rvalues denote temporaries or objects that want to look like a
temporary. What is so particular about temporaries, is the fact that
they will be used in a very limited way: their value will be read once, and
they will be destroyed. This is a very useful observation in implementing
"move semantics." In other words, "steal resource"
rvalue references will implicitly bind to rvalues and to temporaries that
are the result of an implicit conversion. i.e. float f = 0f; int&& i = f; is
well formed because float is implicitly convertible to int; the reference
would be to a temporary that is the result of the conversion.
How to understand move semantics? Move is not really move a big
chunk of data, It just move index of data. just like you move file in the
hard disk.
Rvalue references allow a function to branch at compile time (via
overload resolution) on the condition "Am I being called on an lvalue or
an rvalue?" It is true that you can overload any function in this manner,
as shown above. But in the overwhelming majority of cases,this kind of overload should occur only for copy constructorsand assignment operators, for the purpose of achieving movesemantics.
First, don’t declare objects const if you want to be able to move from them.
Move requests on const objects are silently transformed into copy
operations.
Second, std::move not only doesn’t actually move anything, it doesn’t even
guarantee that the object it’s casting will be eligible to be moved. The only
thing you know for sure about the result of applying std::move to an object
is that it’s an rvalue.