Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-05-10 13:13:10


"Peter Dimov" <pdimov_at_[hidden]> wrote in message
news:02b001c554cd$47504940$6401a8c0_at_pdimov2...
| 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.

but it wouldn't work with pair<iterator,iterator> without an adapter.

| One reasonable extension

perhaps. C++ is typed language.

| would be to allow [type] to be omitted, with
| semantics:
|
| {
| decltype(*i) [identifier] = *i;
| [statement]
| }
|
| Note that this is not the same as auto.

yep, because auto drops references.

-Thorsten


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