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

3129. regex_token_iterator constructor uses wrong pointer arithmetic

Section: 32.11.2.2 [re.tokiter.cnstr] Status: C++20 Submitter: Tim Song Opened: 2018-06-30 Last modified: 2021-02-25

Priority: 0

View all other issues in [re.tokiter.cnstr].

View all issues with C++20 status.

Discussion:

The specification of regex_token_iterator for the overload taking a const int (&submatchs)[N] uses the range [&submatches, &submatches + N). This is obviously incorrect; we want to perform pointer arithmetic on a pointer to the first element of that array, not a pointer to the whole array.

[2018-07-20 Status to Tentatively Ready after five positive votes on the reflector.]

[2018-11, Adopted in San Diego]

Proposed resolution:

This wording is relative to N4750.

  1. Change 32.11.2.2 [re.tokiter.cnstr] p3 as indicated:

    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                         const regex_type& re,
                         int submatch = 0,
                         regex_constants::match_flag_type m = regex_constants::match_default);
    
    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                         const regex_type& re,
                         const vector<int>& submatches,
                         regex_constants::match_flag_type m = regex_constants::match_default);
    
    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                         const regex_type& re,
                         initializer_list<int> submatches,
                         regex_constants::match_flag_type m = regex_constants::match_default);
    
    template<size_t N>
      regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
                           const regex_type& re,
                           const int (&submatches)[N],
                           regex_constants::match_flag_type m = regex_constants::match_default);
    

    -2- Requires: […]

    -3- Effects: The first constructor initializes the member subs to hold the single value submatch. The second constructor initializes the member subs to hold a copy of the argument submatches. The second, third and fourth constructors initialize the member subs to hold a copy of the sequence of integer values pointed to by the iterator range [submatches.begin(), submatches.end()) and [&submatches, &submatches + N), respectively[begin(submatches), end(submatches)).

    -4- […]