On Mon, 3 Oct 2011, Jupp Tscheak wrote:
Dear users of boost graph library, I would like to extend boost::adjacency_list like this
code: class MyGraph: public boost::adjacency_list<boost::multisetS, boost::vecS, boost::bidirectionalS, boost::property<boost::some_vertex_property, SomeVertexProperty*>, boost::property<boost::some_edge_property, SomeEdgeProperty*> {}
This works as expected.
Is it possible to extend class "MyGraph" with additional vertex and/or edge properties defined?
My first approach was like this
code: template <class AdditionalVertexProperty = boost::no_property, class AdditionalEdgeProperty = boost::no_property> class MyGraph: public boost::adjacency_list<boost::multisetS, boost::vecS, boost::bidirectionalS, boost::property<boost::some_vertex_property, SomeVertexProperty*, AdditionalVertexProperty>, boost::property<boost::some_edge_property, SomeEdgeProperty*, AdditionalEdgeProperty> {}
class ExtendedMyGraph: public MyGraph<boost::property<boost::some_add_vertex_property, SomeAddVertexProperty*> > {}
This, however, led into multiple compiler errors. Does anyone know how to achieve the wanted behavior?
It is unsafe to subclass BGL graph types. However, you can define a metafunction that does what you want: template <typename VP = boost::no_property, typename EP = boost::no_property> struct gen_MyGraph { typedef <your big adjacency_list type> type; }; and then use gen_MyGraph<boost::property<...> >::type as your graph type. -- Jeremiah Willcock