#include #include #include using std::cout; using std::endl; using std::unique_ptr; int main(int argc, char **argv) { unique_ptr x(new int(5)); cout << "x: " << x.get() << endl; unique_ptr y(x.release()); // x abdicates ownership to y cout << "x: " << x.get() << endl; cout << "y: " << y.get() << endl; unique_ptr z(new int(10)); // y transfers ownership of its pointer to z. // z's old pointer was delete'd in the process. z.reset(y.release()); return EXIT_SUCCESS; }