---
name: "std::multimap"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::multimap"
---

# std::multimap(3)

A standard container made up of (key,value) pairs, which can be retrieved based on a key, in logarithmic time.

## NAME

std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \> - A standard container made up of (key,value) pairs, which can be retrieved based on a key, in logarithmic time.

## SYNOPSIS

\#include \<map\>

### Public Types

typedef \_Alloc **allocator\_type**\
 typedef \_Rep\_type::const\_iterator **const\_iterator**\
 typedef \_Alloc\_traits::const\_pointer **const\_pointer**\
 typedef \_Alloc\_traits::const\_reference **const\_reference**\
 typedef \_Rep\_type::const\_reverse\_iterator **const\_reverse\_iterator**\
 typedef \_Rep\_type::difference\_type **difference\_type**\
 typedef \_Rep\_type::iterator **iterator**\
 typedef \_Compare **key\_compare**\
 typedef \_Key **key\_type**\
 typedef \_Tp **mapped\_type**\
 typedef \_Alloc\_traits::pointer **pointer**\
 typedef \_Alloc\_traits::reference **reference**\
 typedef \_Rep\_type::reverse\_iterator **reverse\_iterator**\
 typedef \_Rep\_type::size\_type **size\_type**\
 typedef **std::pair**\< const \_Key, \_Tp \> **value\_type**\

### Public Member Functions

**multimap** ()=default\
 Default constructor creates no elements.  template\<typename \_InputIterator\> **multimap** (\_InputIterator \_\_first, \_InputIterator \_\_last)\
 Builds a multimap from a range.  template\<typename \_InputIterator\> **multimap** (\_InputIterator \_\_first, \_InputIterator \_\_last, const \_Compare &\_\_comp, const allocator\_type &\_\_a=allocator\_type())\
 Builds a multimap from a range.  template\<typename \_InputIterator\> **multimap** (\_InputIterator \_\_first, \_InputIterator \_\_last, const allocator\_type &\_\_a)\
 Allocator-extended range constructor.  **multimap** (const \_Compare &\_\_comp, const allocator\_type &\_\_a=allocator\_type())\
 Creates a multimap with no elements.  **multimap** (const allocator\_type &\_\_a)\
 Allocator-extended default constructor.  **multimap** (const multimap &)=default\
 Multimap copy constructor.  **multimap** (const multimap &\_\_m, const \_\_type\_identity\_t\< allocator\_type \> &\_\_a)\
 Allocator-extended copy constructor.  **multimap** (**initializer\_list**\< value\_type \> \_\_l, const \_Compare &\_\_comp=\_Compare(), const allocator\_type &\_\_a=allocator\_type())\
 Builds a multimap from an initializer\_list.  **multimap** (**initializer\_list**\< value\_type \> \_\_l, const allocator\_type &\_\_a)\
 Allocator-extended initialier-list constructor.  **multimap** (multimap &&)=default\
 Multimap move constructor.  **multimap** (multimap &&\_\_m, const \_\_type\_identity\_t\< allocator\_type \> &\_\_a) noexcept(**is\_nothrow\_copy\_constructible**\< \_Compare \>::value &&\_Alloc\_traits::\_S\_always\_equal())\
 Allocator-extended move constructor.  **~multimap** ()=default\
 const\_iterator **begin** () const noexcept\
 iterator **begin** () noexcept\
 const\_iterator **cbegin** () const noexcept\
 const\_iterator **cend** () const noexcept\
 void **clear** () noexcept\
 const\_reverse\_iterator **crbegin** () const noexcept\
 const\_reverse\_iterator **crend** () const noexcept\
 template\<typename... \_Args\> iterator **emplace** (\_Args &&... \_\_args)\
 Build and insert a std::pair into the multimap.  template\<typename... \_Args\> iterator **emplace\_hint** (const\_iterator \_\_pos, \_Args &&... \_\_args)\
 Builds and inserts a std::pair into the multimap.  bool **empty** () const noexcept\
 const\_iterator **end** () const noexcept\
 iterator **end** () noexcept\
 size\_type **erase** (const key\_type &\_\_x)\
 Erases elements according to the provided key.  iterator **erase** (const\_iterator \_\_first, const\_iterator \_\_last)\
 Erases a \[first,last) range of elements from a multimap.  allocator\_type **get\_allocator** () const noexcept\
 Get a copy of the memory allocation object.  template\<typename \_InputIterator\> void **insert** (\_InputIterator \_\_first, \_InputIterator \_\_last)\
 A template function that attempts to insert a range of elements.  void **insert** (**initializer\_list**\< value\_type \> \_\_l)\
 Attempts to insert a list of std::pairs into the multimap.  key\_compare **key\_comp** () const\
 size\_type **max\_size** () const noexcept\
 **multimap** & **operator=** (const **multimap** &)=default\
 Multimap assignment operator.  **multimap** & **operator=** (**initializer\_list**\< value\_type \> \_\_l)\
 Multimap list assignment operator.  **multimap** & **operator=** (**multimap** &&)=default\
 Move assignment operator.  const\_reverse\_iterator **rbegin** () const noexcept\
 reverse\_iterator **rbegin** () noexcept\
 const\_reverse\_iterator **rend** () const noexcept\
 reverse\_iterator **rend** () noexcept\
 size\_type **size** () const noexcept\
 void **swap** (**multimap** &\_\_x) noexcept(/\***conditional** \*/)\
 Swaps data with another multimap.  value\_compare **value\_comp** () const\

