Effects: Assigns
p to the stored pointer, and then,
with the old value of the stored pointer,
old_p,
evaluates
if (old_p) get_deleter()(old_p);
[
Note 1:
The order of these operations is significant
because the call to
get_deleter() might destroy
*this. —
end note]
Postconditions:
get() == p. [
Note 2:
The postcondition does not hold if the call to
get_deleter()
destroys
*this since
this->get() is no longer a valid expression
. —
end note]
Remarks: The behavior is undefined
if the evaluation of
get_deleter()(old_p) throws an exception
. constexpr void swap(unique_ptr& u) noexcept;
Effects: Invokes
swap on the stored pointers and on the stored
deleters of
*this and
u.