|
Boost : |
From: John Torjo (john.lists_at_[hidden])
Date: 2004-04-21 01:37:49
michael toksvig wrote:
>A while back, Erik Niebler was testing the waters for inclusion of his very,
>very clever looping construct into boost, but nothing really came of it.
>
>Erik's technique is described here:
> http://www.nwcpp.org/Meetings/2004/01.html
>
>Yup, macros are involved and they are yucky, and yup, there already exists a
>for_each in the standard that works just fine if you care to move your loop
>body away into a function, and yup, the name BOOST_FOREACH could use a
>little love.
>
>But there is no denying the notational clarity and succinctness of e.g.:
> foreach(double &d, container)
> d += 2;
>
>
>
You can also use the rtl (Ranges Template Library):
(note: I'll rename the library, wince there's another one with the same
name ;))
for( crange<container> r(cont); r; ++r)
*r += 2;
Best,
John
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk