[#bsl-multimap-0ae]
= xref:bsl.adoc[bsl]::multimap
:relfileprefix: ../
:mrdocs:

This class template implements a value&hyphen;semantic container type holding an ordered sequence of key&hyphen;value pairs having possibly duplicate keys that provide a mapping from keys (of the template parameter type, `KEY`) to their associated values (of another template parameter type, `VALUE`)&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;multimap&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class VALUE,
    class COMPARATOR = std::less&lt;KEY&gt;,
    class ALLOCATOR = xref:bsl/allocator-0df.adoc[allocator&lt;pair&lt;KEY const, VALUE&gt;&gt;]&gt;
class multimap;
----

== Description

This class&colon; &ast; supports a complete set of _value&hyphen;semantic_ operations

* except for BDEX serialization &ast; is _exception&hyphen;neutral_ &ast; is _alias&hyphen;safe_ &ast; is `const` _thread&hyphen;safe_ For terminology see &lcub;`bsldoc&lowbar;glossary`&rcub;&period;

== Types

[cols="1,4"]
|===
| Name| Description
| xref:bsl/multimap-0ae/value_compare.adoc[`value&lowbar;compare`] 
| This nested class defines a mechanism for comparing two objects of `value&lowbar;type` by adapting an object of (template parameter) type `COMPARATOR`, which compares two objects of (template parameter) type `KEY` &period; Note that this class exactly matches its definition in the C&plus;&plus;11 standard &lsqb;23&period;4&period;4&period;1&rsqb;&semi; otherwise, we would have implemented it as a separate component&hyphen;local class&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:bsl/multimap-0ae/allocator_type.adoc[`allocator&lowbar;type`] 
| Allocator type for this container&period;
| xref:bsl/multimap-0ae/const_iterator.adoc[`const&lowbar;iterator`] 
| Constant bidirectional iterator over `multimap` elements&period;
| xref:bsl/multimap-0ae/const_pointer.adoc[`const&lowbar;pointer`] 
| Constant pointer type for elements in this container&period;
| xref:bsl/multimap-0ae/const_reference.adoc[`const&lowbar;reference`] 
| Constant reference type for elements&period;
| xref:bsl/multimap-0ae/const_reverse_iterator.adoc[`const&lowbar;reverse&lowbar;iterator`] 
| Const reverse iterator type for traversing the multimap in reverse order&period;
| xref:bsl/multimap-0ae/difference_type.adoc[`difference&lowbar;type`] 
| Signed integer type measuring iterator distance&period;
| xref:bsl/multimap-0ae/iterator.adoc[`iterator`] 
| Bidirectional iterator over `multimap` elements&period;
| xref:bsl/multimap-0ae/key_compare.adoc[`key&lowbar;compare`] 
| Comparator type for ordering keys&period;
| xref:bsl/multimap-0ae/key_type.adoc[`key&lowbar;type`] 
| Key type for this multimap&period;
| xref:bsl/multimap-0ae/mapped_type.adoc[`mapped&lowbar;type`] 
| Mapped value type for this multimap&period;
| xref:bsl/multimap-0ae/pointer.adoc[`pointer`] 
| Pointer type for elements in this container&period;
| xref:bsl/multimap-0ae/reference.adoc[`reference`] 
| Modifiable reference type for elements&period;
| xref:bsl/multimap-0ae/reverse_iterator.adoc[`reverse&lowbar;iterator`] 
| Reverse iterator type for traversing the multimap in reverse order&period;
| xref:bsl/multimap-0ae/size_type.adoc[`size&lowbar;type`] 
| Unsigned integer type measuring multimap size&period;
| xref:bsl/multimap-0ae/value_type.adoc[`value&lowbar;type`] 
| Element type stored in this multimap&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/multimap-0ae/2constructor-005.adoc[`multimap`]         [.small]#[constructor]#
| Constructors
| xref:bsl/multimap-0ae/2destructor.adoc[`&#126;multimap`] [.small]#[destructor]#
| Destroy this object&period;
| xref:bsl/multimap-0ae/operator_assign-07.adoc[`operator&equals;`] 
| Assignment operators
| xref:bsl/multimap-0ae/begin-04a.adoc[`begin`] 
| `begin` overloads
| xref:bsl/multimap-0ae/cbegin.adoc[`cbegin`] 
| Return an iterator providing non&hyphen;modifiable access to the first `value&lowbar;type` object in the ordered sequence of `value&lowbar;type` objects maintained by this multimap, or the `cend` iterator if this multimap is empty&period;
| xref:bsl/multimap-0ae/cend.adoc[`cend`] 
| Return an iterator providing non&hyphen;modifiable access to the past&hyphen;the&hyphen;end element in the ordered sequence of `value&lowbar;type` objects maintained by this multimap&period;
| xref:bsl/multimap-0ae/clear.adoc[`clear`] 
| Remove all entries from this multimap&period; Note that the multimap is empty after this call, but allocated memory may be retained for future use&period;
| xref:bsl/multimap-0ae/contains-05.adoc[`contains`] 
| Return `true` if this multimap contains an element whose key is equivalent to the specified `key`&period;
| xref:bsl/multimap-0ae/count-07.adoc[`count`] 
| Return the number of `value&lowbar;type` objects within this multimap whose keys are equivalent to the specified `key`&period;
| xref:bsl/multimap-0ae/crbegin.adoc[`crbegin`] 
| Return a reverse iterator providing non&hyphen;modifiable access to the last `value&lowbar;type` object in the ordered sequence of `value&lowbar;type` objects maintained by this multimap, or `rend` if this multimap is empty&period;
| xref:bsl/multimap-0ae/crend.adoc[`crend`] 
| Return a reverse iterator providing non&hyphen;modifiable access to the prior&hyphen;to&hyphen;the&hyphen;beginning element in the ordered sequence of `value&lowbar;type` objects maintained by this multimap&period;
| xref:bsl/multimap-0ae/emplace.adoc[`emplace`] 
| Insert into this multimap a newly&hyphen;created `value&lowbar;type` object, constructed by forwarding `get&lowbar;allocator()` (if required) and the specified (variable number of) `args` to the corresponding constructor of `value&lowbar;type`&period; Return an iterator referring to the newly created and inserted object in this multimap&period; This method requires that the (template parameter) types `KEY` and `VALUE` both be `emplace&hyphen;constructible` from `args` (see &lcub;Requirements on `KEY` and `VALUE`&rcub;)&period;
| xref:bsl/multimap-0ae/emplace_hint.adoc[`emplace&lowbar;hint`] 
| Insert into this multimap a newly&hyphen;created `value&lowbar;type` object, constructed by forwarding `get&lowbar;allocator()` (if required) and the specified (variable number of) `args` to the corresponding constructor of `value&lowbar;type` (in amortized constant time if the specified `hint` is a valid immediate successor to the `value&lowbar;type` object constructed from `args`)&period; Return an iterator referring to the newly created and inserted object in this multimap&period; If `hint` is not a valid immediate successor to the `value&lowbar;type` object implied by `args`, this operation has `O&lsqb;log(N)&rsqb;` complexity where `N` is the size of this multimap&period; This method requires that the (template parameter) types `KEY` and `VALUE` both be `emplace&hyphen;constructible` from `args` (see &lcub;Requirements on `KEY` and `VALUE`&rcub;)&period; The behavior is undefined unless `hint` is an iterator in the range `&lsqb;begin() &period;&period; end()&rsqb;` (both endpoints included)&period;
| xref:bsl/multimap-0ae/empty.adoc[`empty`] 
| Return `true` if this multimap contains no elements, and `false` otherwise&period;
| xref:bsl/multimap-0ae/end-07.adoc[`end`] 
| `end` overloads
| xref:bsl/multimap-0ae/equal_range-00.adoc[`equal&lowbar;range`] 
| `equal&lowbar;range` overloads
| xref:bsl/multimap-0ae/erase-039.adoc[`erase`] 
| `erase` overloads
| xref:bsl/multimap-0ae/find-0c.adoc[`find`] 
| `find` overloads
| xref:bsl/multimap-0ae/get_allocator.adoc[`get&lowbar;allocator`] 
| Return (a copy of) the allocator used for memory allocation by this multimap&period;
| xref:bsl/multimap-0ae/insert-09.adoc[`insert`] 
| `insert` overloads
| xref:bsl/multimap-0ae/insert_range.adoc[`insert&lowbar;range`] 
| Insert into this multimap the value of each `value&lowbar;type` object in the specified `range`&period; The (template parameter) type `RANGE` must meet the requirements of the C&plus;&plus;20 standard &lsqb;ranges&rsqb;providing access to values of a type convertible to `value&lowbar;type`, and `value&lowbar;type` must be `emplace&hyphen;constructible` from `&ast;i` into this multimap, where `i` is a dereferenceable iterator obtained from `range` (see &lcub;Requirements on `KEY` and `VALUE`&rcub;)&period; The behavior is undefined if `range` overlaps this multimap&period;
| xref:bsl/multimap-0ae/key_comp.adoc[`key&lowbar;comp`] 
| Return the key&hyphen;comparison functor (or function pointer) used by this multimap&semi; if a comparator was supplied at construction, return its value, otherwise return a default constructed `key&lowbar;compare` object&period; Note that this comparator compares objects of type `KEY`, which is the key part of the `value&lowbar;type` objects contained in this multimap&period;
| xref:bsl/multimap-0ae/lower_bound-079.adoc[`lower&lowbar;bound`] 
| `lower&lowbar;bound` overloads
| xref:bsl/multimap-0ae/max_size.adoc[`max&lowbar;size`] 
| Return a theoretical upper bound on the largest number of elements that this multimap could possibly hold&period; Note that there is no guarantee that the multimap can successfully grow to the returned size, or even close to that size without running out of resources&period;
| xref:bsl/multimap-0ae/rbegin-02.adoc[`rbegin`] 
| `rbegin` overloads
| xref:bsl/multimap-0ae/rend-06.adoc[`rend`] 
| `rend` overloads
| xref:bsl/multimap-0ae/size.adoc[`size`] 
| Return the number of elements in this multimap&period;
| xref:bsl/multimap-0ae/swap.adoc[`swap`] 
| Exchange the value and comparator of this object with those of the specified `other` object&semi; also exchange the allocator of this object with that of `other` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if and only if the (template parameter) type `COMPARATOR` provides a no&hyphen;throw swap operation, and provides the basic exception&hyphen;safety guarantee otherwise&semi; if an exception is thrown, both objects are left in valid but unspecified states&period; This operation has `O&lsqb;1&rsqb;` complexity if either this object was created with the same allocator as `other` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&semi; otherwise, it has `O&lsqb;n &plus; m&rsqb;` complexity, where `n` and `m` are the number of elements in this object and `other`, respectively&period; Note that this method&apos;s support for swapping objects created with different allocators when `ALLOCATOR` does not have the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait is a departure from the C&plus;&plus; Standard&period;
| xref:bsl/multimap-0ae/upper_bound-00.adoc[`upper&lowbar;bound`] 
| `upper&lowbar;bound` overloads
| xref:bsl/multimap-0ae/value_comp.adoc[`value&lowbar;comp`] 
| Return a functor for comparing two `value&lowbar;type` objects by comparing their respective keys using `key&lowbar;comp()`&period; Note that this comparator compares objects of type `value&lowbar;type` (i&period;e&period;, &apos;pair&lt;const KEY, VALUE&gt;&apos;)&period;
|===


== Deduction Guides

[cols="1,4"]
|===
| Name| Description
| xref:bsl/multimap-07.adoc[`multimap&lt;KEY, VALUE&gt;`] 
| Deduce the template parameters `KEY` and `VALUE` from the `value&lowbar;type` of the initializer&lowbar;list supplied to the constructor of `multimap`&period; This deduction guide does not participate unless the supplied allocator is convertible to `bsl&colon;&colon;allocator&lt;bsl&colon;&colon;pair&lt;const KEY, VALUE&gt;&gt;`&period;
| xref:bsl/multimap-0d.adoc[`multimap&lt;KEY, VALUE&gt;`] 
| Deduce the template parameters `KEY` and `VALUE` from the `value&lowbar;type` of the iterators supplied to the constructor of `multimap`&period; This deduction guide does not participate unless the supplied allocator is convertible to `bsl&colon;&colon;allocator&lt;bsl&colon;&colon;pair&lt;const KEY, VALUE&gt;&gt;`&period;
| xref:bsl/multimap-0e.adoc[`multimap&lt;KEY, VALUE, COMPARATOR&gt;`] 
| Deduce the template parameters `KEY` and `VALUE` from the `value&lowbar;type` of the initializer&lowbar;list supplied to the constructor of `multimap`&period; Deduce the template parameter `COMPARATOR` from the other parameters passed to the constructor&period; This deduction guide does not participate unless the supplied allocator is convertible to `bsl&colon;&colon;allocator&lt;bsl&colon;&colon;pair&lt;const KEY, VALUE&gt;&gt;`&period;
| xref:bsl/multimap-01.adoc[`multimap&lt;KEY, VALUE, COMPARATOR&gt;`] 
| Deduce the template parameters `KEY` and `VALUE` from the `value&lowbar;type` of the iterators supplied to the constructor of `multimap`&period; Deduce the template parameter `COMPARATOR` from the other parameter passed to the constructor&period; This deduction guide does not participate unless the supplied allocator is convertible to `bsl&colon;&colon;allocator&lt;bsl&colon;&colon;pair&lt;const KEY, VALUE&gt;&gt;`&period;
| xref:bsl/multimap-0a3.adoc[`multimap&lt;KEY, VALUE, COMPARATOR, ALLOCATOR&gt;`] 
| Deduce the template parameters `KEY` and `VALUE` from the `value&lowbar;type` of the initializer&lowbar;list supplied to the constructor of `multimap`&period; Deduce the template parameters `COMPARATOR` and `ALLOCATOR` from the other parameters passed to the constructor&period; This deduction guide does not participate unless the supplied allocator meets the requirements of a standard allocator&period;
| xref:bsl/multimap-0f.adoc[`multimap&lt;KEY, VALUE, COMPARATOR, ALLOCATOR&gt;`] 
| Deduce the template parameters `KEY` and `VALUE` from the `value&lowbar;type` of the iterators supplied to the constructor of `multimap`&period; Deduce the template parameters `COMPARATOR` and `ALLOCATOR` from the other parameters passed to the constructor&period; This deduction guide does not participate unless the supplied allocator meets the requirements of a standard allocator&period;
| xref:bsl/multimap-09.adoc[`multimap&lt;KEY, VALUE, std::less&lt;KEY&gt;, ALLOCATOR&gt;`] 
| Deduce the template parameters `KEY` and `VALUE` from the `value&lowbar;type` of the initializer&lowbar;list supplied to the constructor of `multimap`&period; Deduce the template parameter `ALLOCATOR` from the other parameter passed to the constructor&period; This deduction guide does not participate unless the supplied allocator meets the requirements of a standard allocator&period;
| xref:bsl/multimap-00.adoc[`multimap&lt;KEY, VALUE, std::less&lt;KEY&gt;, ALLOCATOR&gt;`] 
| Deduce the template parameters `KEY` and `VALUE` from the `value&lowbar;type` of the iterators supplied to the constructor of `multimap`&period; This deduction guide does not participate unless the supplied allocator meets the requirements of a standard allocator&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/erase_if-0f.adoc[`erase&lowbar;if`]
| Erase all the elements in the specified multimap `m` that satisfy the specified predicate `predicate`&period; Return the number of elements erased&period;
| xref:bsl/operator_3way-081.adoc[`operator&lt;&equals;&gt;`]
| Perform a lexicographic three&hyphen;way comparison of the specified `lhs` and the specified `rhs` maps by using the comparison operators of `bsl&colon;&colon;pair&lt;const KEY, VALUE&gt;` on each element&semi; return the result of that comparison&period;
| xref:bsl/operator_eq-03.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` objects have the same value, and `false` otherwise&period; Two `multimap` objects `lhs` and `rhs` have the same value if they have the same number of key&hyphen;value pairs, and each element in the ordered sequence of key&hyphen;value pairs of `lhs` has the same value as the corresponding element in the ordered sequence of key&hyphen;value pairs of `rhs`&period; This method requires that the (template parameter) types `KEY` and `VALUE` both be `equality&hyphen;comparable` (see &lcub;Requirements on `KEY` and `VALUE`&rcub;)&period;
| xref:bsl/swap-073.adoc[`swap`]
| Exchange the value and comparator of the specified `a` object with those of the specified `b` object&semi; also exchange the allocator of `a` with that of `b` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee if and only if the (template parameter) type `COMPARATOR` provides a no&hyphen;throw swap operation, and provides the basic exception&hyphen;safety guarantee otherwise&semi; if an exception is thrown, both objects are left in valid but unspecified states&period; This operation has `O&lsqb;1&rsqb;` complexity if either `a` was created with the same allocator as `b` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&semi; otherwise, it has `O&lsqb;n &plus; m&rsqb;` complexity, where `n` and `m` are the number of elements in `a` and `b`, respectively&period; Note that this function&apos;s support for swapping objects created with different allocators when `ALLOCATOR` does not have the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait is a departure from the C&plus;&plus; Standard&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
