[unique.ptr.single.modifiers]

# 20 Memory management library [[mem]](./#mem)

## 20.3 Smart pointers [[smartptr]](smartptr#unique.ptr.single.modifiers)

### 20.3.1 Unique-ownership pointers [[unique.ptr]](unique.ptr#single.modifiers)

#### 20.3.1.3 unique_ptr for single objects [[unique.ptr.single]](unique.ptr.single#modifiers)

#### 20.3.1.3.6 Modifiers [unique.ptr.single.modifiers]

[ð](#lib:release,unique_ptr)

`constexpr pointer release() noexcept;
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2841)

*Postconditions*: get() == nullptr[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2845)

*Returns*: The value get() had at the start of
the call to release[.](#2.sentence-1)

[ð](#lib:reset,unique_ptr)

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

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2857)

*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](#note-1)*:

The order of these operations is significant
because the call to get_deleter() might destroy *this[.](#3.sentence-1)

â *end note*]

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2867)

*Postconditions*: get() == p[.](#4.sentence-1)

[*Note [2](#note-2)*:

The postcondition does not hold if the call to get_deleter() destroys *this since this->get() is no longer a valid expression[.](#4.sentence-2)

â *end note*]

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2875)

*Remarks*: The behavior is undefined
if the evaluation of get_deleter()(old_p) throws an exception[.](#5.sentence-1)

[ð](#lib:swap,unique_ptr)

`constexpr void swap(unique_ptr& u) noexcept;
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2887)

*Preconditions*: get_deleter() is swappable ([[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")) and
does not throw an exception under swap[.](#6.sentence-1)

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L2892)

*Effects*: Invokes swap on the stored pointers and on the stored
deleters of *this and u[.](#7.sentence-1)
