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.
quoted should use char_traits::eq for character comparisonSection: 31.7.9 [quoted.manip] Status: C++14 Submitter: Marshall Clow Opened: 2013-07-12 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [quoted.manip].
View all issues with C++14 status.
Discussion:
In 31.7.9 [quoted.manip] p2 b2:
— Each character in
s. If the character to be output is equal toescapeordelim, as determined byoperator==, first outputescape.
In 31.7.9 [quoted.manip] p3 b1 sb1:
— If the first character extracted is equal to
delim, as determined byoperator==, […]
these should both use traits::eq.
Also, I believe that 31.7.9 [quoted.manip] p3 implies that:
std::ostream _stream; std::string _string; _stream << _string; _stream << quoted(_string);
should both compile, or both fail to compile, based on whether or not their char_traits match.
But I believe that the standard should say that explicitly.
[ 2013-09 Chicago ]
Marshall Clow improved the wording with support from Stefanus.
[ 2013-09 Chicago (late night issues) ]
Moved to Ready, after confirming wording correctly reflects discussion earlier in the day.
Proposed resolution:
This wording is relative to N3691.
Change 31.7.9 [quoted.manip] p2+3 as indicated:
template <class charT> unspecified quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\')); template <class charT, class traits, class Allocator> unspecified quoted(const basic_string<charT, traits, Allocator>& s, charT delim=charT('"'), charT escape=charT('\\'));-2- Returns: An object of unspecified type such that if
outis an instance ofbasic_ostreamwith member typechar_typethe same ascharTand with member typetraits_type, which in the second form is the same astraits, then the expressionout << quoted(s, delim, escape)behaves as if it inserts the following characters intooutusing character inserter function templates (27.7.3.6.4), which may throwios_base::failure(27.5.3.1.1):
delimEach character in
s. If the character to be output is equal toescapeordelim, as determined byoperator==traits_type::eq, first outputescape.
delimtemplate <class charT, class traits, class Allocator> unspecified quoted(basic_string<charT, traits, Allocator>& s, charT delim=charT('"'), charT escape=charT('\\'));-3- Returns: An object of unspecified type such that:
If
inis an instance ofbasic_istreamwith member typeschar_typeandtraits_typethe same ascharTandtraits, respectively, then the expressionin >> quoted(s, delim, escape)behaves as if it extracts the following characters from in usingbasic_istream::operator>>(27.7.2.2.3) which may throwios_base::failure(27.5.3.1.1):
If the first character extracted is equal to
delim, as determined byoperator==traits_type::eq, then: […]If
outis an instance ofbasic_ostreamwith member typeschar_typeandtraits_typethe same ascharTandtraits, respectively, then the expressionout << quoted(s, delim, escape)behaves as specified for theconst basic_string<charT, traits, Allocator>&overload of the quoted function.