1
votes

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
1
:/usr/include/boost/container$ dpkg -S list.hpp said libboost1.48-dev: /usr/include/boost/container/list.hpp - Industrial-antidepressant

1 Answers

0
votes

Most of boost are header-only libraries so I'm not surprised that you don't see many, if any boost libraries in /usr/lib.

That said, I think your include path setting is wrong. You're trying to include boost/container/list.hpp but your include path already has "boost" in it. Unless the libraries are installing /usr/include/boost/boost, you either need to remove "boost" from the include path or from the #include line. My preference would be to remove it from the include path as a statement like #include <boost/container/list.hpp> is a lot more informative than #include <container/list.hpp>.