You are not moving anything.
std::move really poorly named: it doesn't make you move; it just returns an rvalue. It is up to the compiler to decide which constructor std::vector<int> call, and what determines whether you exit.
If the container cannot be moved because the target move constructor is not a match, then the copy constructor will be used instead using the basic overload rules.
#include <iostream> struct T { T() = default; T(const T&) { std::cout << "copy ctor\n"; } T(T&&) { std::cout << "move ctor\n"; } }; int main() { T a; T b = std::move(a); // "move ctor" const T c; T d = std::move(c); // "copy ctor" - `const T&&` only matches copy ctor // (shut up GCC) (void) b; (void) d; }
He constructed this method ( const T&& ability to bind to const T& ), at least in part, because the move is for the best effort, just so that you don't have to deal with compiler errors in cases like this.
Lightness races in orbit
source share