bsl::unordered_map::try_emplace

try_emplace overloads

Synopses

Declared in <bslstl_unorderedmap.h>

Emplace a value for movable key if missing.

template<class... Args>
pair<iterator, bool>
try_emplace(
    BloombergLP::bslmf::MovableRef<KEY> key,
    Args&&... args);
» more...

Emplace a value for key if no equivalent key already exists.

template<class... Args>
pair<iterator, bool>
try_emplace(
    KEY const& key,
    Args&&... args);
» more...

Emplace a value for transparent key if missing.

template<
    class LOOKUP_KEY,
    class... Args>
pair<iterator, bool>
try_emplace(
    LOOKUP_KEY&& key,
    Args&&... args)
requires BloombergLP::bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
        && BloombergLP::bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value
        && !bsl::is_convertible<LOOKUP_KEY&&, const_iterator>::value
        && !bsl::is_convertible<LOOKUP_KEY&&, iterator>::value;
» more...

Emplace a value for movable key at hint if missing.

template<class... Args>
iterator
try_emplace(
    const_iterator hint,
    BloombergLP::bslmf::MovableRef<KEY> key,
    Args&&... args);
» more...

Emplace a value for key at hint if missing.

template<class... Args>
iterator
try_emplace(
    const_iterator hint,
    KEY const& key,
    Args&&... args);
» more...

Emplace with transparent lookup key at hint.

template<
    class LOOKUP_KEY,
    class... Args>
iterator
try_emplace(
    const_iterator hint,
    LOOKUP_KEY&& key,
    Args&&... args)
requires BloombergLP::bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
        && BloombergLP::bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value;
» more...

Return Value

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

Parameters

NameDescription
keykey to look up
argsconstructor arguments for the new element
hintiterator hint for insertion