看看这个表达式:
T t;
T& ref = t;
ref
表达式是左值
还是右值
?我相信它是右值
因为 ref
没有“指定函数或对象”:
"An lvalue (so called, historically, because lvalues could appear on the left-hand side of an assignment expression) designates a function or an object."
[开放标准草案 n3092]
根据 cppreference , 引用不是对象。
"The following entities are not objects: value, reference [...]"
我有疑问,因为 ref
在 =
的左侧。
最佳答案
I'm in doubt, because ref is in the left side of =.
ref
是一个名称,因此也是一个左值。
I believe it's an rvalue because ref does not "designates a function or an object"
它指定与 t
相同的对象。
关于c++ - 这个表达式是左值还是右值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56116361/