2016-08-31 38 views
-1

我有一個代碼,可以用Boost 1.49正確編譯。我升級提升到1.61,現在我面對錯誤,如:Boost智能陣列不能正常工作

error: no matching function for call to boost::shared_array::shared_array(unsigned char) Boost/boost/smart_ptr/shared_array.hpp:56: note: candidates are: boost::shared_array::shared_array() [with T = unsigned char] Boost/boost/smart_ptr/shared_array.hpp:45: note: boost::shared_array::shared_array(const boost::shared_array&)

代碼snippate就像

boost::shared_array<uint8_t> val; 
constructor():val(0){} 

可能是什麼造成這種情況的可能的解決方案?

我的當前設置是一臺Linux機器使用GCC 4.1版上。

+2

什麼linux環境下,你運行一個包含GCC的一個古老的版本? [4.1近10歲(2007年2月13日)](https://gcc.gnu.org/releases.html) – sehe

回答

2

您需要升級編譯器。 4.1不支持最新版本的boost。

的片段是在支持的組合沒有問題:

Live On Coliru

#include <boost/smart_ptr/shared_array.hpp> 

struct x { 
    boost::shared_array<uint8_t> val; 
    x() : val(0) {} 
}; 

int main() { 
    x x; 
} 

supported compilers頁:

Linux. GCC 4.5 and newer. Older versions may work too, but it was not tested.

而且

The following compilers/platforms are not supported and will likely fail to compile the library:

...

  • GCC 4.2 and older.
+0

Thanx @sehe。我懷疑GCC版本可能是問題。如果我更改shared_array.hpp的特定部分,其中多個構造函數的實現只有一個定義,那麼可以嗎? – Durgesh