[#bsl-unordered_map-02b-try_emplace-050]
= xref:bsl.adoc[bsl]::xref:bsl/unordered_map-02b.adoc[unordered&lowbar;map]::try&lowbar;emplace
:relfileprefix: ../../
:mrdocs:

`try&lowbar;emplace` overloads

== Synopses

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

Emplace a value for movable `key` if missing&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class&period;&period;&period; Args&gt;
xref:bsl/pair-0b.adoc[pair&lt;iterator, bool&gt;]
xref:bsl/unordered_map-02b/try_emplace-09b.adoc[try&lowbar;emplace](
    xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef&lt;KEY&gt;] key,
    Args&&&period;&period;&period; args);
----

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

Emplace a value for `key` if no equivalent key already exists&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class&period;&period;&period; Args&gt;
xref:bsl/pair-0b.adoc[pair&lt;iterator, bool&gt;]
xref:bsl/unordered_map-02b/try_emplace-02.adoc[try&lowbar;emplace](
    KEY const& key,
    Args&&&period;&period;&period; args);
----

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

Emplace a value for transparent `key` if missing&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class LOOKUP&lowbar;KEY,
    class&period;&period;&period; Args&gt;
xref:bsl/pair-0b.adoc[pair&lt;iterator, bool&gt;]
xref:bsl/unordered_map-02b/try_emplace-07.adoc[try&lowbar;emplace](
    LOOKUP&lowbar;KEY&& key,
    Args&&&period;&period;&period; args)
requires BloombergLP&colon;&colon;bslmf&colon;&colon;IsTransparentPredicate&lt;HASH, LOOKUP&lowbar;KEY&gt;&colon;&colon;value
        &amp;&amp; BloombergLP&colon;&colon;bslmf&colon;&colon;IsTransparentPredicate&lt;EQUAL,LOOKUP&lowbar;KEY&gt;&colon;&colon;value
        &amp;&amp; !bsl&colon;&colon;is&lowbar;convertible&lt;LOOKUP&lowbar;KEY&amp;&amp;, const&lowbar;iterator&gt;&colon;&colon;value
        &amp;&amp; !bsl&colon;&colon;is&lowbar;convertible&lt;LOOKUP&lowbar;KEY&amp;&amp;, iterator&gt;&colon;&colon;value;
----

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

Emplace a value for movable `key` at `hint` if missing&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class&period;&period;&period; Args&gt;
xref:bsl/unordered_map-02b/iterator.adoc[iterator]
xref:bsl/unordered_map-02b/try_emplace-09d.adoc[try&lowbar;emplace](
    xref:bsl/unordered_map-02b/const_iterator.adoc[const&lowbar;iterator] hint,
    xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef&lt;KEY&gt;] key,
    Args&&&period;&period;&period; args);
----

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

Emplace a value for `key` at `hint` if missing&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class&period;&period;&period; Args&gt;
xref:bsl/unordered_map-02b/iterator.adoc[iterator]
xref:bsl/unordered_map-02b/try_emplace-05e.adoc[try&lowbar;emplace](
    xref:bsl/unordered_map-02b/const_iterator.adoc[const&lowbar;iterator] hint,
    KEY const& key,
    Args&&&period;&period;&period; args);
----

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

Emplace with transparent lookup key at `hint`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class LOOKUP&lowbar;KEY,
    class&period;&period;&period; Args&gt;
xref:bsl/unordered_map-02b/iterator.adoc[iterator]
xref:bsl/unordered_map-02b/try_emplace-0f.adoc[try&lowbar;emplace](
    xref:bsl/unordered_map-02b/const_iterator.adoc[const&lowbar;iterator] hint,
    LOOKUP&lowbar;KEY&& key,
    Args&&&period;&period;&period; args)
requires BloombergLP&colon;&colon;bslmf&colon;&colon;IsTransparentPredicate&lt;HASH, LOOKUP&lowbar;KEY&gt;&colon;&colon;value
        &amp;&amp; BloombergLP&colon;&colon;bslmf&colon;&colon;IsTransparentPredicate&lt;EQUAL,LOOKUP&lowbar;KEY&gt;&colon;&colon;value;
----

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

== Return Value

* iterator to the element and whether insertion occurred
* iterator to the existing or newly inserted element

== Parameters

[cols="1,4"]
|===
| Name| Description
| *key*
| key to look up
| *args*
| constructor arguments for the new element
| *hint*
| iterator hint for insertion
|===


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