Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2005-03-20 21:28:16


Jens Theisen <jens.theisen_at_[hidden]> writes:

> I want to implement my own iterator as single pass traversal with
> reference type value& (a genuine reference).
>
> My problem is, that the iterator facade concludes from the single pass
> traversal, that this is an input/output iterator

I'm afraid you're mistaken.

> and those are generelly subject to a postfix increment proxy.

No, postfix increment proxies are used for any readable iterators that
are not at least forward traversal iterators.

> That is, writing
>
> *iter++ = some_value;
>
> doesn't really do anything but changing a temporary value in the
> proxy.

If that's the case, the iterator_facade is choosing
postfix_increment_proxy instead of writable_postfix_increment_proxy,
on the basis of the fact that you haven't given the iterator a proxy
reference type. I'm not sure I understand the logic behind it, but
iterator_facade assumes that if your readable iterator doesn't support
forward traversal, it must have a proxy reference in order to also be
writable. If you have a counterexample, it would be good to see it.

[Jeremy, Thomas: Can you shed any light on this assumption? Also, it
looks like we left out the requirement that a single-pass iterator is
also an incrementable iterator. Am I mistaken? If not, I'd like to
fix the docs: http://tinyurl.com/2dm3h]

> In addition to this, iter++ == iter would't find a suited overload,
> which seems to be a bug.

That expression is not required to be supported by a single-pass
iterator. See http://tinyurl.com/2dm3h.

> Chancing the traversal tag to forward traversal works correct, but
> that's not really what I want to do. I want my iterator to be single
> pass since I don't support the i == j => ++i == ++j requirement.

Interesting. I'd like to know more.

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

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net