Ben Saks in his lesson "Understanding Value Categories" at the 2019 CppCon in Aurora (CO) (great lesson btw) said:
"Character string literals, such as "examplestring", are lvalues because they are basically arrays and they need to be stored in memory."
At the end of the lesson a person ask this question to Ben: "Did you really mean that string literals are lvalues? because, if they are, why I can't assign to a string literal?" He answered "yes, because they act like array and they need a place in memory"
This confused me a little bit
So I have some questions:
If the only reason why string literals are lvalues is that, why they cannot be temporary rvalues? During that lesson he explained that if an rvalue is too big (such as very long integer literals) the compiler store that in memory but that doesn't mean that they are lvalues...
Why can I pass a string literal as a rvalue reference?
std::string a = "string1"+"string2"; if "string1" and "string2" are lvalues how their sum can be an rvalue?
There something that I have missed because, in conclusion, everything would have been right for me if he had said that string literals are xvalues because as array they must have a location in memory but they can't be lvalues because they don't have a "name" and I can't reach them in memory because I'm not able to know the address (ex: int a => &a if I want to reach it)
YouTube link for the lesson: https://youtu.be/XS2JddPq7GQ?si=5aCMj1sm4YKHMPW-
Thank you in advance for your answers.