我已经开始研究一个包含一些 boost 库(线程和 MPI)的项目。我将在其中一个根本不使用 boost 的模块中使用 boost multi_index。仅供参考,这个项目之前没有使用 boost multi index)
一旦我试图包括
boost/multi_index_container.hpp
到文件并构建项目,我收到了一些错误,从以下开始:
Building CXX object CMakeFiles/SimMobility.dir/main.cpp.o
/usr/bin/c++ -fmessage-length=0 -DBOOST_NO_HASH -O0 -g -I/usr/include/postgresql -I/usr/include/soci -I/usr/include/soci/postgresql -I/usr/include/xsd -I/home/vahid/workspace/Basic__Multi_index -o CMakeFiles/SimMobility.dir/main.cpp.o -c /home/vahid/workspace/Basic__Multi_index/main.cpp
In file included from /usr/include/boost/multi_index/detail/node_type.hpp:22:0,
from /usr/include/boost/multi_index/detail/index_base.hpp:21,
from /usr/include/boost/multi_index/detail/base_type.hpp:21,
from /usr/include/boost/multi_index_container.hpp:33,
from /home/vahid/workspace/Basic__Multi_index/geospatial/RoadNetwork.hpp:10,
from /home/vahid/workspace/Basic__Multi_index/main.cpp:25:
/usr/include/boost/multi_index/detail/header_holder.hpp:41:16: error: expected unqualified-id before ‘)’ token
/usr/include/boost/multi_index/detail/header_holder.hpp: In constructor ‘boost::multi_index::detail::header_holder<NodeTypePtr, Final>::header_holder()’:
/usr/include/boost/multi_index/detail/header_holder.hpp:35:32: error: expected primary-expression before ‘)’ token
我可以知道问题是什么吗?是cmake没有找到它需要的东西吗?知道如何解决吗?
编辑: 如果您想查看源代码,这是一个简化版本:
RoadNetwork.hpp:
#pragma once
#include <iostream>
#include <vector>
#include <set>
#include <boost/multi_index_container.hpp> //causing problem!!!!!!!
namespace geo {class Links_pimpl;}
namespace sim_mob
{
//Forward declarations
class Node;
class UniNode;
class MultiNode;
class Point2D;
class Link;
namespace aimsun
{
//Forward declaration
class Loader;
}
//typedef multi_index_container<
//sim_mob::Link,
// indexed_by<
// random_access<>,
//// ordered_unique< member<sim_mob::Link, std::string, &sim_mob::Link::linkID> >
// >
//> Link_m;
class RoadNetwork {
public:
RoadNetwork() { drivingSide=DRIVES_ON_LEFT; } //TEMP
sim_mob::Node* locateNode(const sim_mob::Point2D& position, bool includeUniNodes=false, int maxDistCM=100) const;
private:
std::vector<sim_mob::MultiNode*> nodes;
std::vector<sim_mob::Link*> links;
std::vector<sim_mob::MultiNode*>& getNodesRW() { return nodes; }
std::set<sim_mob::UniNode*>& getUniNodesRW() { return segmentnodes; }
std::vector<sim_mob::Link*>& getLinksRW() { return links; }
friend class sim_mob::aimsun::Loader;
friend class geo::Links_pimpl;
};
}
谢谢你的帮助