Title
quoted should use char_traits::eq for character comparison
Status
c++14
Section
[quoted.manip]
Submitter
Marshall Clow

Created on 2013-07-12.00:00:00 last changed 129 months ago

Messages

Date: 2013-09-26.02:33:30

Proposed resolution:

This wording is relative to N3691.

  1. Change [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 of basic_ostream with member type char_type the same as charT and with member type traits_type, which in the second form is the same as traits, then the expression out << quoted(s, delim, escape) behaves as if it inserts the following characters into out using character inserter function templates (27.7.3.6.4), which may throw ios_base::failure (27.5.3.1.1):

    • delim

    • Each character in s. If the character to be output is equal to escape or delim, as determined by operator==traits_type::eq, first output escape.

    • 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 of basic_istream with member types char_type and traits_type the same as charT and traits, respectively, then the expression in >> quoted(s, delim, escape) behaves as if it extracts the following characters from in using basic_istream::operator>> (27.7.2.2.3) which may throw ios_base::failure (27.5.3.1.1):

      • If the first character extracted is equal to delim, as determined by operator==traits_type::eq, then: […]

    • If out is an instance of basic_ostream with member types char_type and traits_type the same as charT and traits, respectively, then the expression out << quoted(s, delim, escape) behaves as specified for the const basic_string<charT, traits, Allocator>& overload of the quoted function.

Date: 2013-09-26.02:33:30

[ 2013-09 Chicago (late night issues) ]

Moved to Ready, after confirming wording correctly reflects discussion earlier in the day.

Date: 2013-09-25.22:46:19

[ 2013-09 Chicago ]

Marshall Clow improved the wording with support from Stefanus.

Date: 2013-07-12.00:00:00

In [quoted.manip] p2 b2:

— Each character in s. If the character to be output is equal to escape or delim, as determined by operator==, first output escape.

In [quoted.manip] p3 b1 sb1:

— If the first character extracted is equal to delim, as determined by operator==, […]

these should both use traits::eq.

Also, I believe that [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.

History
Date User Action Args
2014-02-27 17:03:20adminsetstatus: wp -> c++14
2014-02-20 13:52:38adminsetstatus: voting -> wp
2014-02-12 14:19:44adminsetstatus: ready -> voting
2013-09-26 02:33:30adminsetmessages: + msg6623
2013-09-26 02:33:30adminsetstatus: new -> ready
2013-09-25 22:46:19adminsetmessages: + msg6620
2013-08-19 20:47:04adminsetmessages: + msg6557
2013-07-12 00:00:00admincreate