Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2005-03-10 13:00:31

Russell Hind wrote:
> Is there a way to reverse iterator using BOOST_FOREACH? From a quick
> browse of the docs, it isn't mentioned. I guess it could be done using
> a std::pair of reverse iterators, but would it be easy to build a
> BOOST_REVERSE_FOREACH construct or BOOST_RFOREACH that just runs from
> rbegin to rend?

Grab the range algorithms and adaptors library from the file vault. You
can find it in the file at:

There you'll find the "reverse" range adaptor, which you can use with
BOOST_FOREACH like this:

using boost::adaptor::reverse;
BOOST_FOREACH( int i, my_list | reverse )
     // ...

It's anybody's guess how Borland will handle this, though. :-P

Eric Niebler
Boost Consulting

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