basic_regex
uses non existent string_type
Section: 28.6.7.3 [re.regex.assign] Status: C++11 Submitter: Volker Lukas Opened: 2010-10-21 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [re.regex.assign].
View all issues with C++11 status.
Discussion:
In working draft N3126, subclause 28.6.7.3 [re.regex.assign], paragraphs 12, 13 and 19,
the name string_type
is used. This is presumably a typedef for basic_string<value_type>
, where
value_type
is the character type used by basic_regex
. The basic_regex
template however defines no such typedef, and neither does the <regex>
header or the <initializer_list>
header included by <regex>
.
[ 2010-11-03 Daniel comments and suggests alternative wording: ]
The proposed resolution needs to use
basic_string<charT>
instead ofbasic_string<char>
Previous Proposed Resolution:
Make the following changes to [re.regex.assign]:basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);12 Returns:
assign(
.string_typebasic_string<charT>(ptr), f)basic_regex& assign(const charT* ptr, size_t len, flag_type f = regex_constants::ECMAScript);13 Returns:
assign(
.string_typebasic_string<charT>(ptr, len), f)[..] template <class InputIterator> basic_regex& assign(InputIterator first, InputIterator last, flag_type f = regex_constants::ECMAScript);18 Requires: The type
InputIterator
shall satisfy the requirements for an Input Iterator (24.2.3).19 Returns:
assign(
.string_typebasic_string<charT>(first, last), f)
[ 2010 Batavia ]
Unsure if we should just give basic_regex
a string_type
typedef. Looking for when string_type
was
introduced into regex
. Howard to draft wording for typedef typename traits::string_type string_type
, then move to Review.
[ 2011-02-16: Daniel comments and provides an alternative resolution. ]
I'm strongly in favour with the Batavia idea to provide a separate string_type
within
basic_regex
, but it seems to me that the issue resultion should add one more
important typedef, namely that of the traits type! Currently, basic_regex
is the
only template that does not publish the type of the associated traits type. Instead
of opening a new issue, I added this suggestion as part of the proposed wording.
[2011-02-24 Reflector discussion]
Moved to Tentatively Ready after 6 votes.
Proposed resolution:
Change the class template basic_regex
synopsis, 28.6.7 [re.regex] p. 3, as indicated:
namespace std { template <class charT, class traits = regex_traits<charT> > class basic_regex { public: // types: typedef charT value_type; typedef traits traits_type; typedef typename traits::string_type string_type; typedef regex_constants::syntax_option_type flag_type; typedef typename traits::locale_type locale_type; [..] }; }