iterator **insert** (const value\_type &\_\_x)\
 Inserts a std::pair into the multimap.  iterator **insert** (value\_type &&\_\_x)\
 Inserts a std::pair into the multimap.  template\<typename \_Pair\> \_\_enable\_if\_t\< **is\_constructible**\< value\_type, \_Pair \>::value, iterator \> **insert** (\_Pair &&\_\_x)\
 Inserts a std::pair into the multimap.

iterator **insert** (const\_iterator \_\_position, const value\_type &\_\_x)\
 Inserts a std::pair into the multimap.  iterator **insert** (const\_iterator \_\_position, value\_type &&\_\_x)\
 Inserts a std::pair into the multimap.  template\<typename \_Pair\> \_\_enable\_if\_t\< **is\_constructible**\< value\_type, \_Pair && \>::value, iterator \> **insert** (const\_iterator \_\_position, \_Pair &&\_\_x)\
 Inserts a std::pair into the multimap.

iterator **erase** (const\_iterator \_\_position)\
 Erases an element from a multimap.  iterator **erase** (iterator \_\_position)\
 Erases an element from a multimap.

iterator **find** (const key\_type &\_\_x)\
 Tries to locate an element in a multimap.

const\_iterator **find** (const key\_type &\_\_x) const\
 Tries to locate an element in a multimap.

size\_type **count** (const key\_type &\_\_x) const\
 Finds the number of elements with given key.

bool **contains** (const key\_type &\_\_x) const\
 Finds whether an element with the given key exists.  template\<typename \_Kt\> auto **contains** (const \_Kt &\_\_x) const -\> decltype(\_M\_t.\_M\_find\_tr(\_\_x), void(), true)\
 Finds whether an element with the given key exists.

iterator **lower\_bound** (const key\_type &\_\_x)\
 Finds the beginning of a subsequence matching given key.

const\_iterator **lower\_bound** (const key\_type &\_\_x) const\
 Finds the beginning of a subsequence matching given key.

iterator **upper\_bound** (const key\_type &\_\_x)\
 Finds the end of a subsequence matching given key.

const\_iterator **upper\_bound** (const key\_type &\_\_x) const\
 Finds the end of a subsequence matching given key.

**std::pair**\< iterator, iterator \> **equal\_range** (const key\_type &\_\_x)\
 Finds a subsequence matching given key.

**std::pair**\< const\_iterator, const\_iterator \> **equal\_range** (const key\_type &\_\_x) const\
 Finds a subsequence matching given key.

### Friends

