Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-05-10 13:53:14

Thorsten Ottosen wrote:
> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
> news:02b001c554cd$47504940$6401a8c0_at_pdimov2...


>> 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.

Correct. I think that the benefits of not having to include <iterator> and
confining this to a pure core extension not requiring library support
outweigh the costs.

pair<iterator, iterator> is not the proper way to express an iterator range
anyway; its use in the standard library only serves to highlight the lack of
iterator_range<iterator>, or even range<iterator>, if you prefer.

>> One reasonable extension
> perhaps. C++ is typed language.
>> would be to allow [type] to be omitted, ...

This form is even more typed than the other, because it doesn't let you
accidentally supply a wrong type.

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