Insert an element constructed from value if its key is absent.

Synopsis

Declared in <bslstl_map.h>

template<class ALT_VALUE_TYPE>
pair<iterator, bool>
insert(ALT_VALUE_TYPE&& value)
requires std::is_constructible<value_type,
                                             ALT_VALUE_TYPE&&>::value;

Description

Insert into this map a value_type object created from the specified value if a key (the first element) equivalent to that of such an object does not already exist in this map; otherwise, this method has no effect (other than possibly creating a temporary value_type object). Return a pair whose first member is an iterator referring to the (possibly newly inserted) value_type object in this map whose key is equivalent to that of the object created from value, and whose second member is true if a new value was inserted and false if the key was already present. This method requires that the (template parameter) types KEY and VALUE both be move‐insertable into this map (see {Requirements on KEY and VALUE}), and the value_type be constructible from the (template parameter) ALT_VALUE_TYPE.

Return Value

pair of iterator and whether a new element was inserted

Parameters

Name

Description

value

value used to construct the inserted element

Created with MrDocs