【问题标题】:Boost smart array is not workingBoost 智能阵列不工作
【发布时间】:2016-08-31 15:25:43
【问题描述】:

我有一段代码可以用 Boost 1.49 正确编译。我将 boost 升级到 1.61,现在我面临如下错误:

错误:没有匹配函数调用 boost::shared_array::shared_array(unsigned char) Boost/boost/smart_ptr/shared_array.hpp:56:注意:候选者是:boost::shared_array::shared_array() [with T = unsigned char] Boost/boost/smart_ptr/shared_array.hpp:45: 注意: boost::shared_array::shared_array(const boost::shared_array&)

代码片段就像

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

可能的解决方案是什么?

我当前的设置是在 GCC 4.1 版的 linux 机器上。

【问题讨论】:

标签: linux boost shared-ptr


【解决方案1】:

您需要升级编译器。任何最新版本的 boost 都不支持 4.1。

sn-p 在支持的组合上没有问题:

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 和更新版本。旧版本也可以工作,但未经过测试。

和

以下编译器/平台不受支持,可能无法编译库:

...

  • GCC 4.2 及更早版本。

【讨论】:

  • 谢谢@sehe。我怀疑 GCC 版本可能是问题所在。如果我将 shared_array.hpp 中实现多个构造函数的特定部分更改为只有 1 个定义,可以吗?
猜你喜欢
  • 1970-01-01
  • 2016-09-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多