From: Anthony Williams (anthony.williamsNOSPAM_at_[hidden])
Date: 2003-09-22 08:15:04
David Abrahams <dave_at_[hidden]> writes:
> Anthony Williams <anthony.williamsNOSPAM_at_[hidden]> writes:
>> David Abrahams <dave_at_[hidden]> writes:
>>> Anthony Williams <anthony.williamsNOSPAM_at_[hidden]> writes:
>>>> I would like to submit my "pair iterators" library for inclusion in
>>>> boost. The library is described in my article "Pairing off Iterators" from
>>>> Overload 51, which is available at
>>> I think you may be a little late. Have you seen
>> I hadn't. But then, you only checked it in two weeks ago. Does it work
>> correctly with things like this?
>> template<typename It>
>> void rotate_by_one(It begin,It end)
>> typedef std::iterator_traits<It>::value_type ValueType;
>> ValueType value=*begin; // take a copy and keep it around
>> for(It prev=begin++;begin!=end;++begin,++prev)
>> *prev=*begin; // overwrite the value copied
>> *prev=value; // use the copy
>> *that* was the bit that I found hardest to get working --- having a value
>> type such that *it was a real reference, writing to *it updated the
>> underlying iterators, yet copying from *it produced an object of the same
>> type that *didn't* update the underlying iterators.
> The above code would work, but *it is not a real reference and
> doesn't need to be. In fact, I'm pretty sure that would make the
> iterator bigger and slower than neccessary.
*it MUST be a real reference to the value type for Forward/bidi/random access
Iterators (see table 74 of the standard).
-- Anthony Williams Senior Software Engineer, Beran Instruments Ltd. Remove NOSPAM when replying, for timely response.