|
Boost : |
From: Anthony Williams (anthony.williamsNOSPAM_at_[hidden])
Date: 2003-09-22 03:54:04
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
>> http://cplusplus.anthonyw.cjb.net/pair_iterators.pdf
> I think you may be a little late. Have you seen
> http://www.boost-consulting.com/boost/boost/iterator/zip_iterator.hpp
> ??
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;
if(begin==end)
{
return;
}
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.
If it does, then I'll let the Ublas guys know, since it was a request from
them to use my code that finally forced me to stop sitting around and submit
it (after all, the article in Overload was published October 2002).
Anthony
-- Anthony Williams Senior Software Engineer, Beran Instruments Ltd. Remove NOSPAM when replying, for timely response.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk