#include // for std::unique_ptr #include // for std::cout, std::endl #include // for EXIT_SUCCESS using std::cout; using std::endl; using std::move; using std::unique_ptr; int main(int argc, char **argv) { unique_ptr x(new int(5)); cout << "x: " << x.get() << endl; unique_ptr y = move(x); // y takes ownership, x abdicates it cout << "x: " << x.get() << endl; cout << "y: " << y.get() << endl; unique_ptr z(new int(10)); // z delete's its old pointer and takes ownership of y's pointer. // y abdicates its ownership. z = move(y); return EXIT_SUCCESS; }