Boost logo

Boost Users :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2004-05-11 09:50:35


On Tuesday 11 May 2004 08:29 am, Cyrille Damez wrote:
> 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 ?

The iterators won't ever need non-const access to your graph data structure.
The iterators return edge or vertex descriptors, which do not have direct
access to the graph data structure. Notice that every operation on
descriptors includes the graph itself (which can be const or non-const)?
That's what allows the constness of descriptors to be irrelevant.

Granted, there are still some graph representations that might need
const_casts (or something even uglier).

        Doug


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net