Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-08-02 07:26:37


From: "Beman Dawes" <bdawes_at_[hidden]>
> At 12:00 PM 8/1/2002, Mattias Flodin wrote:
>
> >On Thu, Aug 01, 2002 at 08:33:24AM -0400, Beman Dawes wrote:
> >> >What I've been meaning to ask, after this somewhat wordy post, are
two
> >> >things. First, path::begin() returns a mutable iterator. Shouldn't it
> be
> >> >returning a const iterator, for the same reasons as above? Same thing
> >> >goes for path::end().
> >>
> >> I'm not quite sure what you mean here.
> >
> >I mean that code such as
> >
> >path p2("foo/bar");
> >p2.begin() = p2.end();
> >path::iterator it = ++p2.begin();
> >
> >is legal.
>
> Ah, yes, I see what you mean. But that is a general problem with the
> design of iterators, isn't it, rather than a problem with
> path? path::begin() can't return a const iterator; iteration (operator++,
> operator--) wouldn't work!

++p2.begin() already doesn't work. An iterator is not required to be a class
type, and therefore, its rvalues aren't required to support ++. All built-in
rvalues, despite being non-qualifiable, are de-facto const.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk