Boost logo

Boost Users :

Subject: Re: [Boost-users] Problem with iterator_facade
From: Daniel Krügler (dsp_at_[hidden])
Date: 2008-09-17 11:45:28


Robert Dailey wrote:
> On Wed, Sep 17, 2008 at 6:21 AM, Daniel Krügler <dsp_at_[hidden]> wrote:
>> I guess you want:
>>
>> <snip>
>>
>> Alternatively you could do this:
>>
>> <snip>
>
> Well I don't want to return by value, and I most certainly don't want
> to return a const reference (Since this Pass object must be mutable).
> For now I did a const_cast in the dereference() function and now I'm
> returning a non-const reference.
>
> If there is no solution to this, then this is broken. Any chance boost
> can fix this? I really don't think it makes much since for constness
> to be an issue here when I never designed my iterator to be const to
> begin with.

Of-course there exists a solution, but I misunderstood your original
request. I think you should declare your member as mutable, which
is the safest way here. If you would use const_cast you would land on
UB island if someone tries to work with a const PassIterator.

- Daniel


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