
David Abrahams wrote:
Maybe something could be done with "goto"? I haven't looked at BOOST_FOREACH carefully, but I'm imagining something like:
for (C::iterator s = c.begin(), f = c.end(); s != f; ++s) // outer { for(C::reference r = *s;;) // inner { // Body goes here goto continue_; } break; // if there's a break in the body, break out all the way continue_: }
That won't work. Look how BOOST_FOREACH is used: BOOST_FOREACH( int &i, int_vector ) { // body goes here } BOOST_FOREACH must expand to something such that the following scope is treated as the loop body. There is no place to put the continue_ label, and no place to put the goto. I thought about putting a goto somewhere in the inner for loop, like "for( ...; ; goto continue_ )" but C++ doesn't allow that. And even if that worked, it's still borken because a break in the loop body would skip the goto. -- Eric Niebler Boost Consulting www.boost-consulting.com