int main() { // Ptr p1(new Foo); // std::cout << "Foo exists: " << static_cast<bool>(p1) << std::endl; // Vector v; // v.push_back(std::move(p1)); // v.clear(); // std::cout << "Foo exists: " << static_cast<bool>(p1) << std::endl; //foo is gone Foo * rawPtr = new Foo; { Bar bar; bar.add(rawPtr); } std::cout << "foo is gone, can't use rawPtr" << std::endl; }