[#bsl-unordered_map-02b-insert-03]
= xref:bsl.adoc[bsl]::xref:bsl/unordered_map-02b.adoc[unordered&lowbar;map]::insert
:relfileprefix: ../../
:mrdocs:

`insert` overloads

== Synopses

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

Create a `value&lowbar;type` object for each element in the specified `values`&period; Insert into this unordered map each such object whose key is not already contained&period; Note that this method requires that the (template parameter) types `KEY` and `VALUE` both be `copy&hyphen;constructible` (see &lcub;Requirements on `value&lowbar;type`&rcub;)&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
xref:bsl/unordered_map-02b/insert-04.adoc[insert](std::initializer&lowbar;list&lt;value&lowbar;type&gt; values);
----

[.small]#xref:bsl/unordered_map-02b/insert-04.adoc[_» more&period;&period;&period;_]#

Insert the specified `value` into this unordered map if the key (the `first` element) of the object referred to by `value` does not already exist in this unordered map&semi; otherwise, this method has no effect (a `value&lowbar;type` object having the key equivalent to the key of `value` already exists in this unordered map)&period; Return a `pair` whose `first` member is an iterator referring to the (possibly newly inserted) `value&lowbar;type` object in this unordered map whose key is equivalent to that of the object to be inserted, and whose `second` member is `true` if a new value was inserted, and `false` if a value having an equivalent key was already present&period; Note that this method requires that the (template parameter) types `KEY` and `VALUE` both be `copy&hyphen;insertable` into this unordered map (see &lcub;Requirements on `value&lowbar;type`&rcub;)&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/pair-0b.adoc[pair&lt;iterator, bool&gt;]
xref:bsl/unordered_map-02b/insert-028.adoc[insert](xref:bsl/unordered_map-02b/value_type.adoc[value&lowbar;type] const& value);
----

[.small]#xref:bsl/unordered_map-02b/insert-028.adoc[_» more&period;&period;&period;_]#

Insert the specified `value` into this unordered map if the key (the `first` element) of the object referred to by `value` does not already exist in this unordered map&semi; otherwise, this method has no effect (a `value&lowbar;type` object having the same key as the converted `value` already exists in this unordered map) &period; Return a `pair` whose `first` member is an iterator referring to the (possibly newly inserted) `value&lowbar;type` object in this unordered map whose key is the equivalent to that of the object to be inserted, and whose `second` member is `true` if a new value was inserted, and `false` if a value having an equivalent key was already present&period; Note that this method requires that the (template parameter) types `KEY` and `VALUE` both be `move&hyphen;constructible` (see &lcub;Requirements on `value&lowbar;type`&rcub;), and that the `value&lowbar;type` be constructible from the (template parameter) `ALT&lowbar;VALUE&lowbar;TYPE`&period; Also note that this one template stands in for three `insert` functions in the C&plus;&plus;11 standard&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALT&lowbar;VALUE&lowbar;TYPE&gt;
xref:bsl/pair-0b.adoc[pair&lt;iterator, bool&gt;]
xref:bsl/unordered_map-02b/insert-06.adoc[insert](ALT&lowbar;VALUE&lowbar;TYPE&& value)
requires std&colon;&colon;is&lowbar;constructible&lt;value&lowbar;type,
                                             ALT&lowbar;VALUE&lowbar;TYPE&amp;&amp;&gt;&colon;&colon;value;
----

[.small]#xref:bsl/unordered_map-02b/insert-06.adoc[_» more&period;&period;&period;_]#

Insert the specified `value` into this unordered map if the key (the `first` element) of the object referred to by `value` does not already exist in this unordered map&semi; otherwise, this method has no effect (a `value&lowbar;type` object having the key equivalent to the key of `value` already exists in this unordered map)&period; Return an iterator referring to ether the newly inserted `value&lowbar;type` object or to the existing object whose key is equivalent to the key of `value`&period; The average and worst case complexity of this operation is not affected by the specified `hint`&period; This method requires that the (template parameter) types `KEY` and `VALUE` both be `copy&hyphen;insertable` into this unordered map (see &lcub;Requirements on `value&lowbar;type`&rcub;)&period; The behavior is undefined unless `hint` is an iterator in the range `&lsqb;begin() &period;&period; end()&rsqb;` (both endpoints included)&period; Note that `hint` is ignored (other than possibly asserting its validity in some build modes)&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/unordered_map-02b/iterator.adoc[iterator]
xref:bsl/unordered_map-02b/insert-08.adoc[insert](
    xref:bsl/unordered_map-02b/const_iterator.adoc[const&lowbar;iterator] hint,
    xref:bsl/unordered_map-02b/value_type.adoc[value&lowbar;type] const& value);
----

[.small]#xref:bsl/unordered_map-02b/insert-08.adoc[_» more&period;&period;&period;_]#

Create a `value&lowbar;type` object for each iterator in the range starting at the specified `first` iterator and ending immediately before the specified `last` iterator, by converting from the object referred to by each iterator&period; Insert into this unordered map each such object whose key is not already contained&period; The (template parameter) type `INPUT&lowbar;ITERATOR` shall meet the requirements of an input iterator defined in the C&plus;&plus;11 standard &lsqb;24&period;2&period;3&rsqb;providing access to values of a type convertible to `value&lowbar;type`&period; The behavior is undefined unless `first` and `last` refer to a sequence of valid values where `first` is at a position at or before `last`&period; Note that this method requires that the (template parameter) types `KEY` and `VALUE` both be `copy&hyphen;constructible` (see &lcub;Requirements on `value&lowbar;type`&rcub;)&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class INPUT&lowbar;ITERATOR&gt;
void
xref:bsl/unordered_map-02b/insert-0b.adoc[insert](
    INPUT&lowbar;ITERATOR first,
    INPUT&lowbar;ITERATOR last);
----

[.small]#xref:bsl/unordered_map-02b/insert-0b.adoc[_» more&period;&period;&period;_]#

Insert the specified `value` into this unordered map if the key (the `first` element) of the object referred to by `value` does not already exist in this unordered map&semi; otherwise, this method has no effect (a `value&lowbar;type` object having the same key as the converted `value` already exists in this unordered map) &period; Return an iterator referring to ether the newly inserted) `value&lowbar;type` object or to the existing object whose key is equivalent to the key of `value`&period; The average and worst case complexity of this operation is not affected by the specified `hint`&period; This method requires that the (template parameter) types `KEY` and `VALUE` both be `move&hyphen;constructible` (see &lcub;Requirements on `value&lowbar;type`&rcub;) and that the `value&lowbar;type` be constructible from the (template parameter) `ALT&lowbar;VALUE&lowbar;TYPE`&period; The behavior is undefined unless `hint` is an iterator in the range `&lsqb;begin() &period;&period; end()&rsqb;` (both endpoints included)&period; Note that `hint` is ignored (other than possibly asserting its validity in some build modes)&period; Also note that this one template stands in for three `insert` functions in the C&plus;&plus;11 standard&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALT&lowbar;VALUE&lowbar;TYPE&gt;
xref:bsl/unordered_map-02b/iterator.adoc[iterator]
xref:bsl/unordered_map-02b/insert-021.adoc[insert](
    xref:bsl/unordered_map-02b/const_iterator.adoc[const&lowbar;iterator] hint,
    ALT&lowbar;VALUE&lowbar;TYPE&& value)
requires std&colon;&colon;is&lowbar;constructible&lt;value&lowbar;type,
                                             ALT&lowbar;VALUE&lowbar;TYPE&amp;&amp;&gt;&colon;&colon;value;
----

[.small]#xref:bsl/unordered_map-02b/insert-021.adoc[_» more&period;&period;&period;_]#


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