The std::move
technically doesn't move anything, it just gives you an rvalue reference. The actual semantics of moving something only happen because this causes overload resolution to call different functions, so:
std::vector<int> a{1, 2, 3};
std::vector<int> b{std::move(a)};
This is equivalent to:
std::vector<int> a{1, 2, 3};
std::vector<int> b{static_cast<std::vector<int>&&>(a)};
Again, there's nothing special about the rvalue reference &&
that makes it "move" things, all the move semantics are in the std::vector
constructor. The int
type doesn't have any special move semantics, so it doesn't do that.
This makes sense. For a std::vector
, moving the vector and zeroing the original is cheaper than a copy. For an int
, zeroing the original is actually more expensive than just copying it--you have to copy the value anyway, so there is no point in doing extra work to throw away the original.