[foreach] Request for auto type deduction

Hi, Boost already provides a tool for emulating C++0x auto syntax: auto iter = map_of_strings.begin(); // C++0x BOOST_AUTO( iter, map_of_strings.begin() ); // boost It even works in more complex contexts like: if( BOOST_AUTO(ptr, get_pointer()) ) { ptr->run(); } or: BOOST_AUTO( const& val, vect.front() ); It already provides a tool for emulating C++0x range-based for syntax: for( int & x : vect ) { ...} // C++0x BOOST_FOREACH( int & x, vect ) { ... }; // boost However currently it is impossible to emulate the following C++0x syntax: for( auto & x : collection ) { ... } // C++0x Therefore, I would like to request a new tool in Boost.Foreach that would emulate the above construct, and would look something like: BOOST_FOREACH_AUTO( const& x, collection ) {...} I do not anticipate any technical difficulties with implementing this, as it can already be achiever with a verbose: BOOST_FOREACH( BOOST_TYPEOF( boost::begin(collection) ) const& x, collection ) {..} Regards, &rzej

Andrzej Krzemienski wrote:
Therefore, I would like to request a new tool in Boost.Foreach that would emulate the above construct, and would look something like:
Hi, I asked a similar question on the users mailing list with a very simple implementation mixing auto and foreach : http://lists.boost.org/boost-users/2009/11/53729.php -- Maxime
participants (3)
-
Andrzej Krzemienski
-
Mathias Gaunard
-
Maxime van Noppen