bsl::map::try_emplace

try_emplace overloads

Synopses

Declared in <bslstl_map.h>

Try to emplace an element with a movable key.

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

Try to emplace an element with key constructed from args.

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

Try to emplace an element with transparent key.

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

Try to emplace an element with key near hint.

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

Try to emplace an element with key near hint.

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

Try to emplace an element with transparent key near hint.

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

Return Value

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

Parameters

NameDescription
keykey to move into the new element
argsconstructor arguments for the mapped value
hintiterator hint for the insertion position