I need help understanding some code.
I have read in other places that passing a string literal as a const char*
is legal. But, in the last line of this code from cppreference for user-defined string literals, it says that there is no literal operator for "two"
. Why is that, if the string literal "two"
can be passed to the function taking const char*
?
long double operator "" _w(long double);
std::string operator "" _w(const char16_t*, size_t);
unsigned operator "" _w(const char*);
int main() {
1.2_w; // calls operator "" _w(1.2L)
u"one"_w; // calls operator "" _w(u"one", 3)
12_w; // calls operator "" _w("12")
"two"_w; // error: no applicable literal operator
}