Is this code correct?
auto v = make_unique(12);
v.release(); // is this possible?
Is it equivalent to delete
of a
release
will leak your raw pointer since you don't assign it to anything.
It is meant to be used for something like
int* x = v.release();
Which means v
is no longer managing the lifetime of that pointer, it is delegating the raw pointer ownership to x
. If you just release
without assigning to anything, you leak the raw pointer.