6

So on my VS2010 I can compile code like :

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)));

first 2 lines are ok with boost 1.47.0 and linux... but on std::move it gives error: ‘move’ is not a member of ‘std’. On VS2010 it does not require any special header. So I wonder which header it requires on linux and is it in its STD anyway? If not how to get around it with boost or something?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Rella
  • 65,003
  • 109
  • 363
  • 636
  • 1
    Related: [What std::move() is?](http://stackoverflow.com/questions/3413470/what-stdmove-is) – dee-see Aug 31 '11 at 00:19
  • 2
    To answer the "which header" bit, it's in ``, but you may well find that many other standard headers include that in any given implementation, hence the impression that it doesn't require any special header. – Steve Jessop Aug 31 '11 at 00:42

3 Answers3

15

To get g++ into C++11 (or C++0x) mode, you have to add the command-line parameter -std=c++0x on versions <= 4.6, nowadays you can also use -std=c++11.

filmor
  • 30,840
  • 6
  • 50
  • 48
1

You are using the most recent Visual Studio, but not the most recent GCC. The std::move capability is available in the most recent GCC. It is a new feature of C++11.

ex0du5
  • 2,586
  • 1
  • 14
  • 14
-1

You can't use std::move because your compiler does not support c++11.

Mythli
  • 5,995
  • 2
  • 24
  • 31