Boost logo

Boost :

Subject: Re: [boost] [algorithm] adjacent_for_each interest?
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2013-02-10 17:17:11

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



Boost list run by bdawes at, gregod at, cpdaniel at, john at