This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Changes to std::match_results and <regex>


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]