
24 Oct
2008
24 Oct
'08
9:09 a.m.
On Fri, Oct 24, 2008 at 9:56 AM, <mbiddeg@mtn.co.ug> wrote:
The tuple-based solution seems elegant if you have a varying number of ranges. For your two ranges requirement, a simple custom writing of a for_each would do, like this:
template<class ForwardIterator, class ForwardIterator2, Class Op> Op for_each(ForwardIterator first, ForwardIterator last, ForwardIterator2 first2, Op op){
for(;first != last; ++first, ++first2) op(*(first), *(first2));
return (op);
}
Does this work for you?
I was thinking more of the general case, rather than two ranges specifically. However I do appreciate that for simple cases the simple solution is often the best, as it probably would be here. Many Thanks. - Rob.