Boost 智能阵列不工作
Boost smart array is not working
我有一个代码可以用 Boost 1.49 正确编译。我将 boost 升级到 1.61,现在我面临如下错误:
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&)
代码片段就像
boost::shared_array<uint8_t> val;
constructor():val(0){}
可能的解决方案是什么?
我当前的设置是在装有 GCC 4.1 版的 linux 机器上。
您需要升级编译器。任何最新版本的 boost 都不支持 4.1。
代码段在支持的组合上没有问题:
#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.
我有一个代码可以用 Boost 1.49 正确编译。我将 boost 升级到 1.61,现在我面临如下错误:
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&)
代码片段就像
boost::shared_array<uint8_t> val;
constructor():val(0){}
可能的解决方案是什么?
我当前的设置是在装有 GCC 4.1 版的 linux 机器上。
您需要升级编译器。任何最新版本的 boost 都不支持 4.1。
代码段在支持的组合上没有问题:
#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.