[#bsl-map-0a7]
= xref:bsl.adoc[bsl]::map
:relfileprefix: ../
:mrdocs:

Ordered associative container mapping unique keys to values&period;

== Synopsis

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

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

== Description

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;

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-0a7/value_compare.adoc[`value&lowbar;compare`] 
| Adaptor that compares `value&lowbar;type` objects by their keys&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:bsl/map-0a7/allocator_type.adoc[`allocator&lowbar;type`] 
| Alias for the allocator type `ALLOCATOR`&period;
| xref:bsl/map-0a7/const_iterator.adoc[`const&lowbar;iterator`] 
| Constant bidirectional iterator over `map` elements&period;
| xref:bsl/map-0a7/const_pointer.adoc[`const&lowbar;pointer`] 
| Alias for the const pointer type supplied by the allocator traits&period;
| xref:bsl/map-0a7/const_reference.adoc[`const&lowbar;reference`] 
| Alias for a constant reference to a map element&period;
| xref:bsl/map-0a7/const_reverse_iterator.adoc[`const&lowbar;reverse&lowbar;iterator`] 
| Reverse iterator type for traversing the map in reverse order&period;
| xref:bsl/map-0a7/difference_type.adoc[`difference&lowbar;type`] 
| Signed integer type measuring iterator distance&period;
| xref:bsl/map-0a7/iterator.adoc[`iterator`] 
| Bidirectional iterator over `map` elements&period;
| xref:bsl/map-0a7/key_compare.adoc[`key&lowbar;compare`] 
| Alias for the key&hyphen;comparison functor type `COMPARATOR`&period;
| xref:bsl/map-0a7/key_type.adoc[`key&lowbar;type`] 
| Alias for the key type `KEY`&period;
| xref:bsl/map-0a7/mapped_type.adoc[`mapped&lowbar;type`] 
| Alias for the mapped value type `VALUE`&period;
| xref:bsl/map-0a7/pointer.adoc[`pointer`] 
| Alias for the pointer type supplied by the allocator traits&period;
| xref:bsl/map-0a7/reference.adoc[`reference`] 
| Alias for a modifiable reference to a map element&period;
| xref:bsl/map-0a7/reverse_iterator.adoc[`reverse&lowbar;iterator`] 
| Reverse iterator over `map` elements&period;
| xref:bsl/map-0a7/size_type.adoc[`size&lowbar;type`] 
| Alias for the size type supplied by the allocator traits&period;
| xref:bsl/map-0a7/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-0a7/2constructor-0bc.adoc[`map`]         [.small]#[constructor]#
| Constructors
| xref:bsl/map-0a7/2destructor.adoc[`&#126;map`] [.small]#[destructor]#
| Destroy this object&period;
| xref:bsl/map-0a7/operator_assign-0c.adoc[`operator&equals;`] 
| Assignment operators
| xref:bsl/map-0a7/at-0a.adoc[`at`] 
| `at` overloads
| xref:bsl/map-0a7/begin-0f.adoc[`begin`] 
| `begin` overloads
| xref:bsl/map-0a7/cbegin.adoc[`cbegin`] 
| Return a const iterator to the first element, or `cend` if empty&period;
| xref:bsl/map-0a7/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-0a7/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-0a7/contains-06.adoc[`contains`] 
| Return whether this map contains an element equivalent to `key`&period;
| xref:bsl/map-0a7/count-05.adoc[`count`] 
| Return the number of elements equivalent to `key`&period;
| xref:bsl/map-0a7/crbegin.adoc[`crbegin`] 
| Return a const reverse iterator to the last element, or `crend` if empty&period;
| xref:bsl/map-0a7/crend.adoc[`crend`] 
| Return a const reverse iterator to prior&hyphen;to&hyphen;beginning&period;
| xref:bsl/map-0a7/emplace.adoc[`emplace`] 
| Emplace a newly constructed element into this map&period;
| xref:bsl/map-0a7/emplace_hint.adoc[`emplace&lowbar;hint`] 
| Emplace a newly constructed element near `hint`&period;
| xref:bsl/map-0a7/empty.adoc[`empty`] 
| Return `true` if this map contains no elements, and `false` otherwise&period;
| xref:bsl/map-0a7/end-06.adoc[`end`] 
| `end` overloads
| xref:bsl/map-0a7/equal_range-0e.adoc[`equal&lowbar;range`] 
| Return the half&hyphen;open range of elements equivalent to `key`&period;
| xref:bsl/map-0a7/erase-0d.adoc[`erase`] 
| `erase` overloads
| xref:bsl/map-0a7/find-08.adoc[`find`] 
| `find` overloads
| xref:bsl/map-0a7/get_allocator.adoc[`get&lowbar;allocator`] 
| Return (a copy of) the allocator used for memory allocation by this map&period;
| xref:bsl/map-0a7/insert-03.adoc[`insert`] 
| `insert` overloads
| xref:bsl/map-0a7/insert_or_assign-0f.adoc[`insert&lowbar;or&lowbar;assign`] 
| `insert&lowbar;or&lowbar;assign` overloads
| xref:bsl/map-0a7/insert_range.adoc[`insert&lowbar;range`] 
| Insert elements from `range` whose keys are not already present&period;
| xref:bsl/map-0a7/key_comp.adoc[`key&lowbar;comp`] 
| Return the key&hyphen;comparison functor used by this map&period;
| xref:bsl/map-0a7/lower_bound-03.adoc[`lower&lowbar;bound`] 
| `lower&lowbar;bound` overloads
| xref:bsl/map-0a7/max_size.adoc[`max&lowbar;size`] 
| Return a theoretical upper bound on the size of this map&period;
| xref:bsl/map-0a7/operator_subs-0e4.adoc[`operator&lsqb;&rsqb;`] 
| Subscript operators
| xref:bsl/map-0a7/rbegin-01.adoc[`rbegin`] 
| `rbegin` overloads
| xref:bsl/map-0a7/rend-0d8.adoc[`rend`] 
| `rend` overloads
| xref:bsl/map-0a7/size.adoc[`size`] 
| Return the number of elements in this map&period;
| xref:bsl/map-0a7/swap.adoc[`swap`] 
| Exchange the value and comparator with `other`&period;
| xref:bsl/map-0a7/try_emplace-0c.adoc[`try&lowbar;emplace`] 
| `try&lowbar;emplace` overloads
| xref:bsl/map-0a7/upper_bound-00.adoc[`upper&lowbar;bound`] 
| `upper&lowbar;bound` overloads
| xref:bsl/map-0a7/value_comp.adoc[`value&lowbar;comp`] 
| Return a functor that compares two `value&lowbar;type` objects by key&period;
|===


== Deduction Guides

[cols="1,4"]
|===
| Name| Description
| xref:bsl/map-0da.adoc[`map&lt;KEY, VALUE&gt;`] 
| Deduce `KEY` and `VALUE` from an initializer&hyphen;list constructor argument&period;
| xref:bsl/map-0b.adoc[`map&lt;KEY, VALUE&gt;`] 
| Deduce `KEY` and `VALUE` from iterator&hyphen;pair construction with a pointer allocator&period;
| xref:bsl/map-06.adoc[`map&lt;KEY, VALUE, COMPARATOR&gt;`] 
| Deduce `KEY`, `VALUE`, and `COMPARATOR` from initializer&hyphen;list construction&period;
| xref:bsl/map-0ac.adoc[`map&lt;KEY, VALUE, COMPARATOR&gt;`] 
| Deduce `KEY`, `VALUE`, and `COMPARATOR` from iterator&hyphen;pair construction&period;
| xref:bsl/map-0d4.adoc[`map&lt;KEY, VALUE, COMPARATOR, ALLOCATOR&gt;`] 
| Deduce `KEY`, `VALUE`, `COMPARATOR`, and `ALLOCATOR` from initializer&hyphen;list construction&period;
| xref:bsl/map-03.adoc[`map&lt;KEY, VALUE, COMPARATOR, ALLOCATOR&gt;`] 
| Deduce `KEY`, `VALUE`, `COMPARATOR`, and `ALLOCATOR` from iterator&hyphen;pair construction&period;
| xref:bsl/map-0cb.adoc[`map&lt;KEY, VALUE, std::less&lt;KEY&gt;, ALLOCATOR&gt;`] 
| Deduce `KEY`, `VALUE`, and `ALLOCATOR` from initializer&hyphen;list construction&period;
| xref:bsl/map-02.adoc[`map&lt;KEY, VALUE, std::less&lt;KEY&gt;, ALLOCATOR&gt;`] 
| Deduce `KEY`, `VALUE`, and `ALLOCATOR` from iterator&hyphen;pair construction&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/erase_if-01.adoc[`erase&lowbar;if`]
| Erase every element of `m` that satisfies `predicate`&period;
| xref:bsl/operator_3way-044.adoc[`operator&lt;&equals;&gt;`]
| Perform a lexicographic three&hyphen;way comparison of `lhs` and `rhs`&period;
| xref:bsl/operator_eq-04b.adoc[`operator&equals;&equals;`]
| Return `true` if `lhs` and `rhs` have the same value&period;
| xref:bsl/swap-0cc.adoc[`swap`]
| Exchange the value and comparator of `a` with those of `b`&period;
|===


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