命名空间提升没有成员

namespace boost has no member

本文关键字:成员 命名空间      更新时间:2023-10-16

我下载了最新版本的Boost库1_60_0,并尝试使用它,但很快就遇到了麻烦。

boost::unordered_map<int, int> map;

这段代码表示"名称空间boost没有成员unordered_map"。我检查了文件,它就在那里。基本上,我尝试从boost命名空间访问的所有内容都发生了同样的情况。

标题包括以下内容:

#include <D:/IP/boost_1_60_0/boost/graph/adjacency_list.hpp>
#include <D:/IP/boost_1_60_0/boost/graph/graph_traits.hpp>
#include <D:/IP/boost_1_60_0/boost/graph/connected_components.hpp>
#include <D:/IP/boost_1_60_0/boost/unordered_map.hpp>
#include <D:/IP/boost_1_60_0/boost/graph/floyd_warshall_shortest.hpp>
#include <D:/IP/boost_1_60_0/boost/numeric/ublas/matrix.hpp>
#include <D:/IP/boost_1_60_0/boost/numeric/ublas/io.hpp>

我想我应该包括更多的内容,但不知道是什么。有什么建议吗?

unordered_map.hpp以这种方式包含其他boost头文件:

#include <boost/config.hpp>

这意味着boost文件夹必须设置为一个额外的包含目录才能工作。

我假设您是在MSVC上编译的,如果是,请右键单击您的项目:properties->C/C++->General,并将文件夹D:/IP/boost_1_60_0/添加为Additional Include Directory。

文档也为您回答了这个问题。