en	Class Template unordered_multimap

en	:idprefix: unordered_multimap_

en	`boost::unordered_multimap` — An unordered associative container that associates keys with another value. The same key can be stored multiple times.

en	Synopsis

en	---

en	Description

en	*Template Parameters*

en	_Key_

en	`Key` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it).

en	_T_

en	`T` must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container (i.e. `allocator_traits` can destroy it).

en	_Hash_

en	A unary function object type that acts a hash function for a `Key`. It takes a single argument of type `Key` and returns a value of type `std::size_t`.

en	_Pred_

en	A binary function object that implements an equivalence relation on values of type `Key`. A binary function object that induces an equivalence relation on values of type `Key`. It takes two arguments of type `Key` and returns a value of type bool.

en	_Allocator_

en	An allocator whose value type is the same as the container's value type.

en	Allocators using https://en.cppreference.com/w/cpp/named_req/Allocator#Fancy_pointers[fancy pointers] are supported.

en	The elements are organized into buckets. Keys with the same hash code are stored in the same bucket.

en	The number of buckets can be automatically increased by a call to insert, or as the result of calling rehash.

en	Configuration macros

en	`BOOST_UNORDERED_ENABLE_SERIALIZATION_COMPATIBILITY_V0`

en	Globally define this macro to support loading of ``unordered_multimap``s saved to a Boost.Serialization archive with a version of Boost prior to Boost 1.84.

en	Typedefs

en	An iterator whose value type is `value_type`.

en	The iterator category is at least a forward iterator.

en	Convertible to `const_iterator`.

en	---

en	A constant iterator whose value type is `value_type`.

en	The iterator category is at least a forward iterator.

en	---

en	An iterator with the same value type, difference type and pointer and reference type as iterator.

en	A `local_iterator` object can be used to iterate through a single bucket.

en	---

en	A constant iterator with the same value type, difference type and pointer and reference type as const_iterator.

en	A const_local_iterator object can be used to iterate through a single bucket.

en	---

en	See node_handle_map for details.

en	---

en	Constructors

en	Default Constructor

en	```c++ unordered_multimap(); ```

en	Constructs an empty container using `hasher()` as the hash function, `key_equal()` as the key equality predicate, `allocator_type()` as the allocator and a maximum load factor of `1.0`.

en	Postconditions:;; `size() == 0` Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].

en	---

en	Bucket Count Constructor

en	```c++ explicit unordered_multimap(size_type n, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); ```

en	Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0`.

en	Postconditions:;; `size() == 0` Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].

en	---

en	Iterator Range Constructor

en	Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it.

en	Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].

en	---

en	Copy Constructor

en	```c++ unordered_multimap(const unordered_multimap& other); ```

en	The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator.

en	If `Allocator::select_on_container_copy_construction` exists and has the right signature, the allocator will be constructed from its result.

en	Requires:;; `value_type` is copy constructible

en	---

en	Move Constructor

en	```c++ unordered_multimap(unordered_multimap&& other); ```

en	The move constructor.

en	Notes:;; This is implemented using Boost.Move. Requires:;; `value_type` is move-constructible.

en	---

en	Iterator Range Constructor with Allocator

en	```c++ template<class InputIterator> unordered_multimap(InputIterator f, InputIterator l, const allocator_type& a); ```

en	Constructs an empty container using `a` as the allocator, with the default hash function and key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it.

en	Requires:;; `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].

en	---

en	Allocator Constructor

en	```c++ explicit unordered_multimap(const Allocator& a); ```

en	Constructs an empty container, using allocator `a`.

en	---

en	Copy Constructor with Allocator

en	```c++ unordered_multimap(const unordered_multimap& other, const Allocator& a); ```

en	Constructs an container, copying ``other``'s contained elements, hash function, predicate, maximum load factor, but using allocator `a`.

en	---

en	Move Constructor with Allocator

en	```c++ unordered_multimap(unordered_multimap&& other, const Allocator& a); ```

en	Construct a container moving ``other``'s contained elements, and having the hash function, predicate and maximum load factor, but using allocate `a`.

en	Notes:;; This is implemented using Boost.Move. Requires:;; `value_type` is move insertable.

en	---

en	Initializer List Constructor

en	Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, `a` as the allocator and a maximum load factor of `1.0` and inserts the elements from `il` into it.

en	Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].

en	---

en	Bucket Count Constructor with Allocator

en	```c++ unordered_multimap(size_type n, const allocator_type& a); ```

en	Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default hash function and key equality predicate, `a` as the allocator and a maximum load factor of `1.0`.

en	Postconditions:;; `size() == 0` Requires:;; `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].

en	---

en	Bucket Count Constructor with Hasher and Allocator

en	```c++ unordered_multimap(size_type n, const hasher& hf, const allocator_type& a); ```

en	Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default key equality predicate, `a` as the allocator and a maximum load factor of `1.0`.

en	Postconditions:;; `size() == 0` Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].

en	---

en	Iterator Range Constructor with Bucket Count and Allocator

en	Constructs an empty container with at least `n` buckets, using `a` as the allocator, with the default hash function and key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it.

en	Requires:;; `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].

en	---

en	Iterator Range Constructor with Bucket Count and Hasher

en	Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `a` as the allocator, with the default key equality predicate and a maximum load factor of `1.0` and inserts the elements from `[f, l)` into it.

en	Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].

en	---

en	initializer_list Constructor with Allocator

en	```c++ unordered_multimap(std::initializer_list<value_type> il, const allocator_type& a); ```

en	Constructs an empty container using `a` as the allocator and a maximum load factor of 1.0 and inserts the elements from `il` into it.

en	Requires:;; `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].

en	---

en	initializer_list Constructor with Bucket Count and Allocator

en	```c++ unordered_multimap(std::initializer_list<value_type> il, size_type n, const allocator_type& a); ```

en	Constructs an empty container with at least `n` buckets, using `a` as the allocator and a maximum load factor of 1.0 and inserts the elements from `il` into it.

en	Requires:;; `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].

en	---

en	initializer_list Constructor with Bucket Count and Hasher and Allocator

en	```c++ unordered_multimap(std::initializer_list<value_type> il, size_type n, const hasher& hf, const allocator_type& a); ```

en	Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `a` as the allocator and a maximum load factor of 1.0 and inserts the elements from `il` into it.

en	Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].

en	---

en	Destructor

en	```c++ ~unordered_multimap(); ```

en	Note:;; The destructor is applied to every element, and all memory is deallocated

en	---

en	Assignment

en	Copy Assignment

en	```c++ unordered_multimap& operator=(const unordered_multimap& other); ```

en	The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator.

en	If `Alloc::propagate_on_container_copy_assignment` exists and `Alloc::propagate_on_container_copy_assignment::value` is `true`, the allocator is overwritten, if not the copied elements are created using the existing allocator.

en	Requires:;; `value_type` is copy constructible

en	---

en	Move Assignment

en	```c++ unordered_multimap& operator=(unordered_multimap&& other) noexcept(boost::allocator_traits<Allocator>::is_always_equal::value && boost::is_nothrow_move_assignable_v<Hash> && boost::is_nothrow_move_assignable_v<Pred>); ``` The move assignment operator.

en	If `Alloc::propagate_on_container_move_assignment` exists and `Alloc::propagate_on_container_move_assignment::value` is `true`, the allocator is overwritten, if not the moved elements are created using the existing allocator.

en	Requires:;; `value_type` is move constructible.

en	---

en	Initializer List Assignment

en	```c++ unordered_multimap& operator=(std::initializer_list<value_type> il); ```

en	Assign from values in initializer list. All existing elements are either overwritten by the new elements or destroyed.

en	Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container and https://en.cppreference.com/w/cpp/named_req/CopyAssignable[CopyAssignable^].

en	Iterators

en	begin

en	```c++ iterator begin() noexcept; const_iterator begin() const noexcept; ```

en	Returns:;; An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container.

en	---

en	end

en	```c++ iterator end() noexcept; const_iterator end() const noexcept; ```

en	Returns:;; An iterator which refers to the past-the-end value for the container.

en	---

en	cbegin

en	```c++ const_iterator cbegin() const noexcept; ```

en	Returns:;; A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container.

en	---

en	cend

en	```c++ const_iterator cend() const noexcept; ```

en	Returns:;; A `const_iterator` which refers to the past-the-end value for the container.

en	---

en	Size and Capacity

en	empty

en	```c++ [[nodiscard]] bool empty() const noexcept; ```

en	Returns:;; `size() == 0`

en	---

en	size

en	```c++ size_type size() const noexcept; ```

en	Returns:;; `std::distance(begin(), end())`

en	---

en	max_size

en	```c++ size_type max_size() const noexcept; ```

en	Returns:;; `size()` of the largest possible container.

en	---

en	Modifiers

