Hi Cyrille, On May 11, 2004, at 7:29 AM, Cyrille Damez wrote:
Hi all,
I'm currently trying to write a wrapper in order to use the BGL algorithms and visitors on a home-made graph class. If I'm not mistaken, this requires me to write (amongst other things) a couple functions that will return iterators over my graph edges and vertices, eg:
std::pair
out_edges(graph_traits<MyGraph>::vertex_descriptor u, const MyGraph& g) and similarly in_edges(...) , vertices(...) and edges(...) functions. However, it seems that this function profile forces me to do a const_cast on g when implementing the function body since the out_edge_iterators are not const iterators, though they point to internal elements of g.
The BGL iterators are neither const or mutable. Same for the
descriptors.
Instead, mutability is encoded in the property maps. So, for example,
it is okay to
implement out_edge_iterator using a const iterator. See the file
boost/graph/vector_as_graph.hpp for an example. Look at the
implementation of
out_edges, and the val_out_edge_iter class. No const_cast is needed.
Cheers,
Jeremy
_______________________________________________
Jeremy Siek