Value Category (lvalue and rvalue)
Learned in CS247 - Software Engineering Principles. Used for the Move Assignment Operator.
Every expression in C++ has both type and a Value Category.
Lvalue
An lvalue is any expression that you can take the address of.
For example:
- In the above, this expression
x
- we can take its address, therefore it is an lvalue.
Rvalue
An rvalue is a temporary value, it will be destroyed “soon”.
5
is an rvalue, as we cannot take the address of5
.