I've been reading a lot about C++ rvalues lately due to work requirements. Combined with some of my practical experience, the following ten conclusions are drawn.
- There are two types of rvalues in C++: prvalues and xvalues.
- One of the effects of rvalue references is to extend the life cycle of rvalues
- Temporary objects are handled as rvalues
- Move constructors can bind rvalue non-constants whenever possible
- For an rvalue object, member functions are allowed to be called
- rvalues can be modified (which means they can be destroyed)
- An rvalue cannot be used as an lvalue, an lvalue can be used as an rvalue.
- A constant lvalue reference can be bound to an rvalue
- Functions that return rvalue references are bad in almost all cases
- Using std::move in return doesn't make things better in most cases, instead it prevents the compiler from optimizing the return value.