template\<typename \_K1, typename \_T1, typename \_C1, typename \_A1\> bool **operator\<** (const **multimap**\< \_K1, \_T1, \_C1, \_A1 \> &, const **multimap**\< \_K1, \_T1, \_C1, \_A1 \> &)\
 template\<typename \_K1, typename \_T1, typename \_C1, typename \_A1\> bool **operator==** (const **multimap**\< \_K1, \_T1, \_C1, \_A1 \> &, const **multimap**\< \_K1, \_T1, \_C1, \_A1 \> &)\

## Detailed Description

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\>

class std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>"A standard container made up of (key,value) pairs, which can be retrieved based on a key, in logarithmic time.

**Since**

C++98

**Template Parameters**

*\_Key* Type of key objects. \
 *\_Tp* Type of mapped objects. \
 *\_Compare* Comparison function object type, defaults to less\<\_Key\>. \
 *\_Alloc* Allocator type, defaults to allocator\<pair\<const \_Key, \_Tp\>.

Meets the requirements of a container, a reversible container, and an associative container (using equivalent keys). For a multimap\<Key,T\> the key\_type is Key, the mapped\_type is T, and the value\_type is std::pair\<const Key,T\>.

Multimaps support bidirectional iterators.

The private tree data is declared exactly the same way for map and multimap; the distinction is made entirely in how the tree functions are called (\*\_unique versus \*\_equal, same as the standard).

## Constructor & Destructor Documentation

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::multimap () \[default\]

Default constructor creates no elements.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::multimap (const \_Compare & \_\_comp, const allocator\_type & \_\_a = allocator\_type()) \[inline\], \[explicit\]

Creates a multimap with no elements.

**Parameters**

*\_\_comp* A comparison object. \
 *\_\_a* An allocator object.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::multimap (const multimap\< \_Key, \_Tp, \_Compare, \_Alloc \> & ) \[default\]

Multimap copy constructor. Whether the allocator is copied depends on the allocator traits.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::multimap (multimap\< \_Key, \_Tp, \_Compare, \_Alloc \> && ) \[default\]

Multimap move constructor. The newly-created multimap contains the exact contents of the moved instance. The moved instance is a valid, but unspecified multimap.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::multimap (initializer\_list\< value\_type \> \_\_l, const \_Compare & \_\_comp = \_Compare(), const allocator\_type & \_\_a = allocator\_type()) \[inline\]

Builds a multimap from an initializer\_list.

**Parameters**

*\_\_l* An initializer\_list. \
 *\_\_comp* A comparison functor. \
 *\_\_a* An allocator object.

Create a multimap consisting of copies of the elements from the initializer\_list. This is linear in N if the list is already sorted, and NlogN otherwise (where N is *\_\_l.size()*).

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::multimap (const allocator\_type & \_\_a) \[inline\], \[explicit\]

Allocator-extended default constructor.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::multimap (const multimap\< \_Key, \_Tp, \_Compare, \_Alloc \> & \_\_m, const \_\_type\_identity\_t\< allocator\_type \> & \_\_a) \[inline\]

Allocator-extended copy constructor.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::multimap (multimap\< \_Key, \_Tp, \_Compare, \_Alloc \> && \_\_m, const \_\_type\_identity\_t\< allocator\_type \> & \_\_a) \[inline\], \[noexcept\]

Allocator-extended move constructor.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::multimap (initializer\_list\< value\_type \> \_\_l, const allocator\_type & \_\_a) \[inline\]

Allocator-extended initialier-list constructor.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_InputIterator\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::multimap (\_InputIterator \_\_first, \_InputIterator \_\_last, const allocator\_type & \_\_a) \[inline\]

Allocator-extended range constructor.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_InputIterator\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::multimap (\_InputIterator \_\_first, \_InputIterator \_\_last) \[inline\]

Builds a multimap from a range.

**Parameters**

*\_\_first* An input iterator. \
 *\_\_last* An input iterator.

