
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...