[util.smartptr.getdeleter]

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

## 20.3 Smart pointers [[smartptr]](smartptr#util.smartptr.getdeleter)

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

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

#### 20.3.2.2.11 get_deleter [util.smartptr.getdeleter]

[ð](#lib:get_deleter,shared_ptr)

`template<class D, class T>
  constexpr D* get_deleter(const shared_ptr<T>& p) noexcept;
`

[1](#1)

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

*Returns*: If p owns a deleter d of type cv-unqualifiedD, returns addressof(d); otherwise returns nullptr[.](#1.sentence-1)

The returned
pointer remains valid as long as there exists a shared_ptr instance
that owns d[.](#1.sentence-2)

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

It is unspecified whether the pointer
remains valid longer than that[.](#1.sentence-3)

This can happen if the implementation doesn't destroy
the deleter until all weak_ptr instances that share ownership withp have been destroyed[.](#1.sentence-4)

â *end note*]
