[#bsl-map-0c7]
= xref:bsl.adoc[bsl]::xref:bsl/map-0a7.adoc[map]&lt;int, xref:bsl/pair-0b.adoc[pair&lt;shared&lowbar;ptr&lt;Statistics&gt;, shared&lowbar;ptr&lt;Collector&lt;OsLinux&gt;&gt;&gt;]&gt;
:relfileprefix: ../
:mrdocs:

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

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;&gt;
class xref:bsl/map-0a7.adoc[map]&lt;int, xref:bsl/pair-0b.adoc[pair&lt;shared&lowbar;ptr&lt;Statistics&gt;, shared&lowbar;ptr&lt;Collector&lt;OsLinux&gt;&gt;&gt;]&gt;;
----

== Description

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

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

== Types

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


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:bsl/map-0c7/allocator_type.adoc[`allocator&lowbar;type`] 
| Alias for the allocator type `ALLOCATOR`&period;
| xref:bsl/map-0c7/const_iterator.adoc[`const&lowbar;iterator`] 
| Constant bidirectional iterator over `map` elements&period;
| xref:bsl/map-0c7/const_pointer.adoc[`const&lowbar;pointer`] 
| Alias for the const pointer type supplied by the allocator traits&period;
| xref:bsl/map-0c7/const_reference.adoc[`const&lowbar;reference`] 
| Alias for a constant reference to a map element&period;
| xref:bsl/map-0c7/const_reverse_iterator.adoc[`const&lowbar;reverse&lowbar;iterator`] 
| Reverse iterator type for traversing the map in reverse order&period;
| xref:bsl/map-0c7/difference_type.adoc[`difference&lowbar;type`] 
| Signed integer type measuring iterator distance&period;
| xref:bsl/map-0c7/iterator.adoc[`iterator`] 
| Bidirectional iterator over `map` elements&period;
| xref:bsl/map-0c7/key_compare.adoc[`key&lowbar;compare`] 
| Alias for the key&hyphen;comparison functor type `COMPARATOR`&period;
| xref:bsl/map-0c7/key_type.adoc[`key&lowbar;type`] 
| Alias for the key type `KEY`&period;
| xref:bsl/map-0c7/mapped_type.adoc[`mapped&lowbar;type`] 
| Alias for the mapped value type `VALUE`&period;
| xref:bsl/map-0c7/pointer.adoc[`pointer`] 
| Alias for the pointer type supplied by the allocator traits&period;
| xref:bsl/map-0c7/reference.adoc[`reference`] 
| Alias for a modifiable reference to a map element&period;
| xref:bsl/map-0c7/reverse_iterator.adoc[`reverse&lowbar;iterator`] 
| Reverse iterator over `map` elements&period;
| xref:bsl/map-0c7/size_type.adoc[`size&lowbar;type`] 
| Alias for the size type supplied by the allocator traits&period;
| xref:bsl/map-0c7/value_type.adoc[`value&lowbar;type`] 
| Alias for the map element type `pair&lt;const KEY, VALUE&gt;`&period;
|===


== Member Functions

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



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