我很确定整数、字符、 bool 值和浮点文字的值类别是纯右值。
用户定义的文字就像函数调用,因此它们的值类别取决于它们解析为的运算符函数的返回类型。
我不清楚字符串文字。它们的类型为“array of const charx”,其中 charx 是某种字符类型。
它在 3.10 中说:
The value of a literal ... is also a prvalue.
但我认为这可能不适用于字符串文字?
字符串文字的值类别是什么?你是如何确定的?
最佳答案
So I'm pretty sure the value category of integer, character, boolean and floating literals are prvalues.
没错。
What is the value category of a string literal?
根据 C++11 标准的第 5.1.1/1 段:
A literal is a primary expression. Its type depends on its form (2.14). A string literal is an lvalue; all other literals are prvalues.
关于c++ - 字符串文字的值类别是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15036281/