20 Memory management library [mem]

20.3 Smart pointers [smartptr]

20.3.1 Unique-ownership pointers [unique.ptr]

20.3.1.3 unique_­ptr for single objects [unique.ptr.single]

20.3.1.3.6 Modifiers [unique.ptr.single.modifiers]

constexpr pointer release() noexcept;
Postconditions: get() == nullptr.
Returns: The value get() had at the start of the call to release.
constexpr void reset(pointer p = pointer()) noexcept;
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;
Preconditions: get_­deleter() is swappable ([swappable.requirements]) and does not throw an exception under swap.
Effects: Invokes swap on the stored pointers and on the stored deleters of *this and u.