Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2004-04-06 18:39:13


David Abrahams wrote:
> Pavol Droba <droba_at_[hidden]> writes:
>>On Tue, Apr 06, 2004 at 02:43:20PM -0400, David Abrahams wrote:
>>>>What would be the advantage? User can write
>>>> iterator_range res=regex_maxch(...);
>>>
>>>Doesn't the match object get destroyed here, thereby invalidating the
>>>iterators?
>>>
>>Not really as far as I know. Iterators are bound to the collection that is being searched,
>>not to the match itself. Therfore, they validity should not be bound the lifetime
>>of them match. They will be copied to the iterarator_range.
>
> The match object *is* the collection (of submatches) being searched.
>

A sub-match is just a glorified pair of iterators. The iterators refer
to the sequence being searched, which has a lifetime independent of the
match object. There is no risk of iterator invalidation here.

-- 
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