Boost logo

Boost :

From: Victor A. Wagner, Jr. (vawjr_at_[hidden])
Date: 2002-08-02 11:55:43


At Thursday 2002/08/01 17:04, you wrote:

> > > 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!
>
>I believe begin() should return a const iterator, you then assign it to a
>non-const iterator ("it" above)

Scott Meyers devotes a lot of ink to this. Short story, you can't do the
assign. Long story, "Effective STL" Item 26.

>and then inc/dec the copy.
>
>Glen

Victor A. Wagner Jr. http://rudbek.com
PGP RSA fingerprint = 4D20 EBF6 0101 B069 3817 8DBF C846 E47A
PGP D-H fingerprint = 98BC 65E3 1A19 43EC 3908 65B9 F755 E6F4 63BB 9D93
The five most dangerous words in the English language:
               "There oughta be a law"



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