【发布时间】:2012-12-28 15:47:36
【问题描述】:
这是代码(来自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;
}
我在编译时遇到问题。我试过了:
g++ 2.cpp -o 2 -I /usr/include/boost
还有其他组合,但这是错误的。
错误:
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
我在路径中有“增强包含”: /usr/include/boost 在 /usr/lib 中,与 boost 没有任何关系。 我已经使用这个命令在 ubuntu 上安装了 boost:
sudo apt-get install libboost-all-dev
你有一些用于 boost 程序的通用编译吗? 另一个程序也是用 c++ 编写的,使用 boost 我正常编译没有错误:
g++ 1.cpp -o 1
./1
【问题讨论】:
-
:/usr/include/boost/container$ dpkg -S list.hpp 表示 libboost1.48-dev:/usr/include/boost/container/list.hpp