
Gokulakannan Somasundaram wrote:
Meanwhile, a gentleman helped me by providing this code. Posting it here for any comments #include
#define FOREACH_2(def1, def2, r1, r2) \
for(std::pair
_it12_((r1).begin(),(r2).begin()),\ _e12_((r1).end(), (r2).end()); \ [...]
If you don't mind the "weight" of BOOST_TYPEOF just for a for loop, it's not bad as some of the complexity is hidden in that inner macro. However bear in mind in falls short of the original FOREACH because it uses its arguments r1 and r2 repeatedly which may be inefficient, or even flat out wrong, if r1 and/or r2 are temporaries. Also, there is an open ticket against some extra functionality in Boost.Foreach - BOOST_FOREACH_FIELD I think it is called. If that macro came to pass, I think you could solve your use case with a make_zip_range. Pete