#include <boost/typeof/typeof.hpp>
#define FOREACH_2(def1, def2, r1, r2) \
for(std::pair<BOOST_TYPEOF((r1).begin()), \
BOOST_TYPEOF((r2).begin())> _it12_((r1).begin(),(r2).begin()),\
_e12_((r1).end(), (r2).end()); \
_it12_.first != _e12_.first && _it12_.second != _e12_.second; \
++_it12_.first, ++_it12_.second) \
if(int _cnt1_ = 1) \
for(def1 = *_it12_.first; _cnt1_; _cnt1_ = 0) \
if(int _cnt2_ = 1) \
for(def2 = *_it12_.second; _cnt2_; _cnt2_ = 0)
Thanks,
Gokul.
>Meanwhile, a gentleman helped me by providing this code. Posting it here
for any comments
>#include <boost/typeof/typeof.hpp>
>
>#define FOREACH_2(def1, def2, r1, r2)
\
>
> for(std::pair<BOOST_TYPEOF((r1).begin()),
\
> BOOST_TYPEOF((r2).begin())>
_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
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users