Create a multimap consisting of copies of the elements from \[\_\_first,\_\_last). This is linear in N if the range is already sorted, and NlogN otherwise (where N is distance(\_\_first,\_\_last)).

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_InputIterator\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::multimap (\_InputIterator \_\_first, \_InputIterator \_\_last, const \_Compare & \_\_comp, const allocator\_type & \_\_a = allocator\_type()) \[inline\]

Builds a multimap from a range.

**Parameters**

*\_\_first* An input iterator. \
 *\_\_last* An input iterator. \
 *\_\_comp* A comparison functor. \
 *\_\_a* An allocator object.

Create a multimap consisting of copies of the elements from \[\_\_first,\_\_last). This is linear in N if the range is already sorted, and NlogN otherwise (where N is distance(\_\_first,\_\_last)).

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::~multimap () \[default\]

The dtor only erases the elements, and note that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

## Member Function Documentation

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> const\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::begin () const \[inline\], \[noexcept\]

Returns a read-only (constant) iterator that points to the first pair in the multimap. Iteration is done in ascending order according to the keys.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::begin () \[inline\], \[noexcept\]

Returns a read/write iterator that points to the first pair in the multimap. Iteration is done in ascending order according to the keys.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> const\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::cbegin () const \[inline\], \[noexcept\]

Returns a read-only (constant) iterator that points to the first pair in the multimap. Iteration is done in ascending order according to the keys.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> const\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::cend () const \[inline\], \[noexcept\]

Returns a read-only (constant) iterator that points one past the last pair in the multimap. Iteration is done in ascending order according to the keys.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> void std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::clear () \[inline\], \[noexcept\]

Erases all elements in a multimap. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_Kt\> auto std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::contains (const \_Kt & \_\_x) const -\> decltype(\_M\_t.\_M\_find\_tr(\_\_x), void(), true) \[inline\]

Finds whether an element with the given key exists.

**Parameters**

*\_\_x* Key of (key, value) pairs to be located.

**Returns**

True if there is any element with the specified key.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> bool std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::contains (const key\_type & \_\_x) const \[inline\]

Finds whether an element with the given key exists.

**Parameters**

*\_\_x* Key of (key, value) pairs to be located.

**Returns**

True if there is any element with the specified key.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> size\_type std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::count (const key\_type & \_\_x) const \[inline\]

Finds the number of elements with given key.

**Parameters**

*\_\_x* Key of (key, value) pairs to be located.

**Returns**

Number of elements with specified key.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> const\_reverse\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::crbegin () const \[inline\], \[noexcept\]

Returns a read-only (constant) reverse iterator that points to the last pair in the multimap. Iteration is done in descending order according to the keys.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> const\_reverse\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::crend () const \[inline\], \[noexcept\]

Returns a read-only (constant) reverse iterator that points to one before the first pair in the multimap. Iteration is done in descending order according to the keys.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename... \_Args\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace (\_Args &&... \_\_args) \[inline\]

Build and insert a std::pair into the multimap.

**Parameters**

*\_\_args* Arguments used to generate a new pair instance (see std::piecewise\_contruct for passing arguments to each part of the pair constructor).

**Returns**

An iterator that points to the inserted (key,value) pair.

This function builds and inserts a (key, value) pair into the multimap. Contrary to a std::map the multimap does not rely on unique keys and thus multiple pairs with the same key can be inserted.

Insertion requires logarithmic time.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename... \_Args\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace\_hint (const\_iterator \_\_pos, \_Args &&... \_\_args) \[inline\]

Builds and inserts a std::pair into the multimap.

**Parameters**

*\_\_pos* An iterator that serves as a hint as to where the pair should be inserted. \
 *\_\_args* Arguments used to generate a new pair instance (see std::piecewise\_contruct for passing arguments to each part of the pair constructor).

**Returns**

An iterator that points to the inserted (key,value) pair.

This function inserts a (key, value) pair into the multimap. Contrary to a std::map the multimap does not rely on unique keys and thus multiple pairs with the same key can be inserted. Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.

For more on *hinting*, see: https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert\_hints

Insertion requires logarithmic time (if the hint is not taken).

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> bool std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::empty () const \[inline\], \[nodiscard\], \[noexcept\]

