std::string::operator=(const char*)
is not &-qualified, meaning it allows assignment to lvalues as well as rvalues.
Some argue(1) that assignment operators should be &-qualified to ban assignment to rvalues:
(1) E.g. the High Integrity C++ standard intended for safety-critical C++ development, particularly rule 12.5.7 Declare assignment operators with the ref-qualifier &.
struct S {
S& operator=(const S&) & { return *this; }
};
int main() {
S {} = {}; // error: no viable overloaded '='
}
Or, more explicitly:
struct S {
S& operator=(const S&) & { return *this; }
S& operator=(const S&) && = delete;
};
int main() {
S {} = {}; // error: overload resolution selected deleted operator '='
}