en	emplace

en	```c++ template<class... Args> iterator emplace(Args&&... args); ```

en	Inserts an object, constructed with the arguments `args`, in the container.

en	Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. Returns:;; An iterator pointing to the inserted element. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + + Pointers and references to elements are never invalidated.

en	---

en	emplace_hint

en	```c++ template<class... Args> iterator emplace_hint(const_iterator position, Args&&... args); ```

en	Inserts an object, constructed with the arguments args, in the container.

en	`position` is a suggestion to where the element should be inserted.

en	Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `args`. Returns:;; An iterator pointing to the inserted element. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + + Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + + Pointers and references to elements are never invalidated.

en	---

en	Copy Insert

en	```c++ iterator insert(const value_type& obj); ```

en	Inserts `obj` in the container.

en	Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. Returns:;; An iterator pointing to the inserted element. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + + Pointers and references to elements are never invalidated.

en	---

en	Move Insert

en	```c++ iterator insert(value_type&& obj); ```

en	Inserts `obj` in the container.

en	Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. Returns:;; An iterator pointing to the inserted element. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + + Pointers and references to elements are never invalidated.

en	---

en	Emplace Insert

en	```c++ template<class P> iterator insert(P&& obj); ```

en	Inserts an element into the container by performing `emplace(std::forward<P>(value))`.

en	Only participates in overload resolution if `std::is_constructible<value_type, P&&>::value` is `true`.

en	Returns:;; An iterator pointing to the inserted element.

en	---

en	Copy Insert with Hint

en	```c++ iterator insert(const_iterator hint, const value_type& obj); ``` Inserts `obj` in the container.

en	`hint` is a suggestion to where the element should be inserted.

en	Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. Returns:;; An iterator pointing to the inserted element. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + + Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + + Pointers and references to elements are never invalidated.

en	---

en	Move Insert with Hint

en	```c++ iterator insert(const_iterator hint, value_type&& obj); ```

en	Inserts `obj` in the container.

en	`hint` is a suggestion to where the element should be inserted.

en	Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. Returns:;; An iterator pointing to the inserted element. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + + Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + + Pointers and references to elements are never invalidated.

en	---

en	Emplace Insert with Hint

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

en	Inserts an element into the container by performing `emplace_hint(hint, std::forward<P>(value))`.

en	Only participates in overload resolution if `std::is_constructible<value_type, P&&>::value` is `true`.

en	`hint` is a suggestion to where the element should be inserted.

en	Returns:;; An iterator pointing to the inserted element. Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + + Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + + Pointers and references to elements are never invalidated.

en	---

en	Insert Iterator Range

en	```c++ template<class InputIterator> void insert(InputIterator first, InputIterator last); ```

en	Inserts a range of elements into the container.

en	Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into `X` from `*first`. Throws:;; When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + + Pointers and references to elements are never invalidated.

en	---

en	Insert Initializer List

en	```c++ void insert(std::initializer_list<value_type> il); ```

en	Inserts a range of elements into the container.

en	Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container. Throws:;; When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + + Pointers and references to elements are never invalidated.

en	---

en	Extract by Iterator

en	```c++ node_type extract(const_iterator position); ```

en	Removes the element pointed to by `position`.

en	Returns:;; A `node_type` owning the element. Notes:;; A node extracted using this method can be inserted into a compatible `unordered_map`.

en	---

en	Extract by Key

en	```c++ node_type extract(const key_type& k); template<class K> node_type extract(K&& k); ```

en	Removes an element with key equivalent to `k`.

en	Returns:;; A `node_type` owning the element if found, otherwise an empty `node_type`. Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. Notes:;; A node extracted using this method can be inserted into a compatible `unordered_map`. + + The `template<class K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.

en	---

en	Insert with `node_handle`

en	```c++ iterator insert(node_type&& nh); ```

en	If `nh` is empty, has no effect.

en	Otherwise inserts the element owned by `nh`.

en	Requires:;; `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. Returns:;; If `nh` was empty, returns `end()`. + + Otherwise returns an iterator pointing to the newly inserted element. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + + Pointers and references to elements are never invalidated. + + This can be used to insert a node extracted from a compatible `unordered_map`.

en	---

en	Insert with Hint and `node_handle`

en	```c++ iterator insert(const_iterator hint, node_type&& nh); ```

en	If `nh` is empty, has no effect.

en	Otherwise inserts the element owned by `nh`.

en	`hint` is a suggestion to where the element should be inserted.

