Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-07-26 17:18:51


Anthony Williams <anthony_w.geo_at_[hidden]> writes:

> I am somehow failing to communicate the design to you; it may be best for you
> to look at the code, or read my article on the original pair-based
> implementation (http://web.onetel.com/~anthony_w/cplusplus/pair_iterators.pdf)
>
> I worked hard on this to ensure it met all the requirements of the various
> iterator categories. I am disturbed that I missed the requirement about ==
> implying the same object, but please do not assume that other requirements are
> not met unless you have direct evidence.

I wasn't assuming; I was just wrong ;-)

> operator* returns a real reference to an object stored within the
> iterator. This object is a tuple of references to the objects returned by
> dereferencing the source iterators, with some custom behaviour to handle
> copying.
>
> This custom behaviour means that copies of this tuple actually hold copies of
> the originally-referenced data, and the references on this new copy point back
> within itself to the copies of the data.

That is evil and sneaky! I love it!

Thanks for the explanation.

Is that object the same as the iterator's value_type? If so, I don't
see how swap(*i1, *i2) can work, and thus most sort implementations
should fail. If not, it's not conforming in another way because operator*
must be a reference to value_type. Have I missed something else?

-- 
Dave Abrahams
Boost Consulting
http://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