Opened 13 years ago

Closed 10 years ago

#3643 closed Feature Requests (wontfix)

Auto type deduction in 'foreach'

Reported by: akrzemi1@… Owned by: Eric Niebler
Milestone: Boost 1.42.0 Component: foreach
Version: Boost 1.41.0 Severity: Problem
Keywords: Cc:

Description

I would like to request a new tool in Boost.Foreach that would emulate the following C++0x construct:

for( auto const& x : collection ) { ... }

It would look something like:

BOOST_FOREACH_AUTO( const& x, collection ) {...}

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.

#define BOOST_FOREACH_AUTO( INIT, CONT ) \

BOOST_FOREACH( \

BOOST_TYPEOF( *boost::begin(CONT) ) INIT, \ CONT \

)

Change History (2)

comment:1 by alex@…, 10 years ago

Is this feature going to be accepted?

comment:2 by Eric Niebler, 10 years ago

Resolution: wontfix
Status: newclosed

Ah, sorry no. BOOST_FOREACH 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.

Note: See TracTickets for help on using tickets.