en	Requires:;; `nh` is empty or `nh.get_allocator()` is equal to the container's allocator. Returns:;; If `nh` was empty, returns `end()`. + + Otherwise returns an iterator pointing to the newly inserted element. Throws:;; If an exception is thrown by an operation other than a call to hasher the function has no effect. Notes:;; The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key. + + Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor. + + Pointers and references to elements are never invalidated. + + This can be used to insert a node extracted from a compatible `unordered_map`.

en	---

en	Erase by Position

en	```c++ iterator erase(iterator position); iterator erase(const_iterator position); ```

en	Erase the element pointed to by `position`.

en	Returns:;; The iterator following `position` before the erasure. Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. Notes:;; In older versions this could be inefficient because it had to search through several buckets to find the position of the returned iterator. The data structure has been changed so that this is no longer the case, and the alternative erase methods have been deprecated.

en	---

en	Erase by Key

en	```c++ size_type erase(const key_type& k); template<class K> size_type erase(K&& k); ```

en	Erase all elements with key equivalent to `k`.

en	Returns:;; The number of elements erased. Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. Notes:;; The `template<class K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.

en	---

en	Erase Range

en	```c++ iterator erase(const_iterator first, const_iterator last); ```

en	Erases the elements in the range from `first` to `last`.

en	Returns:;; The iterator following the erased elements - i.e. `last`. Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + + In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.

en	---

en	quick_erase

en	```c++ void quick_erase(const_iterator position); ```

en	Erase the element pointed to by `position`.

en	Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + + In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. Notes:;; This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated.

en	---

en	erase_return_void

en	```c++ void erase_return_void(const_iterator position); ```

en	Erase the element pointed to by `position`.

en	Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. + + In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations. Notes:;; This method was implemented because returning an iterator to the next element from erase was expensive, but the container has been redesigned so that is no longer the case. So this method is now deprecated.

en	---

en	swap

en	```c++ void swap(unordered_multimap& other) noexcept(boost::allocator_traits<Allocator>::is_always_equal::value && boost::is_nothrow_swappable_v<Hash> && boost::is_nothrow_swappable_v<Pred>); ```

en	Swaps the contents of the container with the parameter.

en	If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior.

en	Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors.

en	---

en	clear

en	```c++ void clear() noexcept; ```

en	Erases all elements in the container.

en	Postconditions:;; `size() == 0` Throws:;; Never throws an exception.

en	---

en	merge

en	```c++ template<class H2, class P2> void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source); template<class H2, class P2> void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source); template<class H2, class P2> void merge(unordered_map<Key, T, H2, P2, Allocator>& source); template<class H2, class P2> void merge(unordered_map<Key, T, H2, P2, Allocator>&& source); ```

en	Attempt to "merge" two containers by iterating `source` and extracting all nodes in `source` and inserting them into `*this`.

en	Because `source` can have a different hash function and key equality predicate, the key of each node in `source` is rehashed using `this\->hash_function()` and then, if required, compared using `this\->key_eq()`.

en	The behavior of this function is undefined if `this\->get_allocator() != source.get_allocator()`.

en	This function does not copy or move any elements and instead simply relocates the nodes from `source` into `*this`.

en	Notes:;; + --

en	Pointers and references to transferred elements remain valid.

en	Invalidates iterators to transferred elements.

en	Invalidates iterators belonging to `*this`.

en	Iterators to non-transferred elements in `source` remain valid.

en	--

en	---

en	Observers

en	get_allocator

en	``` allocator_type get_allocator() const; ```

en	---

en	hash_function

en	``` hasher hash_function() const; ```

en	Returns:;; The container's hash function.

en	---

en	key_eq

en	``` key_equal key_eq() const; ```

en	Returns:;; The container's key equality predicate

en	---

en	Lookup

en	find

en	```c++ iterator find(const key_type& k); const_iterator find(const key_type& k) const; template<class K> iterator find(const K& k); template<class K> const_iterator find(const K& k) const; template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> iterator find(CompatibleKey const& k, CompatibleHash const& hash, CompatiblePredicate const& eq); template<typename CompatibleKey, typename CompatibleHash, typename CompatiblePredicate> const_iterator find(CompatibleKey const& k, CompatibleHash const& hash, CompatiblePredicate const& eq) const;

