[#bsl-map-0a7-try_emplace-0c]
= xref:bsl.adoc[bsl]::xref:bsl/map-0a7.adoc[map]::try&lowbar;emplace
:relfileprefix: ../../
:mrdocs:

`try&lowbar;emplace` overloads

== Synopses

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

Try to emplace an element with a movable `key`&period;


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

[.small]#xref:bsl/map-0a7/try_emplace-0de.adoc[_» more&period;&period;&period;_]#

Try to emplace an element with `key` constructed from `args`&period;


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

[.small]#xref:bsl/map-0a7/try_emplace-0be.adoc[_» more&period;&period;&period;_]#

Try to emplace an element with transparent `key`&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/map-0a7/try_emplace-08.adoc[try&lowbar;emplace](
    LOOKUP&lowbar;KEY&& key,
    Args&&&period;&period;&period; args)
requires BloombergLP&colon;&colon;bslmf&colon;&colon;IsTransparentPredicate&lt;COMPARATOR,
                                                   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/map-0a7/try_emplace-08.adoc[_» more&period;&period;&period;_]#

Try to emplace an element with `key` near `hint`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class&period;&period;&period; Args&gt;
xref:bsl/map-0a7/iterator.adoc[map&lt;KEY, VALUE, COMPARATOR, ALLOCATOR&gt;::iterator]
xref:bsl/map-0a7/try_emplace-0b7.adoc[try&lowbar;emplace](
    xref:bsl/map-0a7/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/map-0a7/try_emplace-0b7.adoc[_» more&period;&period;&period;_]#

Try to emplace an element with `key` near `hint`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class&period;&period;&period; Args&gt;
xref:bsl/map-0a7/iterator.adoc[map&lt;KEY, VALUE, COMPARATOR, ALLOCATOR&gt;::iterator]
xref:bsl/map-0a7/try_emplace-0d6.adoc[try&lowbar;emplace](
    xref:bsl/map-0a7/const_iterator.adoc[const&lowbar;iterator] hint,
    KEY const& key,
    Args&&&period;&period;&period; args);
----

[.small]#xref:bsl/map-0a7/try_emplace-0d6.adoc[_» more&period;&period;&period;_]#

Try to emplace an element with transparent `key` near `hint`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class LOOKUP&lowbar;KEY,
    class&period;&period;&period; Args&gt;
xref:bsl/map-0a7/iterator.adoc[iterator]
xref:bsl/map-0a7/try_emplace-04.adoc[try&lowbar;emplace](
    xref:bsl/map-0a7/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;COMPARATOR,
                                                   LOOKUP&lowbar;KEY&gt;&colon;&colon;value;
----

[.small]#xref:bsl/map-0a7/try_emplace-04.adoc[_» more&period;&period;&period;_]#

== Return Value

* pair of iterator and whether a new element was inserted
* iterator to the existing or newly inserted element

== Parameters

[cols="1,4"]
|===
| Name| Description
| *key*
| key to move into the new element
| *args*
| constructor arguments for the mapped value
| *hint*
| iterator hint for the insertion position
|===


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