23 General utilities library [utilities]

23.11 Smart pointers [smartptr]

23.11.1 Class template unique_­ptr [unique.ptr] unique_­ptr for single objects [unique.ptr.single] 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.