Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-04-22 06:54:07


David Abrahams wrote:

> Vladimir Prus <ghost_at_[hidden]> writes:
>
>> And it seems to me, all single pass iterators have to store the value to
>> allow for repeated operator*() calls.
>
> Let's talk about concepts in the standard, i.e. input iterator.

Talking about input iterator, directory_iterator does not comply with *r++
requirement.

> We
> invented single pass iterator; it can mean anything we say, and what
> we said doesn't imply that.

But it's the intention that new-style readable single-pass iterator is also
a model of old-style input iterator? And the problem we're discussing is
that directory_iterator is readable single-pass iterator but not input
iterator?

I see that std::input_iterator requirements say that after ++r any copies of
the previous value of r are no longer required to be dereferencable. New
iterators requirents are silent on this. Is this intentional?

If single pass iterator requirements
- would add the same note about ++r making iterators dereferencable
- retain the same requirements for operator++(int)

The result of r++ is not required even to be dereferencable, and *r++ is not
required even to be to work for single-pass iterator, while it works for
input iterators.

The solutions I see are:

1) require that ++r does not makes any copies dereferencable, or
2) allow returning proxy from operator++(int)
3) require that result of r++ is dereferencable and is equivivalent to the
dereferencing of the previous value of 'r'.

The variant 2) would be most convenient for directory_iterator...

- Volodya


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