Boost logo

Boost :

From: Pavol Droba (droba_at_[hidden])
Date: 2004-04-06 07:55:18


On Tue, Apr 06, 2004 at 11:59:00AM +0100, John Maddock wrote:
Hi,

> So we make match_results implicitly convertible to it's iterator type? I'm
> not necessarily against that, but there are dangers: mainly as Alan stated
> that you can easily miss corner cases (when the regex matches a zero-length
> string).

I just want to add 0.02p.

Maybe it would be good, to make regex match_results convertible to the iterator_range
defined in the string algo library. iterator_range is used as a result of find
operations, it is convertible to safe-bool and its purpose is to delimit a part of a collection.

It was requested during the review of the string algo library, that this facility
should be extracted and documented as a general purpose utility. It can be standardized
then as a generic result of find operation.

What would be the advantage? User can write

   iterator_range res=regex_maxch(...);
   if(res)
   {
      std::copy(res.begin(), res.end(), It)
      // or what ever
   }

iterator_range copying is cheap, it is safe from the problem of empty match (empty is
a well defined state) and there are algorithms that it can be used with. It the user
does not need all the info provided by the regex match_results (which is not so uncommon)
then iterator_range sufficient.

regex match_results would make a logical extension to iterator_range.

Regards,

Pavol


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