Returns true if the multimap is empty.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> const\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::end () const \[inline\], \[noexcept\]

Returns a read-only (constant) iterator that points one past the last pair in the multimap. Iteration is done in ascending order according to the keys.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::end () \[inline\], \[noexcept\]

Returns a read/write iterator that points one past the last pair in the multimap. Iteration is done in ascending order according to the keys.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::pair\< iterator, iterator \> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::equal\_range (const key\_type & \_\_x) \[inline\]

Finds a subsequence matching given key.

**Parameters**

*\_\_x* Key of (key, value) pairs to be located.

**Returns**

Pair of iterators that possibly points to the subsequence matching given key.

This function is equivalent to

```
std::make_pair(c.lower_bound(val),
               c.upper_bound(val))
```

 (but is faster than making the calls separately).

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::pair\< const\_iterator, const\_iterator \> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::equal\_range (const key\_type & \_\_x) const \[inline\]

Finds a subsequence matching given key.

**Parameters**

*\_\_x* Key of (key, value) pairs to be located.

**Returns**

Pair of read-only (constant) iterators that possibly points to the subsequence matching given key.

This function is equivalent to

```
std::make_pair(c.lower_bound(val),
               c.upper_bound(val))
```

 (but is faster than making the calls separately).

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> size\_type std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::erase (const key\_type & \_\_x) \[inline\]

Erases elements according to the provided key.

**Parameters**

*\_\_x* Key of element to be erased.

**Returns**

The number of elements erased.

This function erases all elements located by the given key from a multimap. Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::erase (const\_iterator \_\_first, const\_iterator \_\_last) \[inline\]

Erases a \[first,last) range of elements from a multimap.

**Parameters**

*\_\_first* Iterator pointing to the start of the range to be erased. \
 *\_\_last* Iterator pointing to the end of the range to be erased .

**Returns**

The iterator *\_\_last*.

This function erases a sequence of elements from a multimap. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::erase (const\_iterator \_\_position) \[inline\]

Erases an element from a multimap.

**Parameters**

*\_\_position* An iterator pointing to the element to be erased.

**Returns**

An iterator pointing to the element immediately following *position* prior to the element being erased. If no such element exists, end() is returned.

This function erases an element, pointed to by the given iterator, from a multimap. Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::erase (iterator \_\_position) \[inline\]

Erases an element from a multimap.

**Parameters**

*\_\_position* An iterator pointing to the element to be erased.

**Returns**

An iterator pointing to the element immediately following *position* prior to the element being erased. If no such element exists, end() is returned.

This function erases an element, pointed to by the given iterator, from a multimap. Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::find (const key\_type & \_\_x) \[inline\]

Tries to locate an element in a multimap.

**Parameters**

*\_\_x* Key of (key, value) pair to be located.

**Returns**

Iterator pointing to sought-after element, or end() if not found.

This function takes a key and tries to locate the element with which the key matches. If successful the function returns an iterator pointing to the sought after pair. If unsuccessful it returns the past-the-end ( end() ) iterator.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> const\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::find (const key\_type & \_\_x) const \[inline\]

Tries to locate an element in a multimap.

**Parameters**

*\_\_x* Key of (key, value) pair to be located.

**Returns**

Read-only (constant) iterator pointing to sought-after element, or end() if not found.

This function takes a key and tries to locate the element with which the key matches. If successful the function returns a constant iterator pointing to the sought after pair. If unsuccessful it returns the past-the-end ( end() ) iterator.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> allocator\_type std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::get\_allocator () const \[inline\], \[noexcept\]

Get a copy of the memory allocation object.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_InputIterator\> void std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (\_InputIterator \_\_first, \_InputIterator \_\_last) \[inline\]

A template function that attempts to insert a range of elements.

**Parameters**

*\_\_first* Iterator pointing to the start of the range to be inserted. \
 *\_\_last* Iterator pointing to the end of the range.

