Changes to std::match_results and <regex>
Stephen M. Webb
stephen.webb@bregmasoft.ca
Sun Jun 6 19:54:00 GMT 2010
Quoting Jonathan Wakely <jwakely.gcc@gmail.com>:
> [...]
> My suggested implementation is documented in the code:
>
> The vector base is empty if this does not represent a successful match.
> Otherwise it contains n+3 elements where n is the number of marked
> sub-expressions:
> [0] entire match
> [1] 1st marked subexpression
> ...
> [n] nth marked subexpression
> [n+1] prefix
> [n+2] suffix
>
> This means size() == n+1 == (N ? N-2 : 0)
> Copying, moving and swapping, as well as empty(), are now simply
> forwarded to the vector base.
>
> I made position() return -1 for out-of-range, consistent with
> boost::regex (and with e.g. string::find)
>
> operator[] checks its argument and returns a static object
> representing an unmatched subexpression (as required).
>
> Does anyone have any objections or improvements to this change?
I like this. Do you have test cases?
--
Stephen M. Webb
More information about the Libstdc++
mailing list