BOOST_FOREACH and Boost.RegEx

I often use Boost.RegEx as follows: boost::cregex_iterator i = (pBegin, pEnd, /*Stuff here/*); boost::cregex_iterator e; for ( ; i!=e; ++i) { // Stuff here } While there is nothing wrong with this I'd like to be able to use BOOST_FOREACH to do it. For this to work there would need to be a container that contains the iterators instead of just creating them directly.

Stephen Hewitt wrote:
I often use Boost.RegEx as follows:
boost::cregex_iterator i = (pBegin, pEnd, /*Stuff here/*); boost::cregex_iterator e; for ( ; i!=e; ++i) { // Stuff here }
While there is nothing wrong with this I'd like to be able to use BOOST_FOREACH to do it. For this to work there would need to be a container that contains the iterators instead of just creating them directly.
A boost::iterator_range<> with the two regex_iterators would work, or even just a std::pair: BOOST_FOREACH(cmatch const &what, std::make_pair(i,e)) { // use "what" } -- Eric Niebler Boost Consulting www.boost-consulting.com
participants (2)
-
Eric Niebler
-
Stephen Hewitt