---
name: "std::map"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::map/3cxx"
---

# std::map(3cxx)

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

## NAME

std::map\< \_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**\
 **using** **insert\_return\_type** = **typename** **\_Rep\_type::insert\_return\_type**\
 **typedef** **\_Rep\_type::iterator** **iterator**\
 **typedef** \_Compare **key\_compare**\
 **typedef** **\_Key** **key\_type**\
 **typedef** \_Tp **mapped\_type**\
 **using** **node\_type** = **typename** **\_Rep\_type::node\_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

**map** ()=**default**\
 Default constructor creates no elements.  template\<**typename** **\_InputIterator** \> **map** (**\_InputIterator** \_\_first, **\_InputIterator** \_\_last)\
 Builds a map from a range.  template\<**typename** **\_InputIterator** \> **map** (**\_InputIterator** \_\_first, **\_InputIterator** \_\_last, const \_Compare &\_\_comp, const allocator\_type &\_\_a=allocator\_type())\
 Builds a map from a range.  template\<**typename** **\_InputIterator** \> **map** (**\_InputIterator** \_\_first, **\_InputIterator** \_\_last, const allocator\_type &\_\_a)\
 Allocator-extended range constructor.  **map** (const \_Compare &\_\_comp, const allocator\_type &\_\_a=allocator\_type())\
 Creates a map with no elements.  **map** (const allocator\_type &\_\_a)\
 Allocator-extended default constructor.  **map** (const **map** &)=**default**\
 Map copy constructor.  **map** (const **map** &**\_\_m**, const **\_\_type\_identity\_t**\< allocator\_type \> &\_\_a)\
 Allocator-extended copy constructor.  **map** (**initializer\_list**\< **value\_type** \> **\_\_l**, const \_Compare &\_\_comp=\_Compare(), const allocator\_type &\_\_a=allocator\_type())\
 Builds a map from an initializer\_list.  **map** (**initializer\_list**\< **value\_type** \> **\_\_l**, const allocator\_type &\_\_a)\
 Allocator-extended initialier-list constructor.  **map** (**map** &&)=**default**\
 Map move constructor.  **map** (**map** &&**\_\_m**, const **\_\_type\_identity\_t**\< allocator\_type \> &\_\_a) noexcept(**is\_nothrow\_copy\_constructible**\< \_Compare \>::value &&\_Alloc\_traits::\_S\_always\_equal())\
 Allocator-extended move constructor.  **~map** ()=**default**\
 mapped\_type & **at** (const **key\_type** &**\_\_k**)\
 Access to map data.  const mapped\_type & **at** (const **key\_type** &**\_\_k**) const\
 **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\> **std::pair**\< **iterator**, bool \> **emplace** (**\_Args** &&... **\_\_args**)\
 Attempts to build and insert a std::pair into the map.  template\<typename... \_Args\> **iterator** **emplace\_hint** (**const\_iterator** **\_\_pos**, **\_Args** &&... **\_\_args**)\
 Attempts to build and insert a std::pair into the map.  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 map.  node\_type **extract** (const **key\_type** &\_\_x)\
 Extract a node.  node\_type **extract** (**const\_iterator** **\_\_pos**)\
 Extract a node.  allocator\_type **get\_allocator** () const noexcept\
 Get a copy of the memory allocation object.  template\<**typename** **\_InputIterator** \> **void** **insert** (**\_InputIterator** \_\_first, **\_InputIterator** \_\_last)\
 Template function that attempts to insert a range of elements.  **iterator** **insert** (**const\_iterator** **\_\_hint**, node\_type &&**\_\_nh**)\
 Re-insert an extracted node.  insert\_return\_type **insert** (node\_type &&**\_\_nh**)\
 Re-insert an extracted node.  **void** **insert** (**std::initializer\_list**\< **value\_type** \> **\_\_list**)\
 Attempts to insert a list of std::pairs into the map.  template\<**typename** \_Obj \> **pair**\< **iterator**, bool \> **insert\_or\_assign** (const **key\_type** &**\_\_k**, \_Obj &&**\_\_obj**)\
 Attempts to insert or assign a std::pair into the map.  template\<**typename** \_Obj \> **iterator** **insert\_or\_assign** (**const\_iterator** **\_\_hint**, const **key\_type** &**\_\_k**, \_Obj &&**\_\_obj**)\
 Attempts to insert or assign a std::pair into the map.  template\<**typename** \_Obj \> **iterator** **insert\_or\_assign** (**const\_iterator** **\_\_hint**, **key\_type** &&**\_\_k**, \_Obj &&**\_\_obj**)\
 template\<**typename** \_Obj \> **pair**\< **iterator**, bool \> **insert\_or\_assign** (**key\_type** &&**\_\_k**, \_Obj &&**\_\_obj**)\
 key\_compare **key\_comp** () const\
 size\_type **max\_size** () const noexcept\
 template\<**typename** **\_Cmp2** \> **void** **merge** (**map**\< **\_Key**, \_Tp, **\_Cmp2**, \_Alloc \> &&**\_\_source**)\
 template\<**typename** **\_Cmp2** \> **void** **merge** (**map**\< **\_Key**, \_Tp, **\_Cmp2**, \_Alloc \> &**\_\_source**)\
 template\<**typename** **\_Cmp2** \> **void** **merge** (**multimap**\< **\_Key**, \_Tp, **\_Cmp2**, \_Alloc \> &&**\_\_source**)\
 template\<**typename** **\_Cmp2** \> **void** **merge** (**multimap**\< **\_Key**, \_Tp, **\_Cmp2**, \_Alloc \> &**\_\_source**)\
 **map** & **operator=** (const **map** &)=**default**\
 Map assignment operator.  **map** & **operator=** (**initializer\_list**\< **value\_type** \> **\_\_l**)\
 Map list assignment operator.  **map** & **operator=** (**map** &&)=**default**\
 Move assignment operator.  mapped\_type & **operator\[\]** (const **key\_type** &**\_\_k**)\
 Subscript ( \[\] ) access to map data.  mapped\_type & **operator\[\]** (**key\_type** &&**\_\_k**)\
 **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** (**map** &\_\_x) noexcept(/\***conditional** \*/)\
 Swaps data with another map.  template\<typename... \_Args\> **pair**\< **iterator**, bool \> **try\_emplace** (const **key\_type** &**\_\_k**, **\_Args** &&... **\_\_args**)\
 Attempts to build and insert a std::pair into the map.  template\<typename... \_Args\> **iterator** **try\_emplace** (**const\_iterator** **\_\_hint**, const **key\_type** &**\_\_k**, **\_Args** &&... **\_\_args**)\
 Attempts to build and insert a std::pair into the map.  template\<typename... \_Args\> **iterator** **try\_emplace** (**const\_iterator** **\_\_hint**, **key\_type** &&**\_\_k**, **\_Args** &&... **\_\_args**)\
 template\<typename... \_Args\> **pair**\< **iterator**, bool \> **try\_emplace** (**key\_type** &&**\_\_k**, **\_Args** &&... **\_\_args**)\
 value\_compare **value\_comp** () const\

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

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

