C++ linux:错误:'move'不是'std'的成员如何绕过它?

Rel*_*lla 4 c++ boost move std move-semantics

所以在我的VS2010上我可以编译代码如下:

boost::shared_ptr<boost::thread> internal_thread;
boost::packaged_task<void> internal_task_w(boost::bind(&thread_pool::internal_run, this, internal_thread));
internal_thread = boost::shared_ptr<boost::thread>( new boost::thread(std::move(internal_task_w)));
Run Code Online (Sandbox Code Playgroud)

使用boost 1.47.0和linux ...前两行是正常的但是在std :: move它给出了error: ‘move’ is not a member of ‘std’.在VS2010上它不需要任何特殊标头.所以我想知道它在Linux上需要哪个头,无论如何它都在STD中吗?如果不是如何通过提升或其他东西绕过它?

fil*_*mor 14

要使g ++进入C++ 11(或C++ 0x)模式,您必须-std=c++0x在版本<= 4.6上添加命令行参数,现在您也可以使用-std=c++11.

  • 在gcc 4.7.3上我还必须`#include <utility>`来摆脱这个错误. (4认同)