Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-08-30 12:35:41

Joel Eidsath <jeidsath_at_[hidden]> writes:

> I like the BOOST_FOREACH macro, and I'm going to be spending a lot of
> time playing around with it.
> For working with iterator ranges, however, this sort of thing seems to
> be the best that I can come up with:
> //pFirst and pLast are iterators that return an int on dereference
> //they could be some_containter<int>.rbegin() and
> some_container<int>.rend(), for example
> BOOST_FOREACH(int i, vector<int>(pFirst,pLast));
> It's not that ugly, but creating a new vector to do a loop is quite an
> efficiency hit. Is there an better way to do this?

I think

  BOOST_FOREACH(int i, make_iterator_range(whatever.rbegin(), whatever.rend()))

does it (?)

Dave Abrahams
Boost Consulting

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