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.

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

Section: 30.7 [re.regex] Status: C++20 Submitter: Mark de Wever Opened: 2019-09-16 Last modified: 2021-02-25

Priority: 0

View all other issues in [re.regex].

View all issues with C++20 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.7 [re.regex] p3:

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

30.7.3 [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.7 [re.regex] and 30.7.3 [re.regex.assign] I propose to add a default argument for this overload in the declaration in 30.7 [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.

[2019-10-31 Issue Prioritization]

Status to Tentatively Ready and priority to 0 after six positive votes on the reflector.

Proposed resolution:

This wording is relative to N4830.

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

   >     […]
   >     // 30.7.3 [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);
   >     […]