[unord]

# 23 Containers library [[containers]](./#containers)

## 23.5 Unordered associative containers [unord]

### [23.5.1](#general) General [[unord.general]](unord.general)

[1](#general-1)

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

The header [<unordered_map>](#header:%3cunordered_map%3e "23.5.2 Header <unordered_­map> synopsis [unord.map.syn]") defines the class
templates unordered_map and unordered_multimap;
the header [<unordered_set>](#header:%3cunordered_set%3e "23.5.5 Header <unordered_­set> synopsis [unord.set.syn]") defines the class
templates unordered_set and unordered_multiset[.](#general-1.sentence-1)

[2](#general-2)

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

The exposition-only alias templates*iter-value-type*, *iter-key-type*,*iter-mapped-type*, *iter-to-alloc-type*,*range-key-type*, *range-mapped-type*,
and *range-to-alloc-type* defined in [[associative.general]](associative.general "23.4.1 General") may appear in deduction guides for unordered containers[.](#general-2.sentence-1)

### [23.5.2](#map.syn) Header <unordered_map> synopsis [[unord.map.syn]](unord.map.syn)

[ð](#header:%3cunordered_map%3e)

#include <compare> // see [[compare.syn]](compare.syn "17.12.1 Header <compare> synopsis")#include <initializer_list> // see [[initializer.list.syn]](initializer.list.syn "17.11.2 Header <initializer_­list> synopsis")namespace std {// [[unord.map]](#map "23.5.3 Class template unordered_­map"), class template unordered_maptemplate<class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, class Alloc = allocator<pair<const Key, T>>>class unordered_map; // [[unord.multimap]](#multimap "23.5.4 Class template unordered_­multimap"), class template unordered_multimaptemplate<class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, class Alloc = allocator<pair<const Key, T>>>class unordered_multimap; template<class Key, class T, class Hash, class Pred, class Alloc>constexpr bool operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& a, const unordered_map<Key, T, Hash, Pred, Alloc>& b); template<class Key, class T, class Hash, class Pred, class Alloc>constexpr bool operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& a, const unordered_multimap<Key, T, Hash, Pred, Alloc>& b); template<class Key, class T, class Hash, class Pred, class Alloc>constexpr void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
 unordered_map<Key, T, Hash, Pred, Alloc>& y)noexcept(noexcept(x.swap(y))); template<class Key, class T, class Hash, class Pred, class Alloc>constexpr void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
 unordered_multimap<Key, T, Hash, Pred, Alloc>& y)noexcept(noexcept(x.swap(y))); // [[unord.map.erasure]](#map.erasure "23.5.3.5 Erasure"), erasure for unordered_maptemplate<class K, class T, class H, class P, class A, class Predicate>constexpr typename unordered_map<K, T, H, P, A>::size_type
 erase_if(unordered_map<K, T, H, P, A>& c, Predicate pred); // [[unord.multimap.erasure]](#multimap.erasure "23.5.4.4 Erasure"), erasure for unordered_multimaptemplate<class K, class T, class H, class P, class A, class Predicate>constexpr typename unordered_multimap<K, T, H, P, A>::size_type
 erase_if(unordered_multimap<K, T, H, P, A>& c, Predicate pred); namespace pmr {template<class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>>using unordered_map = std::unordered_map<Key, T, Hash, Pred,
 polymorphic_allocator<pair<const Key, T>>>; template<class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>>using unordered_multimap = std::unordered_multimap<Key, T, Hash, Pred,
 polymorphic_allocator<pair<const Key, T>>>; }}

### [23.5.3](#map) Class template unordered_map [[unord.map]](unord.map)

#### [23.5.3.1](#map.overview) Overview [[unord.map.overview]](unord.map.overview)

[1](#map.overview-1)

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

An unordered_map is an unordered associative container that
supports unique keys (an unordered_map contains at most one of each
key value) and that associates values of another typemapped_type with the keys[.](#map.overview-1.sentence-1)

The unordered_map class
supports forward iterators[.](#map.overview-1.sentence-2)

[2](#map.overview-2)

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

An unordered_map meets all of the requirements
of a container ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements")),
of an allocator-aware container ([[container.alloc.reqmts]](container.alloc.reqmts "23.2.2.5 Allocator-aware containers")), and
of an unordered associative container ([[unord.req]](unord.req "23.2.8 Unordered associative containers"))[.](#map.overview-2.sentence-1)

It provides the operations described in the preceding requirements table for unique keys;
that is, an unordered_map supports the a_uniq operations in that table,
not the a_eq operations[.](#map.overview-2.sentence-2)

For an unordered_map<Key, T> the key_type is Key,
the mapped_type is T,
and the value_type is pair<const Key, T>[.](#map.overview-2.sentence-3)

[3](#map.overview-3)

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

Subclause [[unord.map]](#map "23.5.3 Class template unordered_­map") only describes operations on unordered_map that
are not described in one of the requirement tables, or for which there
is additional semantic information[.](#map.overview-3.sentence-1)

[4](#map.overview-4)

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

The types iterator and const_iterator meet
the constexpr iterator requirements ([[iterator.requirements.general]](iterator.requirements.general "24.3.1 General"))[.](#map.overview-4.sentence-1)

[ð](#lib:unordered_map__)

namespace std {template<class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>>class unordered_map {public:// typesusing key_type = Key; using mapped_type = T; using value_type = pair<const Key, T>; using hasher = Hash; using key_equal = Pred; using allocator_type = Allocator; using pointer = typename allocator_traits<Allocator>::pointer; using const_pointer = typename allocator_traits<Allocator>::const_pointer; using reference = value_type&; using const_reference = const value_type&; using size_type = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using difference_type = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using const_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using local_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using const_local_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using node_type = *unspecified*; using insert_return_type = *insert-return-type*<iterator, node_type>; // [[unord.map.cnstr]](#map.cnstr "23.5.3.2 Constructors"), construct/copy/destroyconstexpr unordered_map(); constexpr explicit unordered_map(size_type n, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); template<class InputIterator>constexpr unordered_map(InputIterator f, InputIterator l,
 size_type n = *see below*, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr unordered_map(from_range_t, R&& rg, size_type n = *see below*, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); constexpr unordered_map(const unordered_map&); constexpr unordered_map(unordered_map&&); constexpr explicit unordered_map(const Allocator&); constexpr unordered_map(const unordered_map&, const type_identity_t<Allocator>&); constexpr unordered_map(unordered_map&&, const type_identity_t<Allocator>&); constexpr unordered_map(initializer_list<value_type> il, size_type n = *see below*, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); constexpr unordered_map(size_type n, const allocator_type& a): unordered_map(n, hasher(), key_equal(), a) { }constexpr unordered_map(size_type n, const hasher& hf, const allocator_type& a): unordered_map(n, hf, key_equal(), a) { }template<class InputIterator>constexpr unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a): unordered_map(f, l, n, hasher(), key_equal(), a) { }template<class InputIterator>constexpr unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf, const allocator_type& a): unordered_map(f, l, n, hf, key_equal(), a) { }template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr unordered_map(from_range_t, R&& rg, size_type n, const allocator_type& a): unordered_map(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { }template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr unordered_map(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a): unordered_map(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { }constexpr unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a): unordered_map(il, n, hasher(), key_equal(), a) { }constexpr unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf, const allocator_type& a): unordered_map(il, n, hf, key_equal(), a) { }constexpr ~unordered_map(); constexpr unordered_map& operator=(const unordered_map&); constexpr unordered_map& operator=(unordered_map&&)noexcept(allocator_traits<Allocator>::is_always_equal::value && is_nothrow_move_assignable_v<Hash> && is_nothrow_move_assignable_v<Pred>); constexpr unordered_map& operator=(initializer_list<value_type>); constexpr allocator_type get_allocator() const noexcept; // iteratorsconstexpr iterator begin() noexcept; constexpr const_iterator begin() const noexcept; constexpr iterator end() noexcept; constexpr const_iterator end() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr const_iterator cend() const noexcept; // capacityconstexpr bool empty() const noexcept; constexpr size_type size() const noexcept; constexpr size_type max_size() const noexcept; // [[unord.map.modifiers]](#map.modifiers "23.5.3.4 Modifiers"), modifierstemplate<class... Args> constexpr pair<iterator, bool> emplace(Args&&... args); template<class... Args>constexpr iterator emplace_hint(const_iterator position, Args&&... args); constexpr pair<iterator, bool> insert(const value_type& obj); constexpr pair<iterator, bool> insert(value_type&& obj); template<class P> constexpr pair<iterator, bool> insert(P&& obj); constexpr iterator insert(const_iterator hint, const value_type& obj); constexpr iterator insert(const_iterator hint, value_type&& obj); template<class P> constexpr iterator insert(const_iterator hint, P&& obj); template<class InputIterator> constexpr void insert(InputIterator first, InputIterator last); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr void insert_range(R&& rg); constexpr void insert(initializer_list<value_type>); constexpr node_type extract(const_iterator position); constexpr node_type extract(const key_type& x); template<class K> constexpr node_type extract(K&& x); constexpr insert_return_type insert(node_type&& nh); constexpr iterator insert(const_iterator hint, node_type&& nh); template<class... Args>constexpr pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); template<class... Args>constexpr pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); template<class K, class... Args>constexpr pair<iterator, bool> try_emplace(K&& k, Args&&... args); template<class... Args>constexpr iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); template<class... Args>constexpr iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); template<class K, class... Args>constexpr iterator try_emplace(const_iterator hint, K&& k, Args&&... args); template<class M>constexpr pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); template<class M>constexpr pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); template<class K, class M>constexpr pair<iterator, bool> insert_or_assign(K&& k, M&& obj); template<class M>constexpr iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); template<class M>constexpr iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); template<class K, class M>constexpr iterator insert_or_assign(const_iterator hint, K&& k, M&& obj); constexpr iterator erase(iterator position); constexpr iterator erase(const_iterator position); constexpr size_type erase(const key_type& k); template<class K> constexpr size_type erase(K&& x); constexpr iterator erase(const_iterator first, const_iterator last); constexpr void swap(unordered_map&)noexcept(allocator_traits<Allocator>::is_always_equal::value && is_nothrow_swappable_v<Hash> && is_nothrow_swappable_v<Pred>); constexpr void clear() noexcept; template<class H2, class P2>constexpr void merge(unordered_map<Key, T, H2, P2, Allocator>& source); template<class H2, class P2>constexpr void merge(unordered_map<Key, T, H2, P2, Allocator>&& source); template<class H2, class P2>constexpr void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source); template<class H2, class P2>constexpr void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source); // observersconstexpr hasher hash_function() const; constexpr key_equal key_eq() const; // map operationsconstexpr iterator find(const key_type& k); constexpr const_iterator find(const key_type& k) const; template<class K>constexpr iterator find(const K& k); template<class K>constexpr const_iterator find(const K& k) const; constexpr size_type count(const key_type& k) const; template<class K>constexpr size_type count(const K& k) const; constexpr bool contains(const key_type& k) const; template<class K>constexpr bool contains(const K& k) const; constexpr pair<iterator, iterator> equal_range(const key_type& k); constexpr pair<const_iterator, const_iterator> equal_range(const key_type& k) const; template<class K>constexpr pair<iterator, iterator> equal_range(const K& k); template<class K>constexpr pair<const_iterator, const_iterator> equal_range(const K& k) const; // [[unord.map.elem]](#map.elem "23.5.3.3 Element access"), element accessconstexpr mapped_type& operator[](const key_type& k); constexpr mapped_type& operator[](key_type&& k); template<class K> constexpr mapped_type& operator[](K&& k); constexpr mapped_type& at(const key_type& k); constexpr const mapped_type& at(const key_type& k) const; template<class K> constexpr mapped_type& at(const K& k); template<class K> constexpr const mapped_type& at(const K& k) const; // bucket interfaceconstexpr size_type bucket_count() const noexcept; constexpr size_type max_bucket_count() const noexcept; constexpr size_type bucket_size(size_type n) const; constexpr size_type bucket(const key_type& k) const; template<class K> constexpr size_type bucket(const K& k) const; constexpr local_iterator begin(size_type n); constexpr const_local_iterator begin(size_type n) const; constexpr local_iterator end(size_type n); constexpr const_local_iterator end(size_type n) const; constexpr const_local_iterator cbegin(size_type n) const; constexpr const_local_iterator cend(size_type n) const; // hash policyconstexpr float load_factor() const noexcept; constexpr float max_load_factor() const noexcept; constexpr void max_load_factor(float z); constexpr void rehash(size_type n); constexpr void reserve(size_type n); }; template<class InputIterator, class Hash = hash<*iter-key-type*<InputIterator>>, class Pred = equal_to<*iter-key-type*<InputIterator>>, class Allocator = allocator<*iter-to-alloc-type*<InputIterator>>> unordered_map(InputIterator, InputIterator, typename *see below*::size_type = *see below*,
 Hash = Hash(), Pred = Pred(), Allocator = Allocator())-> unordered_map<*iter-key-type*<InputIterator>, *iter-mapped-type*<InputIterator>, Hash, Pred,
 Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Hash = hash<*range-key-type*<R>>, class Pred = equal_to<*range-key-type*<R>>, class Allocator = allocator<*range-to-alloc-type*<R>>> unordered_map(from_range_t, R&&, typename *see below*::size_type = *see below*,
 Hash = Hash(), Pred = Pred(), Allocator = Allocator())-> unordered_map<*range-key-type*<R>, *range-mapped-type*<R>, Hash, Pred, Allocator>; template<class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>> unordered_map(initializer_list<pair<Key, T>>, typename *see below*::size_type = *see below*, Hash = Hash(),
 Pred = Pred(), Allocator = Allocator())-> unordered_map<Key, T, Hash, Pred, Allocator>; template<class InputIterator, class Allocator> unordered_map(InputIterator, InputIterator, typename *see below*::size_type, Allocator)-> unordered_map<*iter-key-type*<InputIterator>, *iter-mapped-type*<InputIterator>,
 hash<*iter-key-type*<InputIterator>>,
 equal_to<*iter-key-type*<InputIterator>>, Allocator>; template<class InputIterator, class Allocator> unordered_map(InputIterator, InputIterator, Allocator)-> unordered_map<*iter-key-type*<InputIterator>, *iter-mapped-type*<InputIterator>,
 hash<*iter-key-type*<InputIterator>>,
 equal_to<*iter-key-type*<InputIterator>>, Allocator>; template<class InputIterator, class Hash, class Allocator> unordered_map(InputIterator, InputIterator, typename *see below*::size_type, Hash, Allocator)-> unordered_map<*iter-key-type*<InputIterator>, *iter-mapped-type*<InputIterator>, Hash,
 equal_to<*iter-key-type*<InputIterator>>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Allocator> unordered_map(from_range_t, R&&, typename *see below*::size_type, Allocator)-> unordered_map<*range-key-type*<R>, *range-mapped-type*<R>, hash<*range-key-type*<R>>,
 equal_to<*range-key-type*<R>>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Allocator> unordered_map(from_range_t, R&&, Allocator)-> unordered_map<*range-key-type*<R>, *range-mapped-type*<R>, hash<*range-key-type*<R>>,
 equal_to<*range-key-type*<R>>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Hash, class Allocator> unordered_map(from_range_t, R&&, typename *see below*::size_type, Hash, Allocator)-> unordered_map<*range-key-type*<R>, *range-mapped-type*<R>, Hash,
 equal_to<*range-key-type*<R>>, Allocator>; template<class Key, class T, class Allocator> unordered_map(initializer_list<pair<Key, T>>, typename *see below*::size_type,
 Allocator)-> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; template<class Key, class T, class Allocator> unordered_map(initializer_list<pair<Key, T>>, Allocator)-> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; template<class Key, class T, class Hash, class Allocator> unordered_map(initializer_list<pair<Key, T>>, typename *see below*::size_type, Hash,
 Allocator)-> unordered_map<Key, T, Hash, equal_to<Key>, Allocator>;}

[5](#map.overview-5)

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

A size_type parameter type in an unordered_map deduction guide
refers to the size_type member type of the type deduced by the deduction guide[.](#map.overview-5.sentence-1)

#### [23.5.3.2](#map.cnstr) Constructors [[unord.map.cnstr]](unord.map.cnstr)

[ð](#lib:unordered_map,constructor)

`constexpr unordered_map() : unordered_map(size_type(see below)) { }
constexpr explicit unordered_map(size_type n, const hasher& hf = hasher(),
                                 const key_equal& eql = key_equal(),
                                 const allocator_type& a = allocator_type());
`

[1](#map.cnstr-1)

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

*Effects*: Constructs an empty unordered_map using the
specified hash function, key equality predicate, and allocator, and
using at least n buckets[.](#map.cnstr-1.sentence-1)

For the default constructor,
the number of buckets is implementation-defined[.](#map.cnstr-1.sentence-2)

max_load_factor() returns 1.0[.](#map.cnstr-1.sentence-3)

[2](#map.cnstr-2)

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

*Complexity*: Constant[.](#map.cnstr-2.sentence-1)

[ð](#lib:unordered_map,constructor_)

`template<class InputIterator>
  constexpr unordered_map(InputIterator f, InputIterator l,
                          size_type n = see below, const hasher& hf = hasher(),
                          const key_equal& eql = key_equal(),
                          const allocator_type& a = allocator_type());
template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>
  constexpr unordered_map(from_range_t, R&& rg,
                          size_type n = see below, const hasher& hf = hasher(),
                          const key_equal& eql = key_equal(),
                          const allocator_type& a = allocator_type());
constexpr unordered_map(initializer_list<value_type> il,
                        size_type n = see below, const hasher& hf = hasher(),
                        const key_equal& eql = key_equal(),
                        const allocator_type& a = allocator_type());
`

[3](#map.cnstr-3)

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

*Effects*: Constructs an empty unordered_map using the
specified hash function, key equality predicate, and allocator, and
using at least n buckets[.](#map.cnstr-3.sentence-1)

If n is not
provided, the number of buckets is implementation-defined[.](#map.cnstr-3.sentence-2)

Then
inserts elements from the range [f, l), rg, or il,
respectively[.](#map.cnstr-3.sentence-3)

max_load_factor() returns 1.0[.](#map.cnstr-3.sentence-4)

[4](#map.cnstr-4)

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

*Complexity*: Average case linear, worst case quadratic[.](#map.cnstr-4.sentence-1)

#### [23.5.3.3](#map.elem) Element access [[unord.map.elem]](unord.map.elem)

[ð](#lib:unordered_map,operator%5b%5d)

`constexpr mapped_type& operator[](const key_type& k);
`

[1](#map.elem-1)

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

*Effects*: Equivalent to: return try_emplace(k).first->second;

[ð](#lib:unordered_map,operator%5b%5d_)

`constexpr mapped_type& operator[](key_type&& k);
`

[2](#map.elem-2)

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

*Effects*: Equivalent to: return try_emplace(std​::​move(k)).first->second;

[ð](#lib:unordered_map,operator%5b%5d__)

`template<class K> constexpr mapped_type& operator[](K&& k);
`

[3](#map.elem-3)

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

*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]")*s* Hash​::​is_transparent andPred​::​is_transparent are valid and denote types[.](#map.elem-3.sentence-1)

[4](#map.elem-4)

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

*Effects*: Equivalent to: return try_emplace(std​::​forward<K>(k)).first->second;

[ð](#lib:unordered_map,at)

`constexpr mapped_type& at(const key_type& k);
constexpr const mapped_type& at(const key_type& k) const;
`

[5](#map.elem-5)

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

*Returns*: A reference to x.second, where x is the (unique) element whose key is equivalent to k[.](#map.elem-5.sentence-1)

[6](#map.elem-6)

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

*Throws*: An exception object of type out_of_range if no such element is present[.](#map.elem-6.sentence-1)

[ð](#lib:unordered_map,at_)

`template<class K> constexpr mapped_type&       at(const K& k);
template<class K> constexpr const mapped_type& at(const K& k) const;
`

[7](#map.elem-7)

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

*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]")*s* Hash​::​is_transparent andPred​::​is_transparent are valid and denote types[.](#map.elem-7.sentence-1)

[8](#map.elem-8)

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

*Preconditions*: The expression find(k) is well-formed and has well-defined behavior[.](#map.elem-8.sentence-1)

[9](#map.elem-9)

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

*Returns*: A reference to find(k)->second[.](#map.elem-9.sentence-1)

[10](#map.elem-10)

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

*Throws*: An exception object of type out_of_range if find(k) == end() is true[.](#map.elem-10.sentence-1)

#### [23.5.3.4](#map.modifiers) Modifiers [[unord.map.modifiers]](unord.map.modifiers)

[ð](#lib:unordered_map,insert)

`template<class P>
  constexpr pair<iterator, bool> insert(P&& obj);
`

[1](#map.modifiers-1)

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

*Constraints*: is_constructible_v<value_type, P&&> is true[.](#map.modifiers-1.sentence-1)

[2](#map.modifiers-2)

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

*Effects*: Equivalent to: return emplace(std​::​forward<P>(obj));

[ð](#lib:unordered_map,insert_)

`template<class P>
  constexpr iterator insert(const_iterator hint, P&& obj);
`

[3](#map.modifiers-3)

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

*Constraints*: is_constructible_v<value_type, P&&> is true[.](#map.modifiers-3.sentence-1)

[4](#map.modifiers-4)

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

*Effects*: Equivalent to:return emplace_hint(hint, std​::​forward<P>(obj));

[ð](#lib:try_emplace,unordered_map)

`template<class... Args>
  constexpr pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
template<class... Args>
  constexpr iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
`

[5](#map.modifiers-5)

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

*Preconditions*: value_type is *Cpp17EmplaceConstructible* into unordered_map from piecewise_construct, forward_as_tuple(k),forward_as_tuple(std​::​forward<Args>(args)...)[.](#map.modifiers-5.sentence-1)

[6](#map.modifiers-6)

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

*Effects*: If the map already contains an element
whose key is equivalent to k,
there is no effect[.](#map.modifiers-6.sentence-1)

Otherwise inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(k),forward_as_tuple(std​::​forward<Args>(args)...)[.](#map.modifiers-6.sentence-2)

[7](#map.modifiers-7)

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

*Returns*: In the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#map.modifiers-7.sentence-1)

The returned iterator points to the map element
whose key is equivalent to k[.](#map.modifiers-7.sentence-2)

[8](#map.modifiers-8)

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

*Complexity*: The same as emplace and emplace_hint,
respectively[.](#map.modifiers-8.sentence-1)

[ð](#lib:try_emplace,unordered_map_)

`template<class... Args>
  constexpr pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
template<class... Args>
  constexpr iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
`

[9](#map.modifiers-9)

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

*Preconditions*: value_type is *Cpp17EmplaceConstructible* into unordered_map from piecewise_construct, forward_as_tuple(std​::​move(k)),forward_as_tuple(std​::​forward<Args>(args)...)[.](#map.modifiers-9.sentence-1)

[10](#map.modifiers-10)

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

*Effects*: If the map already contains an element
whose key is equivalent to k,
there is no effect[.](#map.modifiers-10.sentence-1)

Otherwise inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(std​::​move(k)),forward_as_tuple(std​::​forward<Args>(args)...)[.](#map.modifiers-10.sentence-2)

[11](#map.modifiers-11)

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

*Returns*: In the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#map.modifiers-11.sentence-1)

The returned iterator points to the map element
whose key is equivalent to k[.](#map.modifiers-11.sentence-2)

[12](#map.modifiers-12)

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

*Complexity*: The same as emplace and emplace_hint,
respectively[.](#map.modifiers-12.sentence-1)

[ð](#lib:try_emplace,unordered_map__)

`template<class K, class... Args>
  constexpr pair<iterator, bool> try_emplace(K&& k, Args&&... args);
template<class K, class... Args>
  constexpr iterator try_emplace(const_iterator hint, K&& k, Args&&... args);
`

[13](#map.modifiers-13)

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

*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]")*s* Hash​::​is_transparent andPred​::​is_transparent are valid and denote types[.](#map.modifiers-13.sentence-1)

For the first overload,is_convertible_v<K&&, const_iterator> andis_convertible_v<K&&, iterator> are both false[.](#map.modifiers-13.sentence-2)

[14](#map.modifiers-14)

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

*Preconditions*: value_type is *Cpp17EmplaceConstructible* into unordered_map frompiecewise_construct, forward_as_tuple(std​::​forward<K>(k)),
forward_as_tuple(std​::​forward<Args>  
(args)...)[.](#map.modifiers-14.sentence-1)

[15](#map.modifiers-15)

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

*Effects*: If the map already contains an element whose key is equivalent to k,
there is no effect[.](#map.modifiers-15.sentence-1)

Otherwise, let h be hash_function()(k)[.](#map.modifiers-15.sentence-2)

Constructs an object u of type value_type with piecewise_construct, forward_as_tuple(std​::​forward<K>(k)),
forward_as_tuple(std​::​forward<Args>(args)...)[.](#map.modifiers-15.sentence-3)

  
If hash_function()(u.first) != h || contains(u.first) is true,
the behavior is undefined[.](#map.modifiers-15.sentence-4)

Inserts u into *this[.](#map.modifiers-15.sentence-5)

[16](#map.modifiers-16)

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

*Returns*: For the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#map.modifiers-16.sentence-1)

The returned iterator points to the map element
whose key is equivalent to k[.](#map.modifiers-16.sentence-2)

[17](#map.modifiers-17)

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

*Complexity*: The same as emplace and emplace_hint, respectively[.](#map.modifiers-17.sentence-1)

[ð](#lib:insert_or_assign,unordered_map)

`template<class M>
  constexpr pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
template<class M>
  constexpr iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
`

[18](#map.modifiers-18)

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

*Mandates*: is_assignable_v<mapped_type&, M&&> is true[.](#map.modifiers-18.sentence-1)

[19](#map.modifiers-19)

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

*Preconditions*: value_type is *Cpp17EmplaceConstructible* into unordered_map from k, std​::​forward<M>(obj)[.](#map.modifiers-19.sentence-1)

[20](#map.modifiers-20)

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

*Effects*: If the map already contains an element e whose key is equivalent to k,
assigns std​::​forward<M>(obj) to e.second[.](#map.modifiers-20.sentence-1)

Otherwise inserts an object of type value_type constructed with k, std​::​forward<M>(obj)[.](#map.modifiers-20.sentence-2)

[21](#map.modifiers-21)

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

*Returns*: In the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#map.modifiers-21.sentence-1)

The returned iterator points to the map element
whose key is equivalent to k[.](#map.modifiers-21.sentence-2)

[22](#map.modifiers-22)

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

*Complexity*: The same as emplace and emplace_hint,
respectively[.](#map.modifiers-22.sentence-1)

[ð](#lib:insert_or_assign,unordered_map_)

`template<class M>
  constexpr pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
template<class M>
  constexpr iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
`

[23](#map.modifiers-23)

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

*Mandates*: is_assignable_v<mapped_type&, M&&> is true[.](#map.modifiers-23.sentence-1)

[24](#map.modifiers-24)

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

*Preconditions*: value_type is *Cpp17EmplaceConstructible* into unordered_map from std​::​move(k), std​::​​forward<M>(obj)[.](#map.modifiers-24.sentence-1)

[25](#map.modifiers-25)

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

*Effects*: If the map already contains an element e whose key is equivalent to k,
assigns std​::​forward<M>(obj) to e.second[.](#map.modifiers-25.sentence-1)

Otherwise inserts an object of type value_type constructed with std​::​​move(k), std​::​forward<M>(obj)[.](#map.modifiers-25.sentence-2)

[26](#map.modifiers-26)

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

*Returns*: In the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#map.modifiers-26.sentence-1)

The returned iterator points to the map element
whose key is equivalent to k[.](#map.modifiers-26.sentence-2)

[27](#map.modifiers-27)

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

*Complexity*: The same as emplace and emplace_hint,
respectively[.](#map.modifiers-27.sentence-1)

[ð](#lib:insert_or_assign,unordered_map__)

`template<class K, class M>
  constexpr pair<iterator, bool> insert_or_assign(K&& k, M&& obj);
template<class K, class M>
  constexpr iterator insert_or_assign(const_iterator hint, K&& k, M&& obj);
`

[28](#map.modifiers-28)

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

*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]")*s* Hash​::​is_transparent andPred​::​is_transparent are valid and denote types[.](#map.modifiers-28.sentence-1)

[29](#map.modifiers-29)

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

*Mandates*: is_assignable_v<mapped_type&, M&&> is true[.](#map.modifiers-29.sentence-1)

[30](#map.modifiers-30)

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

*Preconditions*: value_type is *Cpp17EmplaceConstructible* into unordered_map from std​::​forward<K>  
(k), std​::​forward<M>(obj)[.](#map.modifiers-30.sentence-1)

[31](#map.modifiers-31)

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

*Effects*: If the map already contains an element e whose key is equivalent to k,
assigns std​::​forward<M>  
(obj) to e.second[.](#map.modifiers-31.sentence-1)

Otherwise, let h be hash_function()(k)[.](#map.modifiers-31.sentence-2)

Constructs an object u of type value_type with std​::​forward<K>(k), std​::​forward<M>(obj)[.](#map.modifiers-31.sentence-3)

If hash_function()(u.first) != h || contains(u.first) is true,
the behavior is undefined[.](#map.modifiers-31.sentence-4)

Inserts u into *this[.](#map.modifiers-31.sentence-5)

[32](#map.modifiers-32)

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

*Returns*: For the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#map.modifiers-32.sentence-1)

The returned iterator points to the map element
whose key is equivalent to k[.](#map.modifiers-32.sentence-2)

[33](#map.modifiers-33)

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

*Complexity*: The same as emplace and emplace_hint, respectively[.](#map.modifiers-33.sentence-1)

#### [23.5.3.5](#map.erasure) Erasure [[unord.map.erasure]](unord.map.erasure)

[ð](#lib:erase_if,unordered_map)

`template<class K, class T, class H, class P, class A, class Predicate>
  constexpr typename unordered_map<K, T, H, P, A>::size_type
    erase_if(unordered_map<K, T, H, P, A>& c, Predicate pred);
`

[1](#map.erasure-1)

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

*Effects*: Equivalent to:auto original_size = c.size();for (auto i = c.begin(), last = c.end(); i != last; ) {if (pred(*i)) { i = c.erase(i); } else {++i; }}return original_size - c.size();

### [23.5.4](#multimap) Class template unordered_multimap [[unord.multimap]](unord.multimap)

#### [23.5.4.1](#multimap.overview) Overview [[unord.multimap.overview]](unord.multimap.overview)

[1](#multimap.overview-1)

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

An unordered_multimap is an unordered associative container
that supports equivalent keys (an instance of unordered_multimap may contain
multiple copies of each key value) and that associates values of
another type mapped_type with the keys[.](#multimap.overview-1.sentence-1)

The unordered_multimap class
supports forward iterators[.](#multimap.overview-1.sentence-2)

[2](#multimap.overview-2)

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

An unordered_multimap meets all of the requirements
of a container ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements")),
of an allocator-aware container ([[container.alloc.reqmts]](container.alloc.reqmts "23.2.2.5 Allocator-aware containers")), and
of an unordered associative container ([[unord.req]](unord.req "23.2.8 Unordered associative containers"))[.](#multimap.overview-2.sentence-1)

It provides the operations described in the
preceding requirements table for equivalent keys; that is, an unordered_multimap supports the a_eq operations in that table, not the a_uniq operations[.](#multimap.overview-2.sentence-2)

For an unordered_multimap<Key, T> the key_type is Key,
the mapped_type is T,
and the value_type is pair<const Key, T>[.](#multimap.overview-2.sentence-3)

[3](#multimap.overview-3)

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

Subclause [[unord.multimap]](#multimap "23.5.4 Class template unordered_­multimap") only describes operations on unordered_multimap that are not described in one of the requirement tables, or for which
there is additional semantic information[.](#multimap.overview-3.sentence-1)

[4](#multimap.overview-4)

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

The types iterator and const_iterator meet
the constexpr iterator requirements ([[iterator.requirements.general]](iterator.requirements.general "24.3.1 General"))[.](#multimap.overview-4.sentence-1)

[ð](#lib:unordered_multimap__)

namespace std {template<class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>>class unordered_multimap {public:// typesusing key_type = Key; using mapped_type = T; using value_type = pair<const Key, T>; using hasher = Hash; using key_equal = Pred; using allocator_type = Allocator; using pointer = typename allocator_traits<Allocator>::pointer; using const_pointer = typename allocator_traits<Allocator>::const_pointer; using reference = value_type&; using const_reference = const value_type&; using size_type = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using difference_type = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using const_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using local_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using const_local_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using node_type = *unspecified*; // [[unord.multimap.cnstr]](#multimap.cnstr "23.5.4.2 Constructors"), construct/copy/destroyconstexpr unordered_multimap(); constexpr explicit unordered_multimap(size_type n, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); template<class InputIterator>constexpr unordered_multimap(InputIterator f, InputIterator l,
 size_type n = *see below*, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr unordered_multimap(from_range_t, R&& rg,
 size_type n = *see below*, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); constexpr unordered_multimap(const unordered_multimap&); constexpr unordered_multimap(unordered_multimap&&); constexpr explicit unordered_multimap(const Allocator&); constexpr unordered_multimap(const unordered_multimap&, const type_identity_t<Allocator>&); constexpr unordered_multimap(unordered_multimap&&, const type_identity_t<Allocator>&); constexpr unordered_multimap(initializer_list<value_type> il,
 size_type n = *see below*, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); constexpr unordered_multimap(size_type n, const allocator_type& a): unordered_multimap(n, hasher(), key_equal(), a) { }constexpr unordered_multimap(size_type n, const hasher& hf, const allocator_type& a): unordered_multimap(n, hf, key_equal(), a) { }template<class InputIterator>constexpr unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a): unordered_multimap(f, l, n, hasher(), key_equal(), a) { }template<class InputIterator>constexpr unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf, const allocator_type& a): unordered_multimap(f, l, n, hf, key_equal(), a) { }template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr unordered_multimap(from_range_t, R&& rg, size_type n, const allocator_type& a): unordered_multimap(from_range, std::forward<R>(rg),
 n, hasher(), key_equal(), a) { }template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr unordered_multimap(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a): unordered_multimap(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { }constexpr unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a): unordered_multimap(il, n, hasher(), key_equal(), a) { }constexpr unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf, const allocator_type& a): unordered_multimap(il, n, hf, key_equal(), a) { }constexpr ~unordered_multimap(); constexpr unordered_multimap& operator=(const unordered_multimap&); constexpr unordered_multimap& operator=(unordered_multimap&&)noexcept(allocator_traits<Allocator>::is_always_equal::value && is_nothrow_move_assignable_v<Hash> && is_nothrow_move_assignable_v<Pred>); constexpr unordered_multimap& operator=(initializer_list<value_type>); constexpr allocator_type get_allocator() const noexcept; // iteratorsconstexpr iterator begin() noexcept; constexpr const_iterator begin() const noexcept; constexpr iterator end() noexcept; constexpr const_iterator end() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr const_iterator cend() const noexcept; // capacityconstexpr bool empty() const noexcept; constexpr size_type size() const noexcept; constexpr size_type max_size() const noexcept; // [[unord.multimap.modifiers]](#multimap.modifiers "23.5.4.3 Modifiers"), modifierstemplate<class... Args> constexpr iterator emplace(Args&&... args); template<class... Args>constexpr iterator emplace_hint(const_iterator position, Args&&... args); constexpr iterator insert(const value_type& obj); constexpr iterator insert(value_type&& obj); template<class P> constexpr iterator insert(P&& obj); constexpr iterator insert(const_iterator hint, const value_type& obj); constexpr iterator insert(const_iterator hint, value_type&& obj); template<class P> constexpr iterator insert(const_iterator hint, P&& obj); template<class InputIterator> constexpr void insert(InputIterator first, InputIterator last); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr void insert_range(R&& rg); constexpr void insert(initializer_list<value_type>); constexpr node_type extract(const_iterator position); constexpr node_type extract(const key_type& x); template<class K> constexpr node_type extract(K&& x); constexpr iterator insert(node_type&& nh); constexpr iterator insert(const_iterator hint, node_type&& nh); constexpr iterator erase(iterator position); constexpr iterator erase(const_iterator position); constexpr size_type erase(const key_type& k); template<class K> constexpr size_type erase(K&& x); constexpr iterator erase(const_iterator first, const_iterator last); constexpr void swap(unordered_multimap&)noexcept(allocator_traits<Allocator>::is_always_equal::value && is_nothrow_swappable_v<Hash> && is_nothrow_swappable_v<Pred>); constexpr void clear() noexcept; template<class H2, class P2>constexpr void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source); template<class H2, class P2>constexpr void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source); template<class H2, class P2>constexpr void merge(unordered_map<Key, T, H2, P2, Allocator>& source); template<class H2, class P2>constexpr void merge(unordered_map<Key, T, H2, P2, Allocator>&& source); // observersconstexpr hasher hash_function() const; constexpr key_equal key_eq() const; // map operationsconstexpr iterator find(const key_type& k); constexpr const_iterator find(const key_type& k) const; template<class K>constexpr iterator find(const K& k); template<class K>constexpr const_iterator find(const K& k) const; constexpr size_type count(const key_type& k) const; template<class K>constexpr size_type count(const K& k) const; constexpr bool contains(const key_type& k) const; template<class K>constexpr bool contains(const K& k) const; constexpr pair<iterator, iterator> equal_range(const key_type& k); constexpr pair<const_iterator, const_iterator> equal_range(const key_type& k) const; template<class K>constexpr pair<iterator, iterator> equal_range(const K& k); template<class K>constexpr pair<const_iterator, const_iterator> equal_range(const K& k) const; // bucket interfaceconstexpr size_type bucket_count() const noexcept; constexpr size_type max_bucket_count() const noexcept; constexpr size_type bucket_size(size_type n) const; constexpr size_type bucket(const key_type& k) const; template<class K> constexpr size_type bucket(const K& k) const; constexpr local_iterator begin(size_type n); constexpr const_local_iterator begin(size_type n) const; constexpr local_iterator end(size_type n); constexpr const_local_iterator end(size_type n) const; constexpr const_local_iterator cbegin(size_type n) const; constexpr const_local_iterator cend(size_type n) const; // hash policyconstexpr float load_factor() const noexcept; constexpr float max_load_factor() const noexcept; constexpr void max_load_factor(float z); constexpr void rehash(size_type n); constexpr void reserve(size_type n); }; template<class InputIterator, class Hash = hash<*iter-key-type*<InputIterator>>, class Pred = equal_to<*iter-key-type*<InputIterator>>, class Allocator = allocator<*iter-to-alloc-type*<InputIterator>>> unordered_multimap(InputIterator, InputIterator, typename *see below*::size_type = *see below*,
 Hash = Hash(), Pred = Pred(), Allocator = Allocator())-> unordered_multimap<*iter-key-type*<InputIterator>, *iter-mapped-type*<InputIterator>,
 Hash, Pred, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Hash = hash<*range-key-type*<R>>, class Pred = equal_to<*range-key-type*<R>>, class Allocator = allocator<*range-to-alloc-type*<R>>> unordered_multimap(from_range_t, R&&, typename *see below*::size_type = *see below*,
 Hash = Hash(), Pred = Pred(), Allocator = Allocator())-> unordered_multimap<*range-key-type*<R>, *range-mapped-type*<R>, Hash, Pred, Allocator>; template<class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>> unordered_multimap(initializer_list<pair<Key, T>>, typename *see below*::size_type = *see below*,
 Hash = Hash(), Pred = Pred(), Allocator = Allocator())-> unordered_multimap<Key, T, Hash, Pred, Allocator>; template<class InputIterator, class Allocator> unordered_multimap(InputIterator, InputIterator, typename *see below*::size_type, Allocator)-> unordered_multimap<*iter-key-type*<InputIterator>, *iter-mapped-type*<InputIterator>,
 hash<*iter-key-type*<InputIterator>>,
 equal_to<*iter-key-type*<InputIterator>>, Allocator>; template<class InputIterator, class Allocator> unordered_multimap(InputIterator, InputIterator, Allocator)-> unordered_multimap<*iter-key-type*<InputIterator>, *iter-mapped-type*<InputIterator>,
 hash<*iter-key-type*<InputIterator>>,
 equal_to<*iter-key-type*<InputIterator>>, Allocator>; template<class InputIterator, class Hash, class Allocator> unordered_multimap(InputIterator, InputIterator, typename *see below*::size_type, Hash,
 Allocator)-> unordered_multimap<*iter-key-type*<InputIterator>, *iter-mapped-type*<InputIterator>, Hash,
 equal_to<*iter-key-type*<InputIterator>>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Allocator> unordered_multimap(from_range_t, R&&, typename *see below*::size_type, Allocator)-> unordered_multimap<*range-key-type*<R>, *range-mapped-type*<R>, hash<*range-key-type*<R>>,
 equal_to<*range-key-type*<R>>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Allocator> unordered_multimap(from_range_t, R&&, Allocator)-> unordered_multimap<*range-key-type*<R>, *range-mapped-type*<R>, hash<*range-key-type*<R>>,
 equal_to<*range-key-type*<R>>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Hash, class Allocator> unordered_multimap(from_range_t, R&&, typename *see below*::size_type, Hash, Allocator)-> unordered_multimap<*range-key-type*<R>, *range-mapped-type*<R>, Hash,
 equal_to<*range-key-type*<R>>, Allocator>; template<class Key, class T, class Allocator> unordered_multimap(initializer_list<pair<Key, T>>, typename *see below*::size_type,
 Allocator)-> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; template<class Key, class T, class Allocator> unordered_multimap(initializer_list<pair<Key, T>>, Allocator)-> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; template<class Key, class T, class Hash, class Allocator> unordered_multimap(initializer_list<pair<Key, T>>, typename *see below*::size_type,
 Hash, Allocator)-> unordered_multimap<Key, T, Hash, equal_to<Key>, Allocator>;}

[5](#multimap.overview-5)

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

A size_type parameter type in an unordered_multimap deduction guide
refers to the size_type member type of the type deduced by the deduction guide[.](#multimap.overview-5.sentence-1)

#### [23.5.4.2](#multimap.cnstr) Constructors [[unord.multimap.cnstr]](unord.multimap.cnstr)

[ð](#lib:unordered_multimap,constructor)

`constexpr unordered_multimap() : unordered_multimap(size_type(see below)) { }
constexpr explicit unordered_multimap(size_type n, const hasher& hf = hasher(),
                                      const key_equal& eql = key_equal(),
                                      const allocator_type& a = allocator_type());
`

[1](#multimap.cnstr-1)

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

*Effects*: Constructs an empty unordered_multimap using the
specified hash function, key equality predicate, and allocator, and
using at least n buckets[.](#multimap.cnstr-1.sentence-1)

For the default constructor,
the number of buckets is implementation-defined[.](#multimap.cnstr-1.sentence-2)

max_load_factor() returns 1.0[.](#multimap.cnstr-1.sentence-3)

[2](#multimap.cnstr-2)

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

*Complexity*: Constant[.](#multimap.cnstr-2.sentence-1)

[ð](#lib:unordered_multimap,constructor_)

`template<class InputIterator>
  constexpr unordered_multimap(InputIterator f, InputIterator l,
                               size_type n = see below, const hasher& hf = hasher(),
                               const key_equal& eql = key_equal(),
                               const allocator_type& a = allocator_type());
template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>
  constexpr unordered_multimap(from_range_t, R&& rg,
                               size_type n = see below, const hasher& hf = hasher(),
                               const key_equal& eql = key_equal(),
                               const allocator_type& a = allocator_type());
constexpr unordered_multimap(initializer_list<value_type> il,
                             size_type n = see below, const hasher& hf = hasher(),
                             const key_equal& eql = key_equal(),
                             const allocator_type& a = allocator_type());
`

[3](#multimap.cnstr-3)

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

*Effects*: Constructs an empty unordered_multimap using the
specified hash function, key equality predicate, and allocator, and
using at least n buckets[.](#multimap.cnstr-3.sentence-1)

If n is not
provided, the number of buckets is implementation-defined[.](#multimap.cnstr-3.sentence-2)

Then
inserts elements from the range [f, l), rg, or il,
respectively[.](#multimap.cnstr-3.sentence-3)

max_load_factor() returns 1.0[.](#multimap.cnstr-3.sentence-4)

[4](#multimap.cnstr-4)

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

*Complexity*: Average case linear, worst case quadratic[.](#multimap.cnstr-4.sentence-1)

#### [23.5.4.3](#multimap.modifiers) Modifiers [[unord.multimap.modifiers]](unord.multimap.modifiers)

[ð](#lib:unordered_multimap,insert)

`template<class P>
  constexpr iterator insert(P&& obj);
`

[1](#multimap.modifiers-1)

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

*Constraints*: is_constructible_v<value_type, P&&> is true[.](#multimap.modifiers-1.sentence-1)

[2](#multimap.modifiers-2)

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

*Effects*: Equivalent to: return emplace(std​::​forward<P>(obj));

[ð](#lib:unordered_multimap,insert_)

`template<class P>
  constexpr iterator insert(const_iterator hint, P&& obj);
`

[3](#multimap.modifiers-3)

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

*Constraints*: is_constructible_v<value_type, P&&> is true[.](#multimap.modifiers-3.sentence-1)

[4](#multimap.modifiers-4)

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

*Effects*: Equivalent to:return emplace_hint(hint, std​::​forward<P>(obj));

#### [23.5.4.4](#multimap.erasure) Erasure [[unord.multimap.erasure]](unord.multimap.erasure)

[ð](#lib:erase_if,unordered_multimap)

`template<class K, class T, class H, class P, class A, class Predicate>
  constexpr typename unordered_multimap<K, T, H, P, A>::size_type
    erase_if(unordered_multimap<K, T, H, P, A>& c, Predicate pred);
`

[1](#multimap.erasure-1)

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

*Effects*: Equivalent to:auto original_size = c.size();for (auto i = c.begin(), last = c.end(); i != last; ) {if (pred(*i)) { i = c.erase(i); } else {++i; }}return original_size - c.size();

### [23.5.5](#set.syn) Header <unordered_set> synopsis [[unord.set.syn]](unord.set.syn)

[ð](#header:%3cunordered_set%3e)

#include <compare> // see [[compare.syn]](compare.syn "17.12.1 Header <compare> synopsis")#include <initializer_list> // see [[initializer.list.syn]](initializer.list.syn "17.11.2 Header <initializer_­list> synopsis")namespace std {// [[unord.set]](#set "23.5.6 Class template unordered_­set"), class template unordered_settemplate<class Key, class Hash = hash<Key>, class Pred = equal_to<Key>, class Alloc = allocator<Key>>class unordered_set; // [[unord.multiset]](#multiset "23.5.7 Class template unordered_­multiset"), class template unordered_multisettemplate<class Key, class Hash = hash<Key>, class Pred = equal_to<Key>, class Alloc = allocator<Key>>class unordered_multiset; template<class Key, class Hash, class Pred, class Alloc>constexpr bool operator==(const unordered_set<Key, Hash, Pred, Alloc>& a, const unordered_set<Key, Hash, Pred, Alloc>& b); template<class Key, class Hash, class Pred, class Alloc>constexpr bool operator==(const unordered_multiset<Key, Hash, Pred, Alloc>& a, const unordered_multiset<Key, Hash, Pred, Alloc>& b); template<class Key, class Hash, class Pred, class Alloc>constexpr void swap(unordered_set<Key, Hash, Pred, Alloc>& x,
 unordered_set<Key, Hash, Pred, Alloc>& y)noexcept(noexcept(x.swap(y))); template<class Key, class Hash, class Pred, class Alloc>constexpr void swap(unordered_multiset<Key, Hash, Pred, Alloc>& x,
 unordered_multiset<Key, Hash, Pred, Alloc>& y)noexcept(noexcept(x.swap(y))); // [[unord.set.erasure]](#set.erasure "23.5.6.3 Erasure"), erasure for unordered_settemplate<class K, class H, class P, class A, class Predicate>constexpr typename unordered_set<K, H, P, A>::size_type
 erase_if(unordered_set<K, H, P, A>& c, Predicate pred); // [[unord.multiset.erasure]](#multiset.erasure "23.5.7.3 Erasure"), erasure for unordered_multisettemplate<class K, class H, class P, class A, class Predicate>constexpr typename unordered_multiset<K, H, P, A>::size_type
 erase_if(unordered_multiset<K, H, P, A>& c, Predicate pred); namespace pmr {template<class Key, class Hash = hash<Key>, class Pred = equal_to<Key>>using unordered_set = std::unordered_set<Key, Hash, Pred,
 polymorphic_allocator<Key>>; template<class Key, class Hash = hash<Key>, class Pred = equal_to<Key>>using unordered_multiset = std::unordered_multiset<Key, Hash, Pred,
 polymorphic_allocator<Key>>; }}

### [23.5.6](#set) Class template unordered_set [[unord.set]](unord.set)

#### [23.5.6.1](#set.overview) Overview [[unord.set.overview]](unord.set.overview)

[1](#set.overview-1)

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

An unordered_set is an unordered associative container that
supports unique keys (an unordered_set contains at most one of each
key value) and in which the elements' keys are the elements
themselves[.](#set.overview-1.sentence-1)

The unordered_set class
supports forward iterators[.](#set.overview-1.sentence-2)

[2](#set.overview-2)

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

An unordered_set meets all of the requirements
of a container ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements")),
of an allocator-aware container ([[container.alloc.reqmts]](container.alloc.reqmts "23.2.2.5 Allocator-aware containers")), and
of an unordered associative container ([[unord.req]](unord.req "23.2.8 Unordered associative containers"))[.](#set.overview-2.sentence-1)

It provides the operations described in the preceding requirements table for unique keys;
that is, an unordered_set supports the a_uniq operations in that table,
not the a_eq operations[.](#set.overview-2.sentence-2)

For an unordered_set<Key> the key_type and the value_type are both Key[.](#set.overview-2.sentence-3)

The iterator and const_iterator types are both constant iterator types[.](#set.overview-2.sentence-4)

It is unspecified whether they are the same type[.](#set.overview-2.sentence-5)

[3](#set.overview-3)

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

Subclause [[unord.set]](#set "23.5.6 Class template unordered_­set") only describes operations on unordered_set that
are not described in one of the requirement tables, or for which there
is additional semantic information[.](#set.overview-3.sentence-1)

[4](#set.overview-4)

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

The types iterator and const_iterator meet
the constexpr iterator requirements ([[iterator.requirements.general]](iterator.requirements.general "24.3.1 General"))[.](#set.overview-4.sentence-1)

[ð](#lib:unordered_set__)

namespace std {template<class Key, class Hash = hash<Key>, class Pred = equal_to<Key>, class Allocator = allocator<Key>>class unordered_set {public:// typesusing key_type = Key; using value_type = Key; using hasher = Hash; using key_equal = Pred; using allocator_type = Allocator; using pointer = typename allocator_traits<Allocator>::pointer; using const_pointer = typename allocator_traits<Allocator>::const_pointer; using reference = value_type&; using const_reference = const value_type&; using size_type = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using difference_type = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using const_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using local_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using const_local_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using node_type = *unspecified*; using insert_return_type = *insert-return-type*<iterator, node_type>; // [[unord.set.cnstr]](#set.cnstr "23.5.6.2 Constructors"), construct/copy/destroyconstexpr unordered_set(); constexpr explicit unordered_set(size_type n, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); template<class InputIterator>constexpr unordered_set(InputIterator f, InputIterator l,
 size_type n = *see below*, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr unordered_set(from_range_t, R&& rg,
 size_type n = *see below*, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); constexpr unordered_set(const unordered_set&); constexpr unordered_set(unordered_set&&); constexpr explicit unordered_set(const Allocator&); constexpr unordered_set(const unordered_set&, const type_identity_t<Allocator>&); constexpr unordered_set(unordered_set&&, const type_identity_t<Allocator>&); constexpr unordered_set(initializer_list<value_type> il,
 size_type n = *see below*, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); constexpr unordered_set(size_type n, const allocator_type& a): unordered_set(n, hasher(), key_equal(), a) { }constexpr unordered_set(size_type n, const hasher& hf, const allocator_type& a): unordered_set(n, hf, key_equal(), a) { }template<class InputIterator>constexpr unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a): unordered_set(f, l, n, hasher(), key_equal(), a) { }template<class InputIterator>constexpr unordered_set(InputIterator f, InputIterator l, size_type n, const hasher& hf, const allocator_type& a): unordered_set(f, l, n, hf, key_equal(), a) { }constexpr unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a): unordered_set(il, n, hasher(), key_equal(), a) { }template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr unordered_set(from_range_t, R&& rg, size_type n, const allocator_type& a): unordered_set(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { }template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr unordered_set(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a): unordered_set(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { }constexpr unordered_set(initializer_list<value_type> il, size_type n, const hasher& hf, const allocator_type& a): unordered_set(il, n, hf, key_equal(), a) { }constexpr ~unordered_set(); constexpr unordered_set& operator=(const unordered_set&); constexpr unordered_set& operator=(unordered_set&&)noexcept(allocator_traits<Allocator>::is_always_equal::value && is_nothrow_move_assignable_v<Hash> && is_nothrow_move_assignable_v<Pred>); constexpr unordered_set& operator=(initializer_list<value_type>); constexpr allocator_type get_allocator() const noexcept; // iteratorsconstexpr iterator begin() noexcept; constexpr const_iterator begin() const noexcept; constexpr iterator end() noexcept; constexpr const_iterator end() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr const_iterator cend() const noexcept; // capacityconstexpr bool empty() const noexcept; constexpr size_type size() const noexcept; constexpr size_type max_size() const noexcept; // [[unord.set.modifiers]](#set.modifiers "23.5.6.4 Modifiers"), modifierstemplate<class... Args> constexpr pair<iterator, bool> emplace(Args&&... args); template<class... Args>constexpr iterator emplace_hint(const_iterator position, Args&&... args); constexpr pair<iterator, bool> insert(const value_type& obj); constexpr pair<iterator, bool> insert(value_type&& obj); template<class K> constexpr pair<iterator, bool> insert(K&& obj); constexpr iterator insert(const_iterator hint, const value_type& obj); constexpr iterator insert(const_iterator hint, value_type&& obj); template<class K> constexpr iterator insert(const_iterator hint, K&& obj); template<class InputIterator> constexpr void insert(InputIterator first, InputIterator last); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr void insert_range(R&& rg); constexpr void insert(initializer_list<value_type>); constexpr node_type extract(const_iterator position); constexpr node_type extract(const key_type& x); template<class K> constexpr node_type extract(K&& x); constexpr insert_return_type insert(node_type&& nh); constexpr iterator insert(const_iterator hint, node_type&& nh); constexpr iterator erase(iterator position)requires (![same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<iterator, const_iterator>); constexpr iterator erase(const_iterator position); constexpr size_type erase(const key_type& k); template<class K> constexpr size_type erase(K&& x); constexpr iterator erase(const_iterator first, const_iterator last); constexpr void swap(unordered_set&)noexcept(allocator_traits<Allocator>::is_always_equal::value && is_nothrow_swappable_v<Hash> && is_nothrow_swappable_v<Pred>); constexpr void clear() noexcept; template<class H2, class P2>constexpr void merge(unordered_set<Key, H2, P2, Allocator>& source); template<class H2, class P2>constexpr void merge(unordered_set<Key, H2, P2, Allocator>&& source); template<class H2, class P2>constexpr void merge(unordered_multiset<Key, H2, P2, Allocator>& source); template<class H2, class P2>constexpr void merge(unordered_multiset<Key, H2, P2, Allocator>&& source); // observersconstexpr hasher hash_function() const; constexpr key_equal key_eq() const; // set operationsconstexpr iterator find(const key_type& k); constexpr const_iterator find(const key_type& k) const; template<class K>constexpr iterator find(const K& k); template<class K>constexpr const_iterator find(const K& k) const; constexpr size_type count(const key_type& k) const; template<class K>constexpr size_type count(const K& k) const; constexpr bool contains(const key_type& k) const; template<class K>constexpr bool contains(const K& k) const; constexpr pair<iterator, iterator> equal_range(const key_type& k); constexpr pair<const_iterator, const_iterator> equal_range(const key_type& k) const; template<class K>constexpr pair<iterator, iterator> equal_range(const K& k); template<class K>constexpr pair<const_iterator, const_iterator> equal_range(const K& k) const; // bucket interfaceconstexpr size_type bucket_count() const noexcept; constexpr size_type max_bucket_count() const noexcept; constexpr size_type bucket_size(size_type n) const; constexpr size_type bucket(const key_type& k) const; template<class K> constexpr size_type bucket(const K& k) const; constexpr local_iterator begin(size_type n); constexpr const_local_iterator begin(size_type n) const; constexpr local_iterator end(size_type n); constexpr const_local_iterator end(size_type n) const; constexpr const_local_iterator cbegin(size_type n) const; constexpr const_local_iterator cend(size_type n) const; // hash policyconstexpr float load_factor() const noexcept; constexpr float max_load_factor() const noexcept; constexpr void max_load_factor(float z); constexpr void rehash(size_type n); constexpr void reserve(size_type n); }; template<class InputIterator, class Hash = hash<*iter-value-type*<InputIterator>>, class Pred = equal_to<*iter-value-type*<InputIterator>>, class Allocator = allocator<*iter-value-type*<InputIterator>>> unordered_set(InputIterator, InputIterator, typename *see below*::size_type = *see below*,
 Hash = Hash(), Pred = Pred(), Allocator = Allocator())-> unordered_set<*iter-value-type*<InputIterator>,
 Hash, Pred, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Hash = hash<ranges::range_value_t<R>>, class Pred = equal_to<ranges::range_value_t<R>>, class Allocator = allocator<ranges::range_value_t<R>>> unordered_set(from_range_t, R&&, typename *see below*::size_type = *see below*,
 Hash = Hash(), Pred = Pred(), Allocator = Allocator())-> unordered_set<ranges::range_value_t<R>, Hash, Pred, Allocator>; template<class T, class Hash = hash<T>, class Pred = equal_to<T>, class Allocator = allocator<T>> unordered_set(initializer_list<T>, typename *see below*::size_type = *see below*,
 Hash = Hash(), Pred = Pred(), Allocator = Allocator())-> unordered_set<T, Hash, Pred, Allocator>; template<class InputIterator, class Allocator> unordered_set(InputIterator, InputIterator, typename *see below*::size_type, Allocator)-> unordered_set<*iter-value-type*<InputIterator>,
 hash<*iter-value-type*<InputIterator>>,
 equal_to<*iter-value-type*<InputIterator>>,
 Allocator>; template<class InputIterator, class Hash, class Allocator> unordered_set(InputIterator, InputIterator, typename *see below*::size_type,
 Hash, Allocator)-> unordered_set<*iter-value-type*<InputIterator>, Hash,
 equal_to<*iter-value-type*<InputIterator>>,
 Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Allocator> unordered_set(from_range_t, R&&, typename *see below*::size_type, Allocator)-> unordered_set<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
 equal_to<ranges::range_value_t<R>>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Allocator> unordered_set(from_range_t, R&&, Allocator)-> unordered_set<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
 equal_to<ranges::range_value_t<R>>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Hash, class Allocator> unordered_set(from_range_t, R&&, typename *see below*::size_type, Hash, Allocator)-> unordered_set<ranges::range_value_t<R>, Hash,
 equal_to<ranges::range_value_t<R>>, Allocator>; template<class T, class Allocator> unordered_set(initializer_list<T>, typename *see below*::size_type, Allocator)-> unordered_set<T, hash<T>, equal_to<T>, Allocator>; template<class T, class Hash, class Allocator> unordered_set(initializer_list<T>, typename *see below*::size_type, Hash, Allocator)-> unordered_set<T, Hash, equal_to<T>, Allocator>;}

[5](#set.overview-5)

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

A size_type parameter type in an unordered_set deduction guide
refers to the size_type member type of
the type deduced by the deduction guide[.](#set.overview-5.sentence-1)

#### [23.5.6.2](#set.cnstr) Constructors [[unord.set.cnstr]](unord.set.cnstr)

[ð](#lib:unordered_set,constructor)

`constexpr unordered_set() : unordered_set(size_type(see below)) { }
constexpr explicit unordered_set(size_type n, const hasher& hf = hasher(),
                                 const key_equal& eql = key_equal(),
                                 const allocator_type& a = allocator_type());
`

[1](#set.cnstr-1)

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

*Effects*: Constructs an empty unordered_set using the
specified hash function, key equality predicate, and allocator, and
using at least n buckets[.](#set.cnstr-1.sentence-1)

For the default constructor,
the number of buckets is implementation-defined[.](#set.cnstr-1.sentence-2)

max_load_factor() returns 1.0[.](#set.cnstr-1.sentence-3)

[2](#set.cnstr-2)

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

*Complexity*: Constant[.](#set.cnstr-2.sentence-1)

[ð](#lib:unordered_set,constructor_)

`template<class InputIterator>
  constexpr unordered_set(InputIterator f, InputIterator l,
                          size_type n = see below, const hasher& hf = hasher(),
                          const key_equal& eql = key_equal(),
                          const allocator_type& a = allocator_type());
template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>
  constexpr unordered_multiset(from_range_t, R&& rg,
                               size_type n = see below, const hasher& hf = hasher(),
                               const key_equal& eql = key_equal(),
                               const allocator_type& a = allocator_type());
constexpr unordered_set(initializer_list<value_type> il,
                        size_type n = see below, const hasher& hf = hasher(),
                        const key_equal& eql = key_equal(),
                        const allocator_type& a = allocator_type());
`

[3](#set.cnstr-3)

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

*Effects*: Constructs an empty unordered_set using the
specified hash function, key equality predicate, and allocator, and
using at least n buckets[.](#set.cnstr-3.sentence-1)

If n is not
provided, the number of buckets is implementation-defined[.](#set.cnstr-3.sentence-2)

Then
inserts elements from the range [f, l), rg, or il,
respectively[.](#set.cnstr-3.sentence-3)

max_load_factor() returns 1.0[.](#set.cnstr-3.sentence-4)

[4](#set.cnstr-4)

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

*Complexity*: Average case linear, worst case quadratic[.](#set.cnstr-4.sentence-1)

#### [23.5.6.3](#set.erasure) Erasure [[unord.set.erasure]](unord.set.erasure)

[ð](#lib:erase_if,unordered_set)

`template<class K, class H, class P, class A, class Predicate>
  constexpr typename unordered_set<K, H, P, A>::size_type
    erase_if(unordered_set<K, H, P, A>& c, Predicate pred);
`

[1](#set.erasure-1)

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

*Effects*: Equivalent to:auto original_size = c.size();for (auto i = c.begin(), last = c.end(); i != last; ) {if (pred(*i)) { i = c.erase(i); } else {++i; }}return original_size - c.size();

#### [23.5.6.4](#set.modifiers) Modifiers [[unord.set.modifiers]](unord.set.modifiers)

[ð](#lib:insert,unordered_set)

`template<class K> constexpr pair<iterator, bool> insert(K&& obj);
template<class K> constexpr iterator insert(const_iterator hint, K&& obj);
`

[1](#set.modifiers-1)

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

*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]")*s* Hash​::​is_transparent andPred​::​is_transparent are valid and denote types[.](#set.modifiers-1.sentence-1)

For the second overload,is_convertible_v<K&&, const_iterator> andis_convertible_v<K&&, iterator> are both false[.](#set.modifiers-1.sentence-2)

[2](#set.modifiers-2)

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

*Preconditions*: value_type is *Cpp17EmplaceConstructible* into unordered_set from std​::​forward<K>  
(obj)[.](#set.modifiers-2.sentence-1)

[3](#set.modifiers-3)

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

*Effects*: If the set already contains an element that is equivalent to obj,
there is no effect[.](#set.modifiers-3.sentence-1)

Otherwise, let h be hash_function()(obj)[.](#set.modifiers-3.sentence-2)

Constructs an object u of type value_type with std​::​forward<K>(obj)[.](#set.modifiers-3.sentence-3)

If hash_function()(u) != h || contains(u) is true,
the behavior is undefined[.](#set.modifiers-3.sentence-4)

Inserts u into *this[.](#set.modifiers-3.sentence-5)

[4](#set.modifiers-4)

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

*Returns*: For the first overload,
the bool component of the returned pair is true if and only if the insertion took place[.](#set.modifiers-4.sentence-1)

The returned iterator points to the set element
that is equivalent to obj[.](#set.modifiers-4.sentence-2)

[5](#set.modifiers-5)

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

*Complexity*: Average case constant, worst case linear[.](#set.modifiers-5.sentence-1)

### [23.5.7](#multiset) Class template unordered_multiset [[unord.multiset]](unord.multiset)

#### [23.5.7.1](#multiset.overview) Overview [[unord.multiset.overview]](unord.multiset.overview)

[1](#multiset.overview-1)

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

An unordered_multiset is an unordered associative container
that supports equivalent keys (an instance of unordered_multiset may contain
multiple copies of the same key value) and in which each element's key
is the element itself[.](#multiset.overview-1.sentence-1)

The unordered_multiset class
supports forward iterators[.](#multiset.overview-1.sentence-2)

[2](#multiset.overview-2)

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

An unordered_multiset meets all of the requirements
of a container ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements")),
of an allocator-aware container ([[container.alloc.reqmts]](container.alloc.reqmts "23.2.2.5 Allocator-aware containers")), and
of an unordered associative container ([[unord.req]](unord.req "23.2.8 Unordered associative containers"))[.](#multiset.overview-2.sentence-1)

It provides the operations described in the
preceding requirements table for equivalent keys; that is, an unordered_multiset supports the a_eq operations in that table, not the a_uniq operations[.](#multiset.overview-2.sentence-2)

For an unordered_multiset<Key> the key_type and the value_type are
both Key[.](#multiset.overview-2.sentence-3)

The iterator and const_iterator types are both
constant iterator types[.](#multiset.overview-2.sentence-4)

It is unspecified whether they are the same type[.](#multiset.overview-2.sentence-5)

[3](#multiset.overview-3)

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

Subclause [[unord.multiset]](#multiset "23.5.7 Class template unordered_­multiset") only describes operations on unordered_multiset that
are not described in one of the requirement tables, or for which there
is additional semantic information[.](#multiset.overview-3.sentence-1)

[4](#multiset.overview-4)

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

The types iterator and const_iterator meet
the constexpr iterator requirements ([[iterator.requirements.general]](iterator.requirements.general "24.3.1 General"))[.](#multiset.overview-4.sentence-1)

[ð](#lib:unordered_multiset__)

namespace std {template<class Key, class Hash = hash<Key>, class Pred = equal_to<Key>, class Allocator = allocator<Key>>class unordered_multiset {public:// typesusing key_type = Key; using value_type = Key; using hasher = Hash; using key_equal = Pred; using allocator_type = Allocator; using pointer = typename allocator_traits<Allocator>::pointer; using const_pointer = typename allocator_traits<Allocator>::const_pointer; using reference = value_type&; using const_reference = const value_type&; using size_type = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using difference_type = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using const_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using local_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using const_local_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using node_type = *unspecified*; // [[unord.multiset.cnstr]](#multiset.cnstr "23.5.7.2 Constructors"), construct/copy/destroyconstexpr unordered_multiset(); constexpr explicit unordered_multiset(size_type n, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); template<class InputIterator>constexpr unordered_multiset(InputIterator f, InputIterator l,
 size_type n = *see below*, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr unordered_multiset(from_range_t, R&& rg,
 size_type n = *see below*, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); constexpr unordered_multiset(const unordered_multiset&); constexpr unordered_multiset(unordered_multiset&&); constexpr explicit unordered_multiset(const Allocator&); constexpr unordered_multiset(const unordered_multiset&, const type_identity_t<Allocator>&); constexpr unordered_multiset(unordered_multiset&&, const type_identity_t<Allocator>&); constexpr unordered_multiset(initializer_list<value_type> il,
 size_type n = *see below*, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); constexpr unordered_multiset(size_type n, const allocator_type& a): unordered_multiset(n, hasher(), key_equal(), a) { }constexpr unordered_multiset(size_type n, const hasher& hf, const allocator_type& a): unordered_multiset(n, hf, key_equal(), a) { }template<class InputIterator>constexpr unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a): unordered_multiset(f, l, n, hasher(), key_equal(), a) { }template<class InputIterator>constexpr unordered_multiset(InputIterator f, InputIterator l, size_type n, const hasher& hf, const allocator_type& a): unordered_multiset(f, l, n, hf, key_equal(), a) { }template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr unordered_multiset(from_range_t, R&& rg, size_type n, const allocator_type& a): unordered_multiset(from_range, std::forward<R>(rg),
 n, hasher(), key_equal(), a) { }template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr unordered_multiset(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a): unordered_multiset(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { }constexpr unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a): unordered_multiset(il, n, hasher(), key_equal(), a) { }constexpr unordered_multiset(initializer_list<value_type> il, size_type n, const hasher& hf, const allocator_type& a): unordered_multiset(il, n, hf, key_equal(), a) { }constexpr ~unordered_multiset(); constexpr unordered_multiset& operator=(const unordered_multiset&); constexpr unordered_multiset& operator=(unordered_multiset&&)noexcept(allocator_traits<Allocator>::is_always_equal::value && is_nothrow_move_assignable_v<Hash> && is_nothrow_move_assignable_v<Pred>); constexpr unordered_multiset& operator=(initializer_list<value_type>); constexpr allocator_type get_allocator() const noexcept; // iteratorsconstexpr iterator begin() noexcept; constexpr const_iterator begin() const noexcept; constexpr iterator end() noexcept; constexpr const_iterator end() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr const_iterator cend() const noexcept; // capacityconstexpr bool empty() const noexcept; constexpr size_type size() const noexcept; constexpr size_type max_size() const noexcept; // modifierstemplate<class... Args> constexpr iterator emplace(Args&&... args); template<class... Args>constexpr iterator emplace_hint(const_iterator position, Args&&... args); constexpr iterator insert(const value_type& obj); constexpr iterator insert(value_type&& obj); constexpr iterator insert(const_iterator hint, const value_type& obj); constexpr iterator insert(const_iterator hint, value_type&& obj); template<class InputIterator> constexpr void insert(InputIterator first, InputIterator last); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>constexpr void insert_range(R&& rg); constexpr void insert(initializer_list<value_type>); constexpr node_type extract(const_iterator position); constexpr node_type extract(const key_type& x); template<class K> constexpr node_type extract(K&& x); constexpr iterator insert(node_type&& nh); constexpr iterator insert(const_iterator hint, node_type&& nh); constexpr iterator erase(iterator position)requires (![same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<iterator, const_iterator>); constexpr iterator erase(const_iterator position); constexpr size_type erase(const key_type& k); template<class K> constexpr size_type erase(K&& x); constexpr iterator erase(const_iterator first, const_iterator last); constexpr void swap(unordered_multiset&)noexcept(allocator_traits<Allocator>::is_always_equal::value && is_nothrow_swappable_v<Hash> && is_nothrow_swappable_v<Pred>); constexpr void clear() noexcept; template<class H2, class P2>constexpr void merge(unordered_multiset<Key, H2, P2, Allocator>& source); template<class H2, class P2>constexpr void merge(unordered_multiset<Key, H2, P2, Allocator>&& source); template<class H2, class P2>constexpr void merge(unordered_set<Key, H2, P2, Allocator>& source); template<class H2, class P2>constexpr void merge(unordered_set<Key, H2, P2, Allocator>&& source); // observersconstexpr hasher hash_function() const; constexpr key_equal key_eq() const; // set operationsconstexpr iterator find(const key_type& k); constexpr const_iterator find(const key_type& k) const; template<class K>constexpr iterator find(const K& k); template<class K>constexpr const_iterator find(const K& k) const; constexpr size_type count(const key_type& k) const; template<class K>constexpr size_type count(const K& k) const; constexpr bool contains(const key_type& k) const; template<class K>constexpr bool contains(const K& k) const; constexpr pair<iterator, iterator> equal_range(const key_type& k); constexpr pair<const_iterator, const_iterator> equal_range(const key_type& k) const; template<class K>constexpr pair<iterator, iterator> equal_range(const K& k); template<class K>constexpr pair<const_iterator, const_iterator> equal_range(const K& k) const; // bucket interfaceconstexpr size_type bucket_count() const noexcept; constexpr size_type max_bucket_count() const noexcept; constexpr size_type bucket_size(size_type n) const; constexpr size_type bucket(const key_type& k) const; template<class K> constexpr size_type bucket(const K& k) const; constexpr local_iterator begin(size_type n); constexpr const_local_iterator begin(size_type n) const; constexpr local_iterator end(size_type n); constexpr const_local_iterator end(size_type n) const; constexpr const_local_iterator cbegin(size_type n) const; constexpr const_local_iterator cend(size_type n) const; // hash policyconstexpr float load_factor() const noexcept; constexpr float max_load_factor() const noexcept; constexpr void max_load_factor(float z); constexpr void rehash(size_type n); constexpr void reserve(size_type n); }; template<class InputIterator, class Hash = hash<*iter-value-type*<InputIterator>>, class Pred = equal_to<*iter-value-type*<InputIterator>>, class Allocator = allocator<*iter-value-type*<InputIterator>>> unordered_multiset(InputIterator, InputIterator, *see below*::size_type = *see below*,
 Hash = Hash(), Pred = Pred(), Allocator = Allocator())-> unordered_multiset<*iter-value-type*<InputIterator>,
 Hash, Pred, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Hash = hash<ranges::range_value_t<R>>, class Pred = equal_to<ranges::range_value_t<R>>, class Allocator = allocator<ranges::range_value_t<R>>> unordered_multiset(from_range_t, R&&, typename *see below*::size_type = *see below*,
 Hash = Hash(), Pred = Pred(), Allocator = Allocator())-> unordered_multiset<ranges::range_value_t<R>, Hash, Pred, Allocator>; template<class T, class Hash = hash<T>, class Pred = equal_to<T>, class Allocator = allocator<T>> unordered_multiset(initializer_list<T>, typename *see below*::size_type = *see below*,
 Hash = Hash(), Pred = Pred(), Allocator = Allocator())-> unordered_multiset<T, Hash, Pred, Allocator>; template<class InputIterator, class Allocator> unordered_multiset(InputIterator, InputIterator, typename *see below*::size_type, Allocator)-> unordered_multiset<*iter-value-type*<InputIterator>,
 hash<*iter-value-type*<InputIterator>>,
 equal_to<*iter-value-type*<InputIterator>>,
 Allocator>; template<class InputIterator, class Hash, class Allocator> unordered_multiset(InputIterator, InputIterator, typename *see below*::size_type,
 Hash, Allocator)-> unordered_multiset<*iter-value-type*<InputIterator>, Hash,
 equal_to<*iter-value-type*<InputIterator>>,
 Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Allocator> unordered_multiset(from_range_t, R&&, typename *see below*::size_type, Allocator)-> unordered_multiset<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
 equal_to<ranges::range_value_t<R>>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Allocator> unordered_multiset(from_range_t, R&&, Allocator)-> unordered_multiset<ranges::range_value_t<R>, hash<ranges::range_value_t<R>>,
 equal_to<ranges::range_value_t<R>>, Allocator>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]") R, class Hash, class Allocator> unordered_multiset(from_range_t, R&&, typename *see below*::size_type, Hash, Allocator)-> unordered_multiset<ranges::range_value_t<R>, Hash, equal_to<ranges::range_value_t<R>>,
 Allocator>; template<class T, class Allocator> unordered_multiset(initializer_list<T>, typename *see below*::size_type, Allocator)-> unordered_multiset<T, hash<T>, equal_to<T>, Allocator>; template<class T, class Hash, class Allocator> unordered_multiset(initializer_list<T>, typename *see below*::size_type, Hash, Allocator)-> unordered_multiset<T, Hash, equal_to<T>, Allocator>;}

[5](#multiset.overview-5)

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

A size_type parameter type in an unordered_multiset deduction guide
refers to the size_type member type of
the type deduced by the deduction guide[.](#multiset.overview-5.sentence-1)

#### [23.5.7.2](#multiset.cnstr) Constructors [[unord.multiset.cnstr]](unord.multiset.cnstr)

[ð](#lib:unordered_multiset,constructor)

`constexpr unordered_multiset() : unordered_multiset(size_type(see below)) { }
constexpr explicit unordered_multiset(size_type n, const hasher& hf = hasher(),
                                      const key_equal& eql = key_equal(),
                                      const allocator_type& a = allocator_type());
`

[1](#multiset.cnstr-1)

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

*Effects*: Constructs an empty unordered_multiset using the
specified hash function, key equality predicate, and allocator, and
using at least n buckets[.](#multiset.cnstr-1.sentence-1)

For the default constructor,
the number of buckets is implementation-defined[.](#multiset.cnstr-1.sentence-2)

max_load_factor() returns 1.0[.](#multiset.cnstr-1.sentence-3)

[2](#multiset.cnstr-2)

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

*Complexity*: Constant[.](#multiset.cnstr-2.sentence-1)

[ð](#lib:unordered_multiset,constructor_)

`template<class InputIterator>
  constexpr unordered_multiset(InputIterator f, InputIterator l,
                               size_type n = see below, const hasher& hf = hasher(),
                               const key_equal& eql = key_equal(),
                               const allocator_type& a = allocator_type());
template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<value_type> R>
  constexpr unordered_multiset(from_range_t, R&& rg,
                               size_type n = see below, const hasher& hf = hasher(),
                               const key_equal& eql = key_equal(),
                               const allocator_type& a = allocator_type());
constexpr unordered_multiset(initializer_list<value_type> il,
                             size_type n = see below, const hasher& hf = hasher(),
                             const key_equal& eql = key_equal(),
                             const allocator_type& a = allocator_type());
`

[3](#multiset.cnstr-3)

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

*Effects*: Constructs an empty unordered_multiset using the
specified hash function, key equality predicate, and allocator, and
using at least n buckets[.](#multiset.cnstr-3.sentence-1)

If n is not
provided, the number of buckets is implementation-defined[.](#multiset.cnstr-3.sentence-2)

Then
inserts elements from the range [f, l), rg, or il,
respectively[.](#multiset.cnstr-3.sentence-3)

max_load_factor() returns 1.0[.](#multiset.cnstr-3.sentence-4)

[4](#multiset.cnstr-4)

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

*Complexity*: Average case linear, worst case quadratic[.](#multiset.cnstr-4.sentence-1)

#### [23.5.7.3](#multiset.erasure) Erasure [[unord.multiset.erasure]](unord.multiset.erasure)

[ð](#lib:erase_if,unordered_multiset)

`template<class K, class H, class P, class A, class Predicate>
  constexpr typename unordered_multiset<K, H, P, A>::size_type
    erase_if(unordered_multiset<K, H, P, A>& c, Predicate pred);
`

[1](#multiset.erasure-1)

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

*Effects*: Equivalent to:auto original_size = c.size();for (auto i = c.begin(), last = c.end(); i != last; ) {if (pred(*i)) { i = c.erase(i); } else {++i; }}return original_size - c.size();
