|
Boost : |
Subject: [boost] [algorithm] adjacent_for_each interest?
From: Ian Hobson (ian.r.hobson_at_[hidden])
Date: 2013-02-10 08:10:18
Hi,
Is there any interest in a version of for_each that operates on each adjacent pair of elements in a range?
#include <iostream>
#include <boost/algorithm/adjacent_for_each.hpp>
void PrintInts(int a, int b) {
std::cout << '(' << a << ", " << b << ")\n";
}
int main() {
const int ints[] = {0, 1, 2, 3, 4};
boost::algorithm::adjacent_for_each(ints, ints + 5, PrintInts);
}
Output:
(0, 1)
(1, 2)
(2, 3)
(3, 4)
Initial implementation available at http://github.com/irh/adjacent_for_each
Best,
Ian
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk