Insert a convertible value near hint if its key is absent.

Synopsis

Declared in <bslstl_map.h>

template<class ALT_VALUE_TYPE>
iterator
insert(
    const_iterator hint,
    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 (in amortized constant time if the specified hint is a valid immediate successor to the object created from value) if a key (the first element) equivalent to 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 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. If hint is not a valid immediate successor to the object created from value, this operation has O[log(N)] complexity, where N is the size of this map. 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. The behavior is undefined unless hint is an iterator in the range [begin() .. end()] (both endpoints included).

Return Value

iterator to the existing or newly inserted element

Parameters

Name

Description

hint

iterator hint for the insertion position

value

value used to construct the inserted element

Created with MrDocs