absl::linked_hash_map::try_emplace

try_emplace overloads

Synopses

Declared in <absl/container/linked_hash_map.h>

Constructs an element in place if the key is not already present.

template<
    class K = key_type,
    typename... Args>
std::pair<iterator, bool>
try_emplace(
    key_arg<K> const& key,
    Args&&... args);
» more...

Constructs an element in place if the key is not already present.

template<
    class K = key_type,
    typename... Args,
    K* = nullptr>
std::pair<iterator, bool>
try_emplace(
    key_arg<K>&& key,
    Args&&... args);
» more...

Constructs an element in place if the key is not present, ignoring the position hint.

template<
    class K = key_type,
    typename... Args>
iterator
try_emplace(
    const_iterator hint,
    key_arg<K> const& key,
    Args&&... args);
» more...

Constructs an element in place if the key is not present, ignoring the position hint.

template<
    class K = key_type,
    class... Args,
    K* = nullptr>
iterator
try_emplace(
    const_iterator hint,
    key_arg<K>&& k,
    Args&&... args);
» more...

Return Value

  • A pair of an iterator to the element and a bool that is true if insertion took place.
  • An iterator to the inserted or existing element.

Parameters

NameDescription
keyThe key to insert or look up.
argsThe arguments used to construct the mapped value.
hintA position hint, which is ignored.
kThe key to insert or look up.