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.
I had a look at the example given in the documentation (dealing with
converting LEDA graphs to the BGL), but I didn't see anything helping me on
this particular issue (also, the example in the doc is a bit outdated since it
uses the deprecated Boost iterator adaptors).
Am I forced to rely on const_cast in these functions, or is there a way to
declare my graph edges, vertices and the corresponding iterators as
const in my graph_traits class ?
I'm a newbie with the BGL, and more generally with this whole traits/template
specialization style of programming, so please excuse me if I overlooked
something obvious.
Cheers.