[#bsl-map-0a7] = xref:bsl.adoc[bsl]::map :relfileprefix: ../ :mrdocs: Ordered associative container mapping unique keys to values. == Synopsis Declared in `<bslstl_map.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class KEY, class VALUE, class COMPARATOR = std::less<KEY>, class ALLOCATOR = xref:bsl/allocator-0df.adoc[allocator<pair<KEY const, VALUE>>]> class map; ---- == Description This class template implements a value‐semantic container type holding an ordered sequence of key‐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`). This class: * supports a complete set of _value‐semantic_ operations * except for BDEX serialization * is _exception‐neutral_ * is _alias‐safe_ * is `const` _thread‐safe_ For terminology see {`bsldoc_glossary`}. == Types [cols="1,4"] |=== | Name| Description | xref:bsl/map-0a7/value_compare.adoc[`value_compare`] | Adaptor that compares `value_type` objects by their keys. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:bsl/map-0a7/allocator_type.adoc[`allocator_type`] | Alias for the allocator type `ALLOCATOR`. | xref:bsl/map-0a7/const_iterator.adoc[`const_iterator`] | Constant bidirectional iterator over `map` elements. | xref:bsl/map-0a7/const_pointer.adoc[`const_pointer`] | Alias for the const pointer type supplied by the allocator traits. | xref:bsl/map-0a7/const_reference.adoc[`const_reference`] | Alias for a constant reference to a map element. | xref:bsl/map-0a7/const_reverse_iterator.adoc[`const_reverse_iterator`] | Reverse iterator type for traversing the map in reverse order. | xref:bsl/map-0a7/difference_type.adoc[`difference_type`] | Signed integer type measuring iterator distance. | xref:bsl/map-0a7/iterator.adoc[`iterator`] | Bidirectional iterator over `map` elements. | xref:bsl/map-0a7/key_compare.adoc[`key_compare`] | Alias for the key‐comparison functor type `COMPARATOR`. | xref:bsl/map-0a7/key_type.adoc[`key_type`] | Alias for the key type `KEY`. | xref:bsl/map-0a7/mapped_type.adoc[`mapped_type`] | Alias for the mapped value type `VALUE`. | xref:bsl/map-0a7/pointer.adoc[`pointer`] | Alias for the pointer type supplied by the allocator traits. | xref:bsl/map-0a7/reference.adoc[`reference`] | Alias for a modifiable reference to a map element. | xref:bsl/map-0a7/reverse_iterator.adoc[`reverse_iterator`] | Reverse iterator over `map` elements. | xref:bsl/map-0a7/size_type.adoc[`size_type`] | Alias for the size type supplied by the allocator traits. | xref:bsl/map-0a7/value_type.adoc[`value_type`] | Alias for the map element type `pair<const KEY, VALUE>`. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/map-0a7/2constructor-0bc.adoc[`map`] [.small]#[constructor]# | Constructors | xref:bsl/map-0a7/2destructor.adoc[`~map`] [.small]#[destructor]# | Destroy this object. | xref:bsl/map-0a7/operator_assign-0c.adoc[`operator=`] | 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. | xref:bsl/map-0a7/cend.adoc[`cend`] | Return an iterator providing non‐modifiable access to the past‐the‐end element in the ordered sequence of `value_type` objects maintained by this map. | xref:bsl/map-0a7/clear.adoc[`clear`] | Remove all entries from this map. Note that the map is empty after this call, but allocated memory may be retained for future use. | xref:bsl/map-0a7/contains-06.adoc[`contains`] | Return whether this map contains an element equivalent to `key`. | xref:bsl/map-0a7/count-05.adoc[`count`] | Return the number of elements equivalent to `key`. | xref:bsl/map-0a7/crbegin.adoc[`crbegin`] | Return a const reverse iterator to the last element, or `crend` if empty. | xref:bsl/map-0a7/crend.adoc[`crend`] | Return a const reverse iterator to prior‐to‐beginning. | xref:bsl/map-0a7/emplace.adoc[`emplace`] | Emplace a newly constructed element into this map. | xref:bsl/map-0a7/emplace_hint.adoc[`emplace_hint`] | Emplace a newly constructed element near `hint`. | xref:bsl/map-0a7/empty.adoc[`empty`] | Return `true` if this map contains no elements, and `false` otherwise. | xref:bsl/map-0a7/end-06.adoc[`end`] | `end` overloads | xref:bsl/map-0a7/equal_range-0e.adoc[`equal_range`] | Return the half‐open range of elements equivalent to `key`. | 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_allocator`] | Return (a copy of) the allocator used for memory allocation by this map. | xref:bsl/map-0a7/insert-03.adoc[`insert`] | `insert` overloads | xref:bsl/map-0a7/insert_or_assign-0f.adoc[`insert_or_assign`] | `insert_or_assign` overloads | xref:bsl/map-0a7/insert_range.adoc[`insert_range`] | Insert elements from `range` whose keys are not already present. | xref:bsl/map-0a7/key_comp.adoc[`key_comp`] | Return the key‐comparison functor used by this map. | xref:bsl/map-0a7/lower_bound-03.adoc[`lower_bound`] | `lower_bound` overloads | xref:bsl/map-0a7/max_size.adoc[`max_size`] | Return a theoretical upper bound on the size of this map. | xref:bsl/map-0a7/operator_subs-0e4.adoc[`operator[]`] | 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. | xref:bsl/map-0a7/swap.adoc[`swap`] | Exchange the value and comparator with `other`. | xref:bsl/map-0a7/try_emplace-0c.adoc[`try_emplace`] | `try_emplace` overloads | xref:bsl/map-0a7/upper_bound-00.adoc[`upper_bound`] | `upper_bound` overloads | xref:bsl/map-0a7/value_comp.adoc[`value_comp`] | Return a functor that compares two `value_type` objects by key. |=== == Deduction Guides [cols="1,4"] |=== | Name| Description | xref:bsl/map-0da.adoc[`map<KEY, VALUE>`] | Deduce `KEY` and `VALUE` from an initializer‐list constructor argument. | xref:bsl/map-0b.adoc[`map<KEY, VALUE>`] | Deduce `KEY` and `VALUE` from iterator‐pair construction with a pointer allocator. | xref:bsl/map-06.adoc[`map<KEY, VALUE, COMPARATOR>`] | Deduce `KEY`, `VALUE`, and `COMPARATOR` from initializer‐list construction. | xref:bsl/map-0ac.adoc[`map<KEY, VALUE, COMPARATOR>`] | Deduce `KEY`, `VALUE`, and `COMPARATOR` from iterator‐pair construction. | xref:bsl/map-0d4.adoc[`map<KEY, VALUE, COMPARATOR, ALLOCATOR>`] | Deduce `KEY`, `VALUE`, `COMPARATOR`, and `ALLOCATOR` from initializer‐list construction. | xref:bsl/map-03.adoc[`map<KEY, VALUE, COMPARATOR, ALLOCATOR>`] | Deduce `KEY`, `VALUE`, `COMPARATOR`, and `ALLOCATOR` from iterator‐pair construction. | xref:bsl/map-0cb.adoc[`map<KEY, VALUE, std::less<KEY>, ALLOCATOR>`] | Deduce `KEY`, `VALUE`, and `ALLOCATOR` from initializer‐list construction. | xref:bsl/map-02.adoc[`map<KEY, VALUE, std::less<KEY>, ALLOCATOR>`] | Deduce `KEY`, `VALUE`, and `ALLOCATOR` from iterator‐pair construction. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/erase_if-01.adoc[`erase_if`] | Erase every element of `m` that satisfies `predicate`. | xref:bsl/operator_3way-044.adoc[`operator<=>`] | Perform a lexicographic three‐way comparison of `lhs` and `rhs`. | xref:bsl/operator_eq-04b.adoc[`operator==`] | Return `true` if `lhs` and `rhs` have the same value. | xref:bsl/swap-0cc.adoc[`swap`] | Exchange the value and comparator of `a` with those of `b`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#