This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++14 status.

2359. How does regex_constants::nosubs affect basic_regex::mark_count()?

Section: 32.4.2 [re.synopt] Status: C++14 Submitter: Jonathan Wakely Opened: 2014-02-01 Last modified: 2017-09-07

Priority: 0

View all other issues in [re.synopt].

View all issues with C++14 status.

Discussion:

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 32.4.2 [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.

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

Proposed resolution:

This wording is relative to N3797.

  1. Apply the following edit to the table in 32.4.2 [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.