-
Notifications
You must be signed in to change notification settings - Fork 4
Description
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.
Proposed change:
Apply the following changes to the [string.cons] paragraph 30:
template <class T>
constexpr basic_string& operator=(charT c);
Constraints:
is_same_v<T, charT> is true
Effects: Equivalent to:
return *this = basic_string_view<charT, traits>(addressof(c), 1);
Change the [basic.string] synopsis:
template <class T>
constexpr basic_string& operator=(charT c);