I am having issues getting the property map for the graph I am making. I am using bundled properties. I have stripped it down to the example below. I receive an error when I try to grab the type for IndexMap
. The error from both a VC++ compiler and gcc is something along the lines of error forming a reference to void or illegal use of type void
. The error is inside of boost's adjacency_list.hpp
, but is caused by my instantiation of boost::property_map
. I have been unable to understand what the correct type should be. I read the boost docs on bundled properties, but found them a little unhelpful. Any thoughts?
Edit: I am using boost 1.67.0.
Edit2: Apparently changing to vecS
instead of listS
for the vertex representation fixes this. However, I would prefer to use listS
since I need to modify the graph while iterating over it.
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/properties.hpp>
#include <string>
#include <memory>
#include <utility>
#include <vector>
struct MyVertex
{
std::string m_name;
};
int main()
{
using graph_t = boost::adjacency_list<boost::vecS, boost::listS, boost::undirectedS, MyVertex>;
using Vertex = boost::graph_traits<graph_t>::vertex_descriptor;
using IndexMap = boost::property_map<graph_t, boost::vertex_index_t>::type;
std::unique_ptr<graph_t> graph;
std::vector<std::pair<int, int>> edges{ {0,1}, {0,2}, {1,2}, {3,4}, {1,3}, {1,4}};
graph = std::make_unique<graph_t>(edges.begin(), edges.end(), 5);
IndexMap index = boost::get(boost::vertex_index, *graph);
return 0;
}