try_emplace overloads

Synopses

Declared in <bslstl_map.h>

Try to emplace an element with a movable key.

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);

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;

Try to emplace an element with key near hint.

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);

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;

Return Value

  • pair of iterator and whether a new element was inserted

  • iterator to the existing or newly inserted element

Parameters

Name

Description

key

key to move into the new element

args

constructor arguments for the mapped value

hint

iterator hint for the insertion position

Created with MrDocs