
Joel Eidsath <jeidsath@gmail.com> 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 (?) http://www.boost.org/libs/range/doc/utility_class.html#iter_range -- Dave Abrahams Boost Consulting www.boost-consulting.com