From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2004-07-27 04:55:44
David Abrahams <dave_at_[hidden]> writes:
> Anthony Williams <anthony_w.geo_at_[hidden]> writes:
>> 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
>> 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!
> Is that object the same as the iterator's value_type?
Yes, otherwise it wouldn't be conforming (as you point out below)
> 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?
The default implementation of swap is generally along the lines of
void swap(T& lhs,T& rhs)
The initialization of temp creates a genuine copy of the data. The two
assignments then use the assignment operator of boost::tuple to assign through
Does that make it clearer?
-- Anthony Williams Senior Software Engineer, Beran Instruments Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk