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 toescape
ordelim
, 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
out
is an instance ofbasic_ostream
with member typechar_type
the same ascharT
and 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 intoout
using character inserter function templates (27.7.3.6.4), which may throwios_base::failure
(27.5.3.1.1):
delim
Each character in
s
. If the character to be output is equal toescape
ordelim
, as determined byoperator==
traits_type::eq
, first outputescape
.
delim
template <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
in
is an instance ofbasic_istream
with member typeschar_type
andtraits_type
the same ascharT
andtraits
, 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
out
is an instance ofbasic_ostream
with member typeschar_type
andtraits_type
the same ascharT
andtraits
, respectively, then the expressionout << quoted(s, delim, escape)
behaves as specified for theconst basic_string<charT, traits, Allocator>&
overload of the quoted function.