Boost logo

Boost :

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


Thorsten Ottosen wrote:
> Eric Niebler <eric <at> boost-consulting.com> 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] )
    [statement]

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;
    [statement]
}

doesn't require library support.

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

{
    decltype(*i) [identifier] = *i;
    [statement]
}

Note that this is not the same as auto.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk