Boost logo

Boost Users :

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


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

> David Abrahams wrote:
>>>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.
>
> My reference type is a simple reference, I want to implement an lvalue
> iterator (at least in some cases).

And why is it only single-pass?

> I am trying to make a proxy iterator
                        ^^^^^^^^^^^^^^
What do you mean by that?

> that can be attached to different
> implementations of other iterators and compositions thereof.
>
> The problem with Forward traversal is that I can't really compare to
> iterators at the moment. My equals is defined as true iff both sides are
> empty (past the end of the sequence). :-)

I don't see why that would be incompatible with forward traversal. We
don't even seem to have a requirement that a copy of an iterator
compares equal with it. Perhaps we should; then you might be in
trouble [Jeremy, Thomas, your thoughts?]

> I thought changing this would require passing the comparison
> functionality through to the implementations, what I don't really want
> to do; in part because the implementations can be quite nested, so this
> would be a bit slow for something that I need solely as an
> end-of-sequence test.

That shouldn't be slow if there's plenty of inlining.

> To be honest, I don't consider this a real problem anymore. I could
> simply attach a counter to the iterators to do the actual comparison.
> So, Forward traversal it is.

Well, I think we must have some logic errors in iterator_facade,
though. This case confuses even me.

-- 
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