
Hi, 2013/2/11 Nathan Ridge <zeratul976@hotmail.com>
Is there any interest in a version of for_each that operates on each adjacent pair of elements in a range? [...]
P.S. Consider implementation of companion - transform_adjacent. Maybe even consider version which accepts "count of adjacent elements within each iteration" as template non-type parameter. Or maybe choose some another approach involving Boost.Range?
I think a more general approach would be a Boost.Range-style range adaptor [1] that presents a view of the range where elements in the view are pairs of (references to, if desired) elements in the underlying range. You can then use standard algorithms like for_each and transform on the adapted range.
I have written such an adaptor in the past and called it 'adjacent_paired'. I've also seen (can't remember where) the name 'windowed' used for the more general version which presents a view of tuples of N adjacent elements.
Regards, Nate
[1] http://www.boost.org/doc/libs/1_53_0/libs/range/doc/html/range/reference/ada...
Agree. I have range-adaptor implementation already. Please see: http://dl.dropbox.com/u/1682460/git/OvenToBoost/libs/range/doc/html/range_ex... https://github.com/faithandbrave/OvenToBoost/blob/master/boost/range/adaptor...
======================== Akira Takahashi mailto:faithandbrave@gmail.com site: https://sites.google.com/site/faithandbrave/about/en