Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-05-09 14:28:25

Thorsten Ottosen wrote:
> Eric Niebler <eric <at>> writes:
>> Also it requires users to #include <iterator> in order to use the new
>> looping construct. There's precedent for that, though, because users
>> must #include <typeinfo> to use typeid. I can't decide how I feel
>> about that. Perhaps there's another way.
> I spoke with several implementers and they all said that we need to
> include some special header...otherwise it is very problematic to let
> the compiler and standard library work together.

That's a consequence of the complexity of the proposal. Something like:

for( [type] [identifier] : [expr] )

Let e of type E be the value of [expr]. For each iterator i in the range

- [ e.begin(), e.end() ) when E is not an array type;
- [ e, e + N ) when E is T[N],

executes the compound statement

    [type] [identifier] = *i;

doesn't require library support.

One reasonable extension would be to allow [type] to be omitted, with

    decltype(*i) [identifier] = *i;

Note that this is not the same as auto.

Boost list run by bdawes at, gregod at, cpdaniel at, john at