c++中类型的分类
Each C++ expression (an operator with its operands, a literal, a variable name, etc.) is characterized by two independent properties: a type and a value category. Each expression has some non-reference type, and each expression belongs to exactly one of the three primary value categories: prvalue, xvalue, and lvalue.
在c++中,每个表达式(带有操作数的运算符、文字、变量名等),都有两个独立属性:类型和值类别。每个都属于prvalue、xvalue和xvalue中的一种
详情可以翻阅:https://en.cppreference.com/w/cpp/language/value_category
- prvalue: 纯右值 ,表达式产生的中间值,不能取地址。 - glvalue: 广义上的左值 - xvalue: 一个即将被销毁的值,但是可以被重复使用,如static_cast<char&&>(x)
、std::move
等
2022/1/11...大约 7 分钟