Transferring the ownership of object from one unique_ptr to another unique_ptr in C++11?
问题 In C++11 we can transfer the ownership of an object to another unique_ptr using std::move() . After the ownership transfer, the smart pointer that ceded the ownership becomes null and get() returns nullptr. std::unique_ptr<int> p1(new int(42)); std::unique_ptr<int> p2 = std::move(p1); // Transfer ownership What are the situations where this will be useful as it is transferring the ownership to another unique_ptr ? 回答1: The following situations involve transferring ownership from one unique