/// This is an example to demonstrate a problem I encountered with the /// Boost Graph Library's (BGL) make_iterator_property_map when used /// in conjunction with my own graph that has its property_map /// specialization for vertex_index_t define the const_type as a true /// const type. /// /// Is there a reason that make_iterator_property_map takes its second /// argumant "by value" rather than "by referenc"e as the property_map /// constructor does? This seems to cause an extra copy construction /// to be performed that results in a non-const type which then does /// does not match the property_map's constructor resulting in a /// compilation error on GCC. #include "bug_report_example_skeleton.hpp" #include // #include "reverse_graph.hpp" void bug_report_example_reverse_graph(MyGraph::Graph& g) { typedef boost::reverse_graph ReverseMyGraph; /// The following does not compile because reverse_graph assumes /// that the BidirectionalGraph template argument will have an /// edge_property_type and a vertex_property_type. A user defined /// graph that has been adapted by providing a specialization for /// graph_traits and the other associated code may not have these /// types as in this case. /// /// Looking at the code it seems these are only being used to /// allow property_map's to be selected. An alternative way oif /// achieving this is for reverse_graph to provide a /// specialization for property_map that simply defines its /// internals in terms of the base graph's property_map /// specialization. This also simplifies the other code in /// reverse_graph that is currently present to support /// property_map selection. ReverseMyGraph reverse_g = boost::make_reverse_graph(g); /// After fixing the above problem the following does not work /// because the reverse_graph's definition for num_vertices /// specifies the return type in terms of the base graphs /// vertices_size_type. For a user defined graph that has been /// adapted it may not have such a type as in this case. /// /// A solution is to change reverse_graph's num_vertices to use /// graph_traits to obtain the type. This same problem exists on a /// couple of other functions. num_vertices(reverse_g); /// To be consistent some of the other functions need to specify /// both arguments for reverse_graph rather then letting the /// second one default. /// An ammended reverse_graph.hpp is provided that has these /// changes and works with this example. I am not sure if some of /// the property_map related code that is deleted is needed for /// other reasons. It seems that just forwarding the property_map /// of the reverse graph should avoid the need to provide these /// other types that are used by the non-specialized version of /// property_map. By providing an explicit specialization for /// reverse_graph I think these will never be used. }