Title
How does regex_constants::nosubs affect basic_regex::mark_count()?
Status
c++14
Section
[re.synopt]
Submitter
Jonathan Wakely

Created on 2014-02-01.00:00:00 last changed 130 months ago

Messages

Date: 2014-02-13.06:35:03

Proposed resolution:

This wording is relative to N3797.

  1. Apply the following edit to the table in [re.synopt]/1

    Specifies that no sub-expressions shall be considered to be marked, so that when a regular expression is matched against a character container sequence, no sub-expression matches shall be stored in the supplied match_results structure.

Date: 2014-02-13.06:35:03

[ Issaquah 2014-02-12: Move to Immediate ]

Date: 2014-02-01.00:00:00

As discussed in c++std-lib-35399 and its replies, I can see two possible interpretations of the effects of regex_constants::nosubs:

  1. The effect of nosubs only applies during matching. Parentheses are still recognized as marking a sub-expression by the basic_regex compiler, and basic_regex::mark_count() still returns the number of marked sub-expressions, but anything they match is not stored in the results. This means it is not always true that results.size() == r.mark_count() + 1 for a successful match.

  2. nosubs affects how a regular expression is compiled, altering the state of the std::basic_regex object so that mark_count() returns zero. This also affects any subsequent matching.

The definition of nosubs should make this clear.

The wording in [re.synopt]/1 seems to imply that nosubs only has effects during matching, which is (1), but all known implementations do (2). John Maddock confirmed that (2) was intended.

History
Date User Action Args
2014-02-27 17:03:20adminsetstatus: wp -> c++14
2014-02-20 13:52:38adminsetstatus: immediate -> wp
2014-02-13 06:35:03adminsetmessages: + msg6839
2014-02-13 06:35:03adminsetstatus: new -> immediate
2014-02-01 21:25:54adminsetmessages: + msg6806
2014-02-01 00:00:00admincreate