Complexity similar to that of the range constructor.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_Pair\> \_\_enable\_if\_t\< is\_constructible\< value\_type, \_Pair \>::value, iterator \> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (\_Pair && \_\_x) \[inline\]

Inserts a std::pair into the multimap.

**Parameters**

*\_\_x* Pair to be inserted (see std::make\_pair for easy creation of pairs).

**Returns**

An iterator that points to the inserted (key,value) pair.

This function inserts a (key, value) pair into the multimap. Contrary to a std::map the multimap does not rely on unique keys and thus multiple pairs with the same key can be inserted.

Insertion requires logarithmic time.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (const value\_type & \_\_x) \[inline\]

Inserts a std::pair into the multimap.

**Parameters**

*\_\_x* Pair to be inserted (see std::make\_pair for easy creation of pairs).

**Returns**

An iterator that points to the inserted (key,value) pair.

This function inserts a (key, value) pair into the multimap. Contrary to a std::map the multimap does not rely on unique keys and thus multiple pairs with the same key can be inserted.

Insertion requires logarithmic time.

Referenced by **std::multimap\< \_Key, \_Tp, \_Cmp, polymorphic\_allocator\< pair\< const \_Key, \_Tp \> \> \>::insert()**.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_Pair\> \_\_enable\_if\_t\< is\_constructible\< value\_type, \_Pair && \>::value, iterator \> std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (const\_iterator \_\_position, \_Pair && \_\_x) \[inline\]

Inserts a std::pair into the multimap.

**Parameters**

*\_\_position* An iterator that serves as a hint as to where the pair should be inserted. \
 *\_\_x* Pair to be inserted (see std::make\_pair for easy creation of pairs).

**Returns**

An iterator that points to the inserted (key,value) pair.

This function inserts a (key, value) pair into the multimap. Contrary to a std::map the multimap does not rely on unique keys and thus multiple pairs with the same key can be inserted. Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.

For more on *hinting*, see: https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert\_hints

Insertion requires logarithmic time (if the hint is not taken).

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (const\_iterator \_\_position, const value\_type & \_\_x) \[inline\]

Inserts a std::pair into the multimap.

**Parameters**

*\_\_position* An iterator that serves as a hint as to where the pair should be inserted. \
 *\_\_x* Pair to be inserted (see std::make\_pair for easy creation of pairs).

**Returns**

An iterator that points to the inserted (key,value) pair.

This function inserts a (key, value) pair into the multimap. Contrary to a std::map the multimap does not rely on unique keys and thus multiple pairs with the same key can be inserted. Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.

For more on *hinting*, see: https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert\_hints

Insertion requires logarithmic time (if the hint is not taken).

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (const\_iterator \_\_position, value\_type && \_\_x) \[inline\]

Inserts a std::pair into the multimap.

**Parameters**

*\_\_position* An iterator that serves as a hint as to where the pair should be inserted. \
 *\_\_x* Pair to be inserted (see std::make\_pair for easy creation of pairs).

**Returns**

An iterator that points to the inserted (key,value) pair.

This function inserts a (key, value) pair into the multimap. Contrary to a std::map the multimap does not rely on unique keys and thus multiple pairs with the same key can be inserted. Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.

For more on *hinting*, see: https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert\_hints

Insertion requires logarithmic time (if the hint is not taken).

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> void std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (initializer\_list\< value\_type \> \_\_l) \[inline\]

Attempts to insert a list of std::pairs into the multimap.

**Parameters**

*\_\_l* A std::initializer\_list\<value\_type\> of pairs to be inserted.

Complexity similar to that of the range constructor.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (value\_type && \_\_x) \[inline\]

Inserts a std::pair into the multimap.

**Parameters**

*\_\_x* Pair to be inserted (see std::make\_pair for easy creation of pairs).

**Returns**

An iterator that points to the inserted (key,value) pair.

This function inserts a (key, value) pair into the multimap. Contrary to a std::map the multimap does not rely on unique keys and thus multiple pairs with the same key can be inserted.

Insertion requires logarithmic time.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> key\_compare std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::key\_comp () const \[inline\]

