[unique.ptr.single.modifiers] (original) (raw)

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;

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