en	```

en	Returns:;; An iterator pointing to an element with key equivalent to `k`, or `b.end()` if no such element exists. Notes:;; The templated overloads containing `CompatibleKey`, `CompatibleHash` and `CompatiblePredicate` are non-standard extensions which allow you to use a compatible hash function and equality predicate for a key of a different type in order to avoid an expensive type cast. In general, its use is not encouraged and instead the `K` member function templates should be used. + + The `template<class K>` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.

en	---

en	count

en	```c++ size_type count(const key_type& k) const; template<class K> size_type count(const K& k) const; ```

en	Returns:;; The number of elements with key equivalent to `k`. Notes:;; The `template<class K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.

en	---

en	contains

en	```c++ bool contains(const key_type& k) const; template<class K> bool contains(const K& k) const; ```

en	Returns:;; A boolean indicating whether or not there is an element with key equal to `key` in the container Notes:;; The `template<class K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.

en	---

en	equal_range

en	```c++ std::pair<iterator, iterator> equal_range(const key_type& k); std::pair<const_iterator, const_iterator> equal_range(const key_type& k) const; template<class K> std::pair<iterator, iterator> equal_range(const K& k); template<class K> std::pair<const_iterator, const_iterator> equal_range(const K& k) const; ```

en	Returns:;; A range containing all elements with key equivalent to `k`. If the container doesn't contain any such elements, returns `std::make_pair(b.end(), b.end())`. Notes:;; The `template<class K>` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.

en	---

en	Bucket Interface

en	bucket_count

en	```c++ size_type bucket_count() const noexcept; ```

en	Returns:;; The number of buckets.

en	---

en	max_bucket_count

en	```c++ size_type max_bucket_count() const noexcept; ```

en	Returns:;; An upper bound on the number of buckets.

en	---

en	bucket_size

en	```c++ size_type bucket_size(size_type n) const; ```

en	Requires:;; `n < bucket_count()` Returns:;; The number of elements in bucket `n`.

en	---

en	bucket

en	```c++ size_type bucket(const key_type& k) const; template<class K> size_type bucket(const K& k) const; ```

en	Returns:;; The index of the bucket which would contain an element with key `k`. Postconditions:;; The return value is less than `bucket_count()`. Notes:;; The `template<class K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.

en	---

en	begin

en	```c++ local_iterator begin(size_type n); const_local_iterator begin(size_type n) const; ```

en	Requires:;; `n` shall be in the range `[0, bucket_count())`. Returns:;; A local iterator pointing the first element in the bucket with index `n`.

en	---

en	end

en	```c++ local_iterator end(size_type n); const_local_iterator end(size_type n) const; ```

en	Requires:;; `n` shall be in the range `[0, bucket_count())`. Returns:;; A local iterator pointing the 'one past the end' element in the bucket with index `n`.

en	---

en	cbegin

en	```c++ const_local_iterator cbegin(size_type n) const; ```

en	Requires:;; `n` shall be in the range `[0, bucket_count())`. Returns:;; A constant local iterator pointing the first element in the bucket with index `n`.

en	---

en	cend

en	```c++ const_local_iterator cend(size_type n) const; ```

en	Requires:;; `n` shall be in the range `[0, bucket_count())`. Returns:;; A constant local iterator pointing the 'one past the end' element in the bucket with index `n`.

en	---

en	Hash Policy

en	load_factor

en	```c++ float load_factor() const noexcept; ```

en	Returns:;; The average number of elements per bucket.

en	---

en	max_load_factor

en	```c++ float max_load_factor() const noexcept; ```

en	Returns:;; Returns the current maximum load factor.

en	---

en	Set max_load_factor

en	```c++ void max_load_factor(float z); ```

en	Effects:;; Changes the container's maximum load factor, using `z` as a hint.

en	---

en	rehash

en	```c++ void rehash(size_type n); ```

en	Changes the number of buckets so that there are at least `n` buckets, and so that the load factor is less than or equal to the maximum load factor. When applicable, this will either grow or shrink the `bucket_count()` associated with the container.

en	When `size() == 0`, `rehash(0)` will deallocate the underlying buckets array.

en	Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.

en	Throws:;; The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.

en	---

en	reserve

en	```c++ void reserve(size_type n); ```

en	Equivalent to `a.rehash(ceil(n / a.max_load_factor()))`, or `a.rehash(1)` if `n > 0` and `a.max_load_factor() == std::numeric_limits<float>::infinity()`.

en	Similar to `rehash`, this function can be used to grow or shrink the number of buckets in the container.

en	Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.

en	Throws:;; The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.

en	---

