
on Mon Oct 27 2008, Jonas Persson <l.j.persson-AT-gmail.com> wrote:
David Abrahams skrev:
OK, BOOST_FOREACH aside, iterating over a range returned as a pair of iterators can be painful and ugly:
vertex_iterator pv, ve; tie(pv, ve) = vertices(g); // unpack the pair returned by vertices for (; pv != pe; ++pv) { ... }
However, we can make it much nicer, e.g.:
for (vertex_iterator pv,ve = xxx(pv,vertices(g)); pv != ve; ++pv) { ... }
My only problem is how to spell xxx. The attached proof-of-concept uses operator%, but I don't feel particularly good about that choice either. Ideas?
What is the usecase here?
Iterating over a range returned as a std::pair. But that should be obvious from what I wrote, so I guess I don't understand the question.
I'm curious on why it isn't covered by BOOST_FOREACH
BOOST_FOREACH doesn't give you access to the iterator value, for what that's worth. Also some people don't like to use macros.
and if that case really is common enough for a special solution like this.
I can't comment on that, I'm afraid. -- Dave Abrahams BoostPro Computing http://www.boostpro.com