Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-10-09 19:08:00


"Brock Peabody" <brock.peabody_at_[hidden]> wrote in message
news:002c01c38eb1$8b4b7680$580a10ac_at_npci.com...

> >
> > I don't think it would be setting a precedent. I see this as filling a
> > hole in the language. Other languages have foreach looping constructs,
> > and C++ is often criticised for the lack of one. Many new C++
> > programmers ask for foreach (See the "D vs. C++" and "anonymous blocks"
> > threads on c.l.c++.m, for example). Nobody asks for a "transform"
> > keyword -- it's not an important enough concept.

I totally agree. A long time ago I found myself using a macro just to avoid
for loops repetitiveness, but turned it
down again because it wasn't good enough. Now if some potent version can
become part of boost, I would definitely
use it.

I do think it should be called FOR_EACH because it's more like a new
keyword. I can't imagine that will clash with anything.

> One thing I use a lot is a "for_each" that takes a container rather than
> iterators. It's a lot easier to write:
>
> for_each(make_a_list(), f);
>
> Than
>
> const std::vector<int> l = make_a_list();
>
> std::for_each(l.begin(), l.end(), f);
>
> I thought there was a thread a while back about container (or even range)
> based algorithms vs the stl iterator based algorithms.

oh yes :-) look in the sandbox in sequence_algo.

regards

-Thorsten


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