
Matias Capeletto wrote:
Hi all,
I want to combine BOOST_FOREACH and BOOST_AUTO in my code. With the current libs can do something like:
BOOST_FOREACH( BOOST_TYPEOF( *c.begin() ) v, c ) { ... }
I was wondering if this kind of use can be promote to a more user friendly syntax like:
BOOST_AUTO_FOREACH( v, c ) { ... }
Or ... #define BOOST_AUTO_FOREACH( x, y )\ BOOST_FOREACH( BOOST_TYPEOF( *boost::begin(y) ) x, y ) There are some problems with this. There is no way to specify that you want to iterate by reference instead of by value. Also, if y has a dependent type, we'd need to use BOOST_TYPEOF_TPL instead, giving rise to the blasphemous BOOST_AUTO_FOREACH_TPL. Yuk. Finally, I do NOT want to create a dependency between foreach.hpp and typeof.hpp. Considering the problems, I'm inclined to leave it out. You're certainly free to define your own. -- Eric Niebler Boost Consulting www.boost-consulting.com