Title
basic_string::operator=(charT c) should be constrained
Status
dup
Section
[string.cons]
Submitter
Russia

Created on 2019-11-04.00:00:00 last changed 61 months ago

Messages

Date: 2019-11-07.08:20:25

Proposed resolution:

This wording is relative to N4835.

  1. Modify [basic.string] p3, class template basic_string synopsis, as indicated:

    template<class T>
    constexpr basic_string& operator=(charT c);
    
  2. Modify [string.cons] as indicated:

    template<class T>
    constexpr basic_string& operator=(charT c);
    

    -?- Constraints: is_same_v<T, charT> is true.

    -30- Effects: Equivalent to:

    return *this = basic_string_view<charT, traits>(addressof(c), 1);
    

Date: 2019-11-07.08:20:25

[ 2019-11 Status to Duplicate during Tuesday morning issue processing in Belfast. ]

Duplicate of 2372.

Date: 2019-11-04.00:00:00

Addresses RU 013

Because of the implicit conversion of arithmetic types it is error prone to use the basic_string::operator=(charT c):

double d = 3.14;
std::string s;
s = d; // Compiles

Make sure that the program is ill-formed if an implicit conversion from arithmetic type happens while assigning to std::basic_string. Or at least make sure that the program is ill-formed if an implicit conversion from floating point type happens while assigning to std::basic_string.

History
Date User Action Args
2019-11-07 08:20:25adminsetmessages: + msg10784
2019-11-07 08:20:25adminsetstatus: new -> dup
2019-11-04 19:01:12adminsetmessages: + msg10735
2019-11-04 00:00:00admincreate