[util.smartptr.shared.dest]

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

## 20.3 Smart pointers [[smartptr]](smartptr#util.smartptr.shared.dest)

### 20.3.2 Shared-ownership pointers [[util.sharedptr]](util.sharedptr#util.smartptr.shared.dest)

#### 20.3.2.2 Class template shared_ptr [[util.smartptr.shared]](util.smartptr.shared#dest)

#### 20.3.2.2.3 Destructor [util.smartptr.shared.dest]

[ð](#lib:shared_ptr,destructor)

`constexpr ~shared_ptr();
`

[1](#1)

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

*Effects*: 

- [(1.1)](#1.1)

  If *this is empty or shares ownership with anothershared_ptr instance (use_count() > 1), there are no side effects[.](#1.1.sentence-1)

- [(1.2)](#1.2)

  Otherwise, if *this owns an objectp and a deleter d, d(p) is called[.](#1.2.sentence-1)

- [(1.3)](#1.3)

  Otherwise, *this owns a pointer p,
and delete p is called[.](#1.3.sentence-1)

[2](#2)

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

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

Since the destruction of *this decreases the number of instances that share ownership with *this by one,
after *this has been destroyed
all shared_ptr instances that shared ownership with*this will report a use_count() that is one less
than its previous value[.](#2.sentence-1)

â *end note*]
