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

3296. Inconsistent default argument for basic_regex<>::assign

Section: 30.8 [re.regex] Status: New Submitter: Mark de Wever Opened: 2019-09-16 Last modified: 2019-09-24

Priority: Not Prioritized

View other active issues in [re.regex].

View all other issues in [re.regex].

View all issues with New status.

Discussion:

The declaration of the overload of basic_regex<>::assign(const charT* p, size_t len, flag_type f) has an inconsistent default argument for the flag_type f parameter.

30.8 [re.regex] p3:

basic_regex& assign(const charT* p, size_t len, flag_type f);

30.8.2 [re.regex.assign] before p12:

basic_regex& assign(const charT* ptr, size_t len, flag_type f = regex_constants::ECMAScript);

Since all other overloads have a default argument in both 30.8 [re.regex] and 30.8.2 [re.regex.assign] I propose to add a default argument for this overload in the declaration in 30.8 [re.regex].

It should be pointed out that there exists implementation divergence due to the current wording state: libc++ and libstdc++ do not implement the default argument. The MS STL library does have the default argument.

Proposed resolution:

This wording is relative to N4830.

  1. Modify 30.8 [re.regex], class template basic_regex synopsis, as indicated:

    […]
    // 30.8.2 [re.regex.assign], assign
    […]
    basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
    basic_regex& assign(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
    template<class string_traits, class A>
      basic_regex& assign(const basic_string<charT, string_traits, A>& s,
                          flag_type f = regex_constants::ECMAScript);
    template<class InputIterator>
      basic_regex& assign(InputIterator first, InputIterator last,
                          flag_type f = regex_constants::ECMAScript);
    basic_regex& assign(initializer_list<charT>,
                        flag_type = regex_constants::ECMAScript);
    […]