Is this code correct?
auto v = make_unique(12);
v.release(); // is this possible?
Is it equivalent to delete
of a
it may be a bit tricky for arbitrary types:
unique_ptr v = get_me_some_foo(); // manages the object
Foo * raw = v.release(); // pointer to no-longer-managed object
delete raw;
is almost correct.
unique_ptr v = get_me_some_foo(); // manages the object
Foo * ptr = v.release(); // pointer to no-longer-managed object
v.get_deleter() ( ptr );
this one would be correct in all situation; there may be a custom deleter defined on type Foo, but using the deleter returned by the unique_ptr object is good for all cases.