Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-08-01 19:18:56


At 08:04 PM 8/1/2002, Glen Knowles 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) and then inc/dec the copy.

I doubt users would find that attractive. You would have to cast away
const.

Furthermore, the Standard Library container requirements, table 65, require
that the return type of begin() be "iterator", not "const iterator".

Again, I don't think the Filesystem Library is the place to try to solve
wider iterator problems.

--Beman


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