This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Dup status.
basic_string::operator=(charT c)
should be constrainedSection: 27.4.3.3 [string.cons] Status: Dup Submitter: Russia Opened: 2019-11-04 Last modified: 2019-11-16
Priority: Not Prioritized
View all other issues in [string.cons].
View all issues with Dup status.
Discussion:
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
.
[2019-11 Status to Duplicate during Tuesday morning issue processing in Belfast.]
Proposed resolution:
This wording is relative to N4835.
Modify 27.4.3 [basic.string] p3, class template basic_string
synopsis, as indicated:
template<class T> constexpr basic_string& operator=(charT c);
Modify 27.4.3.3 [string.cons] as indicated:
template<class T> constexpr basic_string& operator=(charT c);-?- Constraints:
-30- Effects: Equivalent to:is_same_v<T, charT>
istrue
.return *this = basic_string_view<charT, traits>(addressof(c), 1);