Middle
What assignment allows the use of unique_ptr in C++?
sobes.tech AI
Answer from AI
C++11 allows move assignment for std::unique_ptr.
#include <memory>
std::unique_ptr<int> p1(new int(5));
std::unique_ptr<int> p2 = std::move(p1); // Move assignment
// After this operation, p1 becomes empty, and p2 owns the object.