Is this code correct?
auto v = make_unique(12);
v.release(); // is this possible?
Is it equivalent to delete
of a
Is this code correct?
No. Use std::unique_ptr<>::reset()
to delete the internal raw pointer:
auto v = std::make_unique(12);
v.reset(); // deletes the raw pointer
After that is done, std::unique_ptr<>::get()
will return nullptr
(unless you provided a non-nullptr
parameter to std::unique_ptr<>::reset()
).