Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::unique_ptr<int> p1(new int(5));
- std::unique_ptr<int> p2 = p1; //Compile error.
- std::unique_ptr<int> p3(new int(6));
- std::unique_ptr<int> p3 = std::move(p1); //Transfers ownership. p3 now owns the memory and p1 is rendered invalid.
- p3.reset(); //Deletes the memory.
- p1.reset(); //Does nothing.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement