Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-08-02 12:00:02

From: "Beman Dawes" <bdawes_at_[hidden]>
> At 08:26 AM 8/2/2002, Peter Dimov wrote:
> >From: "Beman Dawes" <bdawes_at_[hidden]>
> >> ... 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 ++.
> >built-in rvalues, despite being non-qualifiable, are de-facto const.
> You're right. I always forget that.
> What to do about it? See my reply to Darin.

Returning a const-qualified iterator is probably the right choice. Although
strictly speaking this doesn't conform to the standard library conventions
that document begin()/end() returning a non-const qualified iterator, I've
always thought that const returns better reflect the intent.

When the iterator is a pointer, the const qualifier will be ignored (by
conforming compilers.)

The only portability problem with returning "iterator const" is that

template<class T> void f(T & t);


will now work when the iterator is a class type, but this is probably pretty

> PS: The Standard itself uses --a.end() twice in the optional sequence
> operations table!

ISTR an issue about it... there it is:

Boost list run by bdawes at, gregod at, cpdaniel at, john at