**iterator** **erase** (**const\_iterator** **\_\_position**)\
 Erases an element from a map.  \_GLIBCXX\_ABI\_TAG\_CXX11 **iterator** **erase** (**iterator** **\_\_position**)\
 Erases an element from a map.

**iterator** **find** (const **key\_type** &\_\_x)\
 Tries to locate an element in a map.  template\<**typename** **\_Kt** \> **auto** **find** (const **\_Kt** &\_\_x) -\> **decltype**(\_M\_t.\_M\_find\_tr(\_\_x))\
 Tries to locate an element in a map.

**const\_iterator** **find** (const **key\_type** &\_\_x) const\
 Tries to locate an element in a map.  template\<**typename** **\_Kt** \> **auto** **find** (const **\_Kt** &\_\_x) const -\> **decltype**(\_M\_t.\_M\_find\_tr(\_\_x))\
 Tries to locate an element in a map.

size\_type **count** (const **key\_type** &\_\_x) const\
 Finds the number of elements with given key.  template\<**typename** **\_Kt** \> **auto** **count** (const **\_Kt** &\_\_x) const -\> **decltype**(\_M\_t.\_M\_count\_tr(\_\_x))\
 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.  template\<**typename** **\_Kt** \> **auto** **lower\_bound** (const **\_Kt** &\_\_x) -\> **decltype**(**iterator**(\_M\_t.\_M\_lower\_bound\_tr(\_\_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.  template\<**typename** **\_Kt** \> **auto** **lower\_bound** (const **\_Kt** &\_\_x) const -\> **decltype**(**const\_iterator**(\_M\_t.\_M\_lower\_bound\_tr(\_\_x)))\
 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.  template\<**typename** **\_Kt** \> **auto** **upper\_bound** (const **\_Kt** &\_\_x) -\> **decltype**(**iterator**(\_M\_t.\_M\_upper\_bound\_tr(\_\_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.  template\<**typename** **\_Kt** \> **auto** **upper\_bound** (const **\_Kt** &\_\_x) const -\> **decltype**(**const\_iterator**(\_M\_t.\_M\_upper\_bound\_tr(\_\_x)))\
 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.  template\<**typename** **\_Kt** \> **auto** **equal\_range** (const **\_Kt** &\_\_x) -\> **decltype**(**pair**\< **iterator**, **iterator** \>(\_M\_t.\_M\_equal\_range\_tr(\_\_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.  template\<**typename** **\_Kt** \> **auto** **equal\_range** (const **\_Kt** &\_\_x) const -\> **decltype**(**pair**\< **const\_iterator**, **const\_iterator** \>(\_M\_t.\_M\_equal\_range\_tr(\_\_x)))\
 Finds a subsequence matching given key.

### Friends

template\<**typename** **\_K1** , **typename** \_T1 , **typename** **\_C1** , **typename** **\_A1** \> bool **operator\<** (const **map**\< **\_K1**, \_T1, **\_C1**, **\_A1** \> &, const **map**\< **\_K1**, \_T1, **\_C1**, **\_A1** \> &)\
 template\<**typename** **\_K1** , **typename** \_T1 , **typename** **\_C1** , **typename** **\_A1** \> bool **operator==** (const **map**\< **\_K1**, \_T1, **\_C1**, **\_A1** \> &, const **map**\< **\_K1**, \_T1, **\_C1**, **\_A1** \> &)\
 template\<**typename** , **typename** \> **struct** **std::\_Rb\_tree\_merge\_helper**\

## Detailed Description

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

class std::map\< \_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 unique keys). For a `map<Key,T>` the key\_type is Key, the mapped\_type is T, and the value\_type is std::pair\<const Key,T\>.

Maps 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::map ()` [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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::map (const \_Compare & \_\_comp, const allocator\_type & \_\_a = `allocator_type()`)` [inline]`, ` [explicit]`

Creates a map 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::map (const map\< \_Key, \_Tp, \_Compare, \_Alloc \> &)` [default]`

Map 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::map (map\< \_Key, \_Tp, \_Compare, \_Alloc \> &&)` [default]`

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

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

Builds a map from an initializer\_list.

**Parameters**

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

Create a map consisting of copies of the elements in the initializer\_list *\_\_l*. This is linear in N if the range 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::map (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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::map (const map\< \_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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::map (map\< \_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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::map (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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::map (\_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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::map (\_InputIterator \_\_first, \_InputIterator \_\_last)` [inline]`

Builds a map from a range.

**Parameters**

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

Create a map 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::map (\_InputIterator \_\_first, \_InputIterator \_\_last, const \_Compare & \_\_comp, const allocator\_type & \_\_a = `allocator_type()`)` [inline]`

Builds a map from a range.

**Parameters**

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

Create a map 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::~map ()` [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\> \>\> mapped\_type & std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::at (const key\_type & \_\_k)` [inline]`

Access to map data.

**Parameters**

*\_\_k* The key for which data should be retrieved.

**Returns**

A reference to the data whose key is equivalent to *\_\_k*, if such a data is present in the map.

**Exceptions**

*std::out\_of\_range* If no such data is present.

References **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::end()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::key\_comp()**, and **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::lower\_bound()**.

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

Returns a read-only (constant) iterator that points to the first pair in the map. 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::begin ()` [inline]`, ` [noexcept]`

Returns a read/write iterator that points to the first pair in the map. 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::cbegin () const` [inline]`, ` [noexcept]`

Returns a read-only (constant) iterator that points to the first pair in the map. 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::cend () const` [inline]`, ` [noexcept]`

Returns a read-only (constant) iterator that points one past the last pair in the map. 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::clear ()` [inline]`, ` [noexcept]`

Erases all elements in a map. 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::map\< \_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 an 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::map\< \_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 an element with the specified key.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_Kt \> auto std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::count (const \_Kt & \_\_x) const -\> decltype(\_M\_t.\_M\_count\_tr(\_\_x))

	` [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.

This function only makes sense for multimaps; for map the result will either be 0 (not present) or 1 (present).

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> size\_type std::map\< \_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.

This function only makes sense for multimaps; for map the result will either be 0 (not present) or 1 (present).

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

Returns a read-only (constant) reverse iterator that points to the last pair in the map. 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::map\< \_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 map. 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\> std::pair\< iterator, bool \> std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace (\_Args &&... \_\_args)` [inline]`

Attempts to build and insert a std::pair into the map.

**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**

A pair, of which the first element is an iterator that points to the possibly inserted pair, and the second is a bool that is true if the pair was actually inserted.

This function attempts to build and insert a (key, value) pair into the map. A map relies on unique keys and thus a pair is only inserted if its first element (the key) is not already present in the map.

Insertion requires logarithmic time.

References **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace\_hint()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::end()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::key\_comp()**, and **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::lower\_bound()**.

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

Attempts to build and insert a std::pair into the map.

**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 element with key of the std::pair built from *\_\_args* (may or may not be that std::pair).

This function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument emplace() does. 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.

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

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

Referenced by **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert\_or\_assign()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert\_or\_assign()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::try\_emplace()**, and **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::try\_emplace()**.

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

Returns true if the map is empty. (Thus begin() would equal end().)

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

Returns a read-only (constant) iterator that points one past the last pair in the map. 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::end ()` [inline]`, ` [noexcept]`

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

Referenced by **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::at()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::extract()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert\_or\_assign()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::operator\[\]()**, and **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::try\_emplace()**.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_Kt \> auto std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::equal\_range (const \_Kt & \_\_x) -\> decltype(pair\<iterator, iterator\>(\_M\_t.\_M\_equal\_range\_tr(\_\_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).

This function probably only makes sense for multimaps.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_Kt \> auto std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::equal\_range (const \_Kt & \_\_x) const -\> decltype(pair\<const\_iterator, const\_iterator\>(

	      \_M\_t.\_M\_equal\_range\_tr(\_\_x)))\
 	` [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).

This function probably only makes sense for multimaps.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> std::pair\< iterator, iterator \> std::map\< \_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).

This function probably only makes sense for multimaps.

### 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::map\< \_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).

This function probably only makes sense for multimaps.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> size\_type std::map\< \_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 the elements located by the given key from a map. 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::erase (const\_iterator \_\_first, const\_iterator \_\_last)` [inline]`

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

**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 map. 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::erase (const\_iterator \_\_position)` [inline]`

Erases an element from a map.

**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 map. 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\> \>\> \_GLIBCXX\_ABI\_TAG\_CXX11 iterator std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::erase (iterator \_\_position)` [inline]`

Erases an element from a map.

**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 map. 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\> \>\> node\_type std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::extract (const key\_type & \_\_x)` [inline]`

Extract a node.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> node\_type std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::extract (const\_iterator \_\_pos)` [inline]`

Extract a node.

References **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::end()**.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_Kt \> auto std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::find (const \_Kt & \_\_x) -\> decltype(\_M\_t.\_M\_find\_tr(\_\_x))

	` [inline]`"

Tries to locate an element in a map.

**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\> \>\> template\<typename \_Kt \> auto std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::find (const \_Kt & \_\_x) const -\> decltype(\_M\_t.\_M\_find\_tr(\_\_x))

	` [inline]`"

Tries to locate an element in a map.

**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\> \>\> iterator std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::find (const key\_type & \_\_x)` [inline]`

Tries to locate an element in a map.

**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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::find (const key\_type & \_\_x) const` [inline]`

Tries to locate an element in a map.

**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::map\< \_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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (\_InputIterator \_\_first, \_InputIterator \_\_last)` [inline]`

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, pair\< iterator, bool \> \> std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (\_Pair && \_\_x)` [inline]`

Attempts to insert a std::pair into the map.

**Parameters**

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

**Returns**

A pair, of which the first element is an iterator that points to the possibly inserted pair, and the second is a bool that is true if the pair was actually inserted.

This function attempts to insert a (key, value) pair into the map. A map relies on unique keys and thus a pair is only inserted if its first element (the key) is not already present in the map.

Insertion requires logarithmic time.

References **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace\_hint()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::end()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::key\_comp()**, and **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::lower\_bound()**.

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

Attempts to insert a std::pair into the map.

**Parameters**

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

**Returns**

A pair, of which the first element is an iterator that points to the possibly inserted pair, and the second is a bool that is true if the pair was actually inserted.

This function attempts to insert a (key, value) pair into the map. A map relies on unique keys and thus a pair is only inserted if its first element (the key) is not already present in the map.

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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (const\_iterator \_\_hint, node\_type && \_\_nh)` [inline]`

Re-insert an extracted node.

References **std::move()**.

### 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (const\_iterator \_\_position, \_Pair && \_\_x)` [inline]`

Attempts to insert a std::pair into the map.

**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 element with key of *\_\_x* (may or may not be the pair passed in).

This function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument insert() does. 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.

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

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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (const\_iterator \_\_position, const value\_type & \_\_x)` [inline]`

Attempts to insert a std::pair into the map.

**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 element with key of *\_\_x* (may or may not be the pair passed in).

This function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument insert() does. 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.

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

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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (const\_iterator \_\_position, value\_type && \_\_x)` [inline]`

Attempts to insert a std::pair into the map.

**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 element with key of *\_\_x* (may or may not be the pair passed in).

This function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument insert() does. 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.

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

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

References **std::move()**.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> insert\_return\_type std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert (node\_type && \_\_nh)` [inline]`

Re-insert an extracted node.

References **std::move()**.

Referenced by **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert()**, and **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::operator\[\]()**.

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

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

**Parameters**

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

Complexity similar to that of the range constructor.

References **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert()**.

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

Attempts to insert a std::pair into the map.

**Parameters**

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

**Returns**

A pair, of which the first element is an iterator that points to the possibly inserted pair, and the second is a bool that is true if the pair was actually inserted.

This function attempts to insert a (key, value) pair into the map. A map relies on unique keys and thus a pair is only inserted if its first element (the key) is not already present in the map.

Insertion requires logarithmic time.

References **std::move()**.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_Obj \> pair\< iterator, bool \> std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert\_or\_assign (const key\_type & \_\_k, \_Obj && \_\_obj)` [inline]`

Attempts to insert or assign a std::pair into the map.

**Parameters**

*\_\_k* Key to use for finding a possibly existing pair in the map. \
 *\_\_obj* Argument used to generate the .second for a pair instance.

**Returns**

A pair, of which the first element is an iterator that points to the possibly inserted pair, and the second is a bool that is true if the pair was actually inserted.

This function attempts to insert a (key, value) pair into the map. A map relies on unique keys and thus a pair is only inserted if its first element (the key) is not already present in the map. If the pair was already in the map, the .second of the pair is assigned from \_\_obj.

Insertion requires logarithmic time.

References **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace\_hint()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::end()**, **std::forward\_as\_tuple()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::key\_comp()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::lower\_bound()**, and **std::piecewise\_construct**.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_Obj \> iterator std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert\_or\_assign (const\_iterator \_\_hint, const key\_type & \_\_k, \_Obj && \_\_obj)` [inline]`

Attempts to insert or assign a std::pair into the map.

**Parameters**

*\_\_hint* An iterator that serves as a hint as to where the pair should be inserted. \
 *\_\_k* Key to use for finding a possibly existing pair in the map. \
 *\_\_obj* Argument used to generate the .second for a pair instance.

**Returns**

An iterator that points to the element with key of *\_\_x* (may or may not be the pair passed in).

This function attempts to insert a (key, value) pair into the map. A map relies on unique keys and thus a pair is only inserted if its first element (the key) is not already present in the map. If the pair was already in the map, the .second of the pair is assigned from \_\_obj.

Insertion requires logarithmic time.

References **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace\_hint()**, **std::forward\_as\_tuple()**, and **std::piecewise\_construct**.

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

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

Referenced by **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::at()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert\_or\_assign()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::operator\[\]()**, and **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::try\_emplace()**.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_Kt \> auto std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::lower\_bound (const \_Kt & \_\_x) -\> decltype(iterator(\_M\_t.\_M\_lower\_bound\_tr(\_\_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\> \>\> template\<typename \_Kt \> auto std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::lower\_bound (const \_Kt & \_\_x) const -\> decltype(const\_iterator(\_M\_t.\_M\_lower\_bound\_tr(\_\_x)))

	` [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 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\> \>\> iterator std::map\< \_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.

Referenced by **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::at()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert\_or\_assign()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::operator\[\]()**, and **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::try\_emplace()**.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> const\_iterator std::map\< \_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 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\> \>\> size\_type std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::max\_size () const` [inline]`, ` [noexcept]`

Returns the maximum size of the map. \

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

Map 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\> \>\> map & std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::operator= (initializer\_list\< value\_type \> \_\_l)` [inline]`

Map list assignment operator.

**Parameters**

*\_\_l* An initializer\_list.

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

Note that the assignment completely changes the map and that the resulting map'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\> \>\> map & std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::operator= (map\< \_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\> \>\> mapped\_type & std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::operator\[\] (const key\_type & \_\_k)` [inline]`

Subscript ( \[\] ) access to map data.

**Parameters**

*\_\_k* The key for which data should be retrieved.

**Returns**

A reference to the data of the (key,data) pair.

Allows for easy lookup with the subscript ( \[\] ) operator. Returns data associated with the key specified in subscript. If the key does not exist, a pair with that key is created using default values, which is then returned.

Lookup requires logarithmic time.

References **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::end()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::insert()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::key\_comp()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::lower\_bound()**, and **std::piecewise\_construct**.

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

Returns a read-only (constant) reverse iterator that points to the last pair in the map. 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::rbegin ()` [inline]`, ` [noexcept]`

Returns a read/write reverse iterator that points to the last pair in the map. 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::map\< \_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 map. 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::rend ()` [inline]`, ` [noexcept]`

Returns a read/write reverse iterator that points to one before the first pair in the map. 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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::size () const` [inline]`, ` [noexcept]`

Returns the size of the map. \

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

Swaps data with another map.

**Parameters**

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

This exchanges the elements between two maps 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.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename... \_Args\> pair\< iterator, bool \> std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::try\_emplace (const key\_type & \_\_k, \_Args &&... \_\_args)` [inline]`

Attempts to build and insert a std::pair into the map.

**Parameters**

*\_\_k* Key to use for finding a possibly existing pair in the map. \
 *\_\_args* Arguments used to generate the .second for a new pair instance.

**Returns**

A pair, of which the first element is an iterator that points to the possibly inserted pair, and the second is a bool that is true if the pair was actually inserted.

This function attempts to build and insert a (key, value) pair into the map. A map relies on unique keys and thus a pair is only inserted if its first element (the key) is not already present in the map. If a pair is not inserted, this function has no effect.

Insertion requires logarithmic time.

References **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace\_hint()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::end()**, **std::forward\_as\_tuple()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::key\_comp()**, **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::lower\_bound()**, and **std::piecewise\_construct**.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename... \_Args\> iterator std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::try\_emplace (const\_iterator \_\_hint, const key\_type & \_\_k, \_Args &&... \_\_args)` [inline]`

Attempts to build and insert a std::pair into the map.

**Parameters**

*\_\_hint* An iterator that serves as a hint as to where the pair should be inserted. \
 *\_\_k* Key to use for finding a possibly existing pair in the map. \
 *\_\_args* Arguments used to generate the .second for a new pair instance.

**Returns**

An iterator that points to the element with key of the std::pair built from *\_\_args* (may or may not be that std::pair).

This function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument try\_emplace() does. However, if insertion did not take place, this function has no effect. 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.

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

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

References **std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::emplace\_hint()**, **std::forward\_as\_tuple()**, and **std::piecewise\_construct**.

### template\<typename \_Key , typename \_Tp , typename \_Compare = std::less\<\_Key\>, typename \_Alloc = std::allocator\<std::pair\<const \_Key, \_Tp\> \>\> template\<typename \_Kt \> auto std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::upper\_bound (const \_Kt & \_\_x) -\> decltype(iterator(\_M\_t.\_M\_upper\_bound\_tr(\_\_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\> \>\> template\<typename \_Kt \> auto std::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::upper\_bound (const \_Kt & \_\_x) const -\> decltype(const\_iterator(\_M\_t.\_M\_upper\_bound\_tr(\_\_x)))

	` [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\> \>\> iterator std::map\< \_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::map\< \_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::map\< \_Key, \_Tp, \_Compare, \_Alloc \>::value\_comp () const` [inline]`

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

## Author

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