How it works...

The output of the first program is as follows (g++ move_01.cpp and ./a.out):

In this program, auto b = std::move(a); does a couple of things:

  1. It casts the vector, a, to the rvalue reference.
  2. As it is an rvalue reference, the vector move constructor is called, which moves the content of the a vector to the b vector.
  3. a doesn't have the original data anymore, b has.

The output of the second program is as follows (g++ moveSemantics2.cpp and ./a.out):

In this second example, the str string we pass to the print method is an lvalue reference (that is, we can take the address of that variable), so it is passed by reference.

The output of the third program is as follows (g++ moveSemantics3.cpp and ./a.out):

In the third example, the method that's being called is the one with the universal reference as a parameter: print (std::string &&s). This is because we cannot take the address of this is a string, which means it is an rvalue reference.

It should be clear now that std::move doesn't actually move anything – it is a function template that performs an unconditional cast to an rvalue, as we saw in the first example. This allows us to move (and not copy) the data to the destination and invalidate the source. The benefits of std::move are huge, especially every time we see an rvalue reference parameter to a method (T&&that would probably* be a copy in the previous versions of the language (C++98 and before). 

*Probably: it depends on compiler optimizations.