Returns the key comparison object out of which the multimap was constructed.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::lower\_bound (const key\_type & \_\_x) \[inline\]

Finds the beginning of a subsequence matching given key.

**Parameters**

*\_\_x* Key of (key, value) pair to be located.

**Returns**

Iterator pointing to first element equal to or greater than key, or end().

This function returns the first element of a subsequence of elements that matches the given key. If unsuccessful it returns an iterator pointing to the first element that has a greater value than given key or end() if no such element exists.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> const\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::lower\_bound (const key\_type & \_\_x) const \[inline\]

Finds the beginning of a subsequence matching given key.

**Parameters**

*\_\_x* Key of (key, value) pair to be located.

**Returns**

Read-only (constant) iterator pointing to first element equal to or greater than key, or end().

This function returns the first element of a subsequence of elements that matches the given key. If unsuccessful the iterator will point to the next greatest element or, if no such greater element exists, to end().

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> size\_type std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::max\_size () const \[inline\], \[noexcept\]

Returns the maximum size of the multimap.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> multimap & std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::operator= (const multimap\< \_Key, \_Tp, \_Compare, \_Alloc \> & ) \[default\]

Multimap assignment operator. Whether the allocator is copied depends on the allocator traits.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> multimap & std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::operator= (initializer\_list\< value\_type \> \_\_l) \[inline\]

Multimap list assignment operator.

**Parameters**

*\_\_l* An initializer\_list.

This function fills a multimap with copies of the elements in the initializer list *\_\_l*.

Note that the assignment completely changes the multimap and that the resulting multimap's size is the same as the number of elements assigned.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> multimap & std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::operator= (multimap\< \_Key, \_Tp, \_Compare, \_Alloc \> && ) \[default\]

Move assignment operator.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> const\_reverse\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::rbegin () const \[inline\], \[noexcept\]

Returns a read-only (constant) reverse iterator that points to the last pair in the multimap. Iteration is done in descending order according to the keys.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> reverse\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::rbegin () \[inline\], \[noexcept\]

Returns a read/write reverse iterator that points to the last pair in the multimap. Iteration is done in descending order according to the keys.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> const\_reverse\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::rend () const \[inline\], \[noexcept\]

Returns a read-only (constant) reverse iterator that points to one before the first pair in the multimap. Iteration is done in descending order according to the keys.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> reverse\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::rend () \[inline\], \[noexcept\]

Returns a read/write reverse iterator that points to one before the first pair in the multimap. Iteration is done in descending order according to the keys.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> size\_type std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::size () const \[inline\], \[noexcept\]

Returns the size of the multimap.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> void std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::swap (multimap\< \_Key, \_Tp, \_Compare, \_Alloc \> & \_\_x) \[inline\], \[noexcept\]

Swaps data with another multimap.

**Parameters**

*\_\_x* A multimap of the same element and allocator types.

This exchanges the elements between two multimaps in constant time. (It is only swapping a pointer, an integer, and an instance of the Compare type (which itself is often stateless and empty), so it should be quite fast.) Note that the global std::swap() function is specialized such that std::swap(m1,m2) will feed to this function.

Whether the allocators are swapped depends on the allocator traits.

Referenced by **std::swap()**.

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::upper\_bound (const key\_type & \_\_x) \[inline\]

Finds the end of a subsequence matching given key.

**Parameters**

*\_\_x* Key of (key, value) pair to be located.

**Returns**

Iterator pointing to the first element greater than key, or end().

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> const\_iterator std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::upper\_bound (const key\_type & \_\_x) const \[inline\]

Finds the end of a subsequence matching given key.

**Parameters**

*\_\_x* Key of (key, value) pair to be located.

**Returns**

Read-only (constant) iterator pointing to first iterator greater than key, or end().

### template\<typename \_Key, typename \_Tp, typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> value\_compare std::multimap\< \_Key, \_Tp, \_Compare, \_Alloc \>::value\_comp () const \[inline\]

Returns a value comparison object, built from the key comparison object out of which the multimap was constructed.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
