C++ linux : error: ‘move’ is not a member of ‘std’ how to get around it?

12,579

Solution 1

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.

Solution 2

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.

Share:
12,579

Related videos on Youtube

Rella
Author by

Rella

Hi! sorry - I am C/C++ noobe, and I am reading a book=)

Updated on June 04, 2022

Comments

  • Rella
    Rella almost 2 years

    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?

    • dee-see
      dee-see
    • Steve Jessop
      Steve Jessop
      To answer the "which header" bit, it's in <utility>, 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.
  • Nebril
    Nebril over 10 years
    On gcc 4.7.3 I also had to #include <utility> to get rid of this error.
  • Sammy
    Sammy over 6 years
    Thanks, -std=c++11 is the solution. Surprised, c++11 is not the default compiler for Ubuntu 16.04LTS
  • PlasmaBinturong
    PlasmaBinturong almost 6 years
    How do you make it work using cmake and make? How would you pass this option?
  • filmor
    filmor almost 6 years
    @PlasmaBinturong Look here: stackoverflow.com/questions/10851247/…