Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2003-10-13 13:28:27

Daniel Wallin wrote:
> Yeah.. So when using in_range() you'd still need to name your iterators,
> and also place them in the "wrong" scope.

in_range() is provided for use when you *already have* two iterators
defining a range over which to iterate.

> I'd prefer
> for (iter_type iter = x.begin(), end = x.end();
> iter != end; ++iter)
> {}
> over
> iter_type begin = x.begin();
> iter_type end = x.end();
> BOOST_FOREACH(xxx i, in_range(begin, end))
> {}
> any day.

Of course. And some would prefer

     BOOST_FOREACH( xxx i, x )

to either, which is how it is intended to be used.

That said, I'm having misgivings about BOOST_FOREACH. It's cool that it
*can* be done, but I'm not certain it should. And when in doubt, better
to leave it out; I don't think I'm going to push to get it included in
Boost. I'll leave it in the yahoo files section as a curiosity.

Eric Niebler
Boost Consulting

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