The lambda notation has made stl algorithms more accessible. I am still learning to decide when it\'s useful and when to fall back to good old fashioned for-loops. Often, it
After reading up on boost::zip_iterator and boost::iterator_range as suggested by some answers, I came across the extension algorithms in boost::range, and found the exact parallel of the algorithm I wrote for two ranges, but with boost ranges.
A working code for the example would be
#include
template
void foo_two_ranges(vector& data, vector& prop) {
auto rng1 = boost::make_iterator_range(data.begin(), data.end());
auto rng2 = boost::make_iterator_range(prop.begin(), prop.end());
boost::for_each(rng1, rng2, [](Data& d, Property& p) {
if (p.SomePropertySatistfied()) {
d.DoSomething();
}
});
}
Some wrappers and utility functions, similar in mind to what @Jonathan Wakely suggested, can make this even more usable.