Quick Q: Is unique_ptr guaranteed to store nullptr after move? -- StackOverflow

Quick A: Yes. Otherwise, it would be unsafe and a lot less unique.

From SO:

Is unique_ptr guaranteed to store nullptr after move?

std::unique_ptr<int> p1{new int{23}};
std::unique_ptr<int> p2{std::move(p1)};
assert(!p1); // is this always true?

 

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.