en	Deduction Guides

en	A deduction guide will not participate in overload resolution if any of the following are true:

en	- It has an `InputIterator` template parameter and a type that does not qualify as an input iterator is deduced for that parameter. - It has an `Allocator` template parameter and a type that does not qualify as an allocator is deduced for that parameter. - It has a `Hash` template parameter and an integral type or a type that qualifies as an allocator is deduced for that parameter. - It has a `Pred` template parameter and a type that qualifies as an allocator is deduced for that parameter.

en	A `size_­type` parameter type in a deduction guide refers to the `size_­type` member type of the container type deduced by the deduction guide. Its default value coincides with the default value of the constructor selected.

en	__iter-value-type__

en	__iter-key-type__

en	__iter-mapped-type__

en	__iter-to-alloc-type__

en	Equality Comparisons

en	operator

en	```c++ template<class Key, class T, class Hash, class Pred, class Alloc> bool operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x, const unordered_multimap<Key, T, Hash, Pred, Alloc>& y); ```

en	Return `true` if `x.size() == y.size()` and for every equivalent key group in `x`, there is a group in `y` for the same key, which is a permutation (using `operator==` to compare the value types).

en	Notes:;; Behavior is undefined if the two containers don't have equivalent equality predicates.

en	---

en	operator!

en	```c++ template<class Key, class T, class Hash, class Pred, class Alloc> bool operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x, const unordered_multimap<Key, T, Hash, Pred, Alloc>& y); ```

en	Return `false` if `x.size() == y.size()` and for every equivalent key group in `x`, there is a group in `y` for the same key, which is a permutation (using `operator==` to compare the value types).

en	Notes:;; Behavior is undefined if the two containers don't have equivalent equality predicates.

en	---

en	Swap

en	```c++ template<class Key, class T, class Hash, class Pred, class Alloc> void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x, unordered_multimap<Key, T, Hash, Pred, Alloc>& y) noexcept(noexcept(x.swap(y))); ```

en	Swaps the contents of `x` and `y`.

en	If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior.

en	Effects:;; `x.swap(y)` Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`. Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors.

en	---

en	erase_if

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

en	Traverses the container `c` and removes all elements for which the supplied predicate returns `true`.

en	Returns:;; The number of erased elements. Notes:;; Equivalent to: + + ```c++ 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(); ``` + Note that the references passed to `pred` are non-const.

en	Serialization

en	``unordered_multimap``s can be archived/retrieved by means of link:../../../../../serialization/index.html[Boost.Serialization^] using the API provided by this library. Both regular and XML archives are supported.

en	Saving an unordered_multimap to an archive

en	Saves all the elements of an `unordered_multimap` `x` to an archive (XML archive) `ar`.

en	Requires:;; `std::remove_const<key_type>::type` and `std::remove_const<mapped_type>::type` are serializable (XML serializable), and they do support Boost.Serialization `save_construct_data`/`load_construct_data` protocol (automatically suported by https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^] types).

en	---

en	Loading an unordered_multimap from an archive

en	Deletes all preexisting elements of an `unordered_multimap` `x` and inserts from an archive (XML archive) `ar` restored copies of the elements of the original `unordered_multimap` `other` saved to the storage read by `ar`.

en	Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] from `(std::remove_const<key_type>::type&&, std::remove_const<mapped_type>::type&&)`. `x.key_equal()` is functionally equivalent to `other.key_equal()`. Note:;; If the archive was saved using a release of Boost prior to Boost 1.84, the configuration macro `BOOST_UNORDERED_ENABLE_SERIALIZATION_COMPATIBILITY_V0` has to be globally defined for this operation to succeed; otherwise, an exception is thrown.

en	---

en	Saving an iterator/const_iterator to an archive

en	Saves the positional information of an `iterator` (`const_iterator`) `it` to an archive (XML archive) `ar`. `it` can be and `end()` iterator.

en	Requires:;; The `unordered_multimap` `x` pointed to by `it` has been previously saved to `ar`, and no modifying operations have been issued on `x` between saving of `x` and saving of `it`.

en	---

en	Loading an iterator/const_iterator from an archive

en	Makes an `iterator` (`const_iterator`) `it` point to the restored position of the original `iterator` (`const_iterator`) saved to the storage read by an archive (XML archive) `ar`.

en	Requires:;; If `x` is the `unordered_multimap` `it` points to, no modifying operations have been issued on `x` between loading of `x` and loading of `it`.