Being able to iterate over a range of values is common operation
that is unnecessarily difficult and verbose in current C++. This makes the
language harder to use for novice and experienced programmers alike.

The benefit of a new for loop is two-fold:

Accessibility. Just about any modern language has added a "for each" construct and C++ should do the same to make the language more accessible.

Performance. A second benefit is that a more consistent performance of the loop is guaranteed; for example, it is quite common to write

for( container::iterator i = c.begin(); i != c.end(); ++i )
...

which leads to repeated calls to c.end(). Moreover, the new for loop might be easier parallelized.

This proposal is based on the discussion following Tom Plum's
presentation at the 2004 meeting
in Sydney.

There is a continued interest in a better for loop for C++
(no pun intended).
For example, Eric Niebler's BOOST_FOREACH macro has recently
been accepted into Boost (not yet part of the distribution)
and Trolltech has provided a foreach macro for QT 4.

Remark: this proposal deals only with the core-language mechanism
that makes the loop work with a range; a separate proposal
will consider the necessary library extensions because
the library components are of great value in many other contexts.

The proposal is thus dependent on the following other
C++0x proposals: