[util.smartptr.hash]

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

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

### 20.3.3 Smart pointer hash support [util.smartptr.hash]

[ð](#lib:hash,unique_ptr)

`template<class T, class D> struct hash<unique_ptr<T, D>>;
`

[1](#1)

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

Letting UP be unique_ptr<T, D>,
the specialization hash<UP> is enabled ([[unord.hash]](unord.hash "22.10.19 Class template hash"))
if and only if hash<typename UP​::​pointer> is enabled[.](#1.sentence-1)

When enabled, for an object p of type UP,hash<UP>()(p) evaluates to
the same value as hash<typename UP​::​pointer>()(p.get())[.](#1.sentence-2)

The member functions are not guaranteed to be noexcept[.](#1.sentence-3)

[ð](#lib:hash,shared_ptr)

`template<class T> struct hash<shared_ptr<T>>;
`

[2](#2)

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

For an object p of type shared_ptr<T>,hash<shared_ptr<T>>()(p) evaluates to
the same value as hash<typename shared_ptr<T>​::​element_type*>()(p.get())[.](#2.sentence-1)
