Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2006-12-06 02:08:19


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

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk