Statement and expression are two important conceptions, you can see
their definition in cppreference.com to see academic explanation. In
C/C++ langauge, there are many expressions, and there are if, switch,
return, block, iteration statements. they are all end with semi-comma.
And function call is a expression, because it can yield a value.
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: lvalue, prvalue, and xvalue;
lvalue is not defined "can be put on the left of =". Because const int a is
also a lvalue, and you can’t put a on the left side of = . It has three
characteristics:
lvalue has Identity, (can be get address by & operator),
lvalue can be persist beyond the expression.
lvalue can’t be move(stolen), because you need to keep original
one intact.
On the contrary, prvalue has no identity, and will not persist beyond
expression and can be move(stolen)
xvalue has identity, and will persist beyond expression and can be
move(stolen)
xvalue is just rvalue reference. Why you need xvalue, because in C++, it
introduce right reference and move semantics.
You need to know, previous codes and explanations just give the basic idea
of rvalue reference. Just like function pointer, we never use function
pointer in simple way, instead, we use it as a function argument to
implement call back. For rvalue reference, We just use it in themove ctor and move assignment. I will explain it in the next
section.