c++ - boost move 编译错误

标签 c++ boost move

我试图在类主体之外实现 move 构造函数,但它无法正确编译

#include <boost/move/move.hpp>

class Test
{
    BOOST_COPYABLE_AND_MOVABLE(Test)
public:
    Test() {}
    Test(const Test & other) { }
    Test(BOOST_RV_REF(Test) other);
    Test & operator=(BOOST_COPY_ASSIGN_REF(Test) other) { return *this; } 
    Test & operator=(BOOST_RV_REF(Test) other) { return *this; }
};

Test::Test(BOOST_RV_REF(Test) other) { }

这段代码是我用g++编译的,我的g++版本是4.4.7

$ g++ -c test.cpp
test.cpp:15: error: prototype for 'Test::Test(boost::rv<Test>&)' does not match any in class 'Test'
test.cpp:9: error: candidates are: Test::Test(boost:rv<Test>&)
test.cpp:8: error:                 Test::Test(const Test&)
test.cpp:7: error:                 Test::Test()

最佳答案

It also failed with g++ 5.4.0 – flyzero

必须是您的升级版本。

它适用于 g++ 5.4.1 和 Boost 1.64。如果不是,请检查预处理器输出是否有任何包含/宏错误。

关于c++ - boost move 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43992462/

相关文章:

python - 如何记住 PyQt 应用程序的最后一个几何图形?

c++ - 在 Winx64 中使用 Boost::asio:我卡住了,需要弄清楚如何为 x64 构建 libboost_system_xxxx.lib

c++ - 需要多少线程才能使它们成为一个糟糕的选择?

jquery 将 li move 到 ul

c++ - QML 无法将 Shared_ptr<Track> 分配给 [未知属性类型]

c++ - 使用 boost::thread 开始/停止记录数据(第二次更新)

c++ - 如何批量分配 boost::ptr_vector 并调用存储类的构造函数?

vim - 如何使用 v :count in Vim to switch line with line n lines away?

c++ - 为什么将 std::move(object) 和此对象的成员传递给函数会导致 SIGSEGV

c++ - 控制台未聚焦时如何检测按键