Here is the code (from http://www.boost.org/doc/libs/1_52_0/doc/html/container/move_emplace.html)
#include <boost/container/list.hpp>
#include <cassert>
class non_copy_movable
{
non_copy_movable(const non_copy_movable &);
non_copy_movable& operator=(const non_copy_movable &);
public:
non_copy_movable(int = 0) {}
};
int main ()
{
using namespace boost::container;
list<non_copy_movable> l;
non_copy_movable ncm;
l.emplace(l.begin(), 0);
assert(l.size() == 1);
l.emplace(l.begin());
assert(l.size() == 2);
return 0;
}
I have problem with compilation. I have tried:
g++ 2.cpp -o 2 -I /usr/include/boost
and also other combination but it is wrong.
Errors:
2.cpp:1:36: error: boost/container/list.hpp: No such file or directory
2.cpp: In function ‘int main()’:
2.cpp:13: error: ‘boost’ has not been declared
2.cpp:13: error: ‘container’ is not a namespace-name
2.cpp:13: error: expected namespace-name before ‘;’ token
2.cpp:14: error: ‘list’ was not declared in this scope
2.cpp:14: error: expected primary-expression before ‘>’ token
2.cpp:14: error: ‘l’ was not declared in this scope
I have "boost include" in path: /usr/include/boost in /usr/lib there is nothing connected with boost. I have installed boost on ubuntu using this command:
sudo apt-get install libboost-all-dev
Have you got some universal compilation for boost program? Another program with is also written in c++ using boost I compile normally without errors:
g++ 1.cpp -o 1
./1