Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-04-10 07:55:30


Ion Gaztañaga <igaztanaga_at_[hidden]> writes:

>> It's not a legal random access (or even forward) iterator if it
>> visits the same *element* more than once in a traversal. That's why I
>> said the above about the iterator category.
>
> Ooops! I would agree that for non-const values it wouldn't be a
> random-access but as an read iterator with const values you can't notice
> it's returning the same value unless you unconst it.

You can check the address. Is that an issue? I'm not sure. It's the
old "equivalence" problem again.

> The random access tag is in my opinion a strongest point of the
> iterator, you can get a performance boost in many applications
> (specially when implementing containers). I'm out of ideas about how
> to solve this. Can't we live breaking the law? Should we create new
> categories? Just let it as a "poor" input iterator?

We already have new categories. It can report that it has random
access traversal. It's just not allowed to have
random_access_iterator_tag. See the "new iterator categories"
document.

>> Whoops, "constant iterator" is already overloaded with a different
>> meaning. Something else, maybe... "repeat iterator?"
>
> constant_iterator is also very similar to const_iterator.

That's a "pre-existing condition."

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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