Boost C++ Libraries: Ticket #3643: Auto type deduction in 'foreach' https://svn.boost.org/trac10/ticket/3643 <p> I would like to request a new tool in Boost.Foreach that would emulate the following C++0x construct: </p> <blockquote> <p> for( auto const&amp; x : collection ) { ... } </p> </blockquote> <p> It would look something like: </p> <blockquote> <p> BOOST_FOREACH_AUTO( const&amp; x, collection ) {...} </p> </blockquote> <p> To prove it is doable I enclose the following suboptimal implementation as a proof of concept. It was already pointed out that the faster implementation is possible. </p> <p> #define BOOST_FOREACH_AUTO( INIT, CONT ) \ </p> <blockquote> <p> BOOST_FOREACH( \ </p> <blockquote> <p> BOOST_TYPEOF( *boost::begin(CONT) ) INIT, \ CONT \ </p> </blockquote> <p> ) </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3643 Trac 1.4.3 alex@… Thu, 15 Nov 2012 14:21:28 GMT <link>https://svn.boost.org/trac10/ticket/3643#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3643#comment:1</guid> <description> <p> Is this feature going to be accepted? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Thu, 15 Nov 2012 18:31:40 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3643#comment:2 https://svn.boost.org/trac10/ticket/3643#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> Ah, sorry no. <code>BOOST_FOREACH</code> is legacy and is in maintenance mode. No new features will be added. The C++11 range-based for loop is the replacement. Please use that. </p> Ticket