23 General utilities library [utilities]

23.11 Smart pointers [smartptr]

23.11.1 Class template unique_Β­ptr [unique.ptr]

23.11.1.2 unique_Β­ptr for single objects [unique.ptr.single]

23.11.1.2.5 unique_Β­ptr modifiers [unique.ptr.single.modifiers]

pointer release() noexcept;

Postconditions: get() == nullptr.

Returns: The value get() had at the start of the call to release.

void reset(pointer p = pointer()) noexcept;

Requires: The expression get_Β­deleter()(get()) shall be well formed, shall have well-defined behavior, and shall not throw exceptions.

Effects: Assigns p to the stored pointer, and then if and only if the old value of the stored pointer, old_Β­p, was not equal to nullptr, calls get_Β­deleter()(old_Β­p). [ Note: The order of these operations is significant because the call to get_Β­deleter() may destroy *this.  — end note ]

Postconditions: get() == p. [ Note: The postcondition does not hold if the call to get_Β­deleter() destroys *this since this->get() is no longer a valid expression.  — end note ]

void swap(unique_ptr& u) noexcept;

Requires: get_Β­deleter() shall be swappable and shall not throw an exception under swap.

Effects: Invokes swap on the stored pointers and on the stored deleters of *this and u.