...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Construct an element in-place.
template< class Arg> std::pair< iterator, bool > emplace( string_view key, Arg&& arg);
Inserts a new element into the container constructed in-place with the
given argument if there is no element with the key
in the container. If the insertion occurs and results in a rehashing of
the container, all iterators and references are invalidated. Otherwise,
they are not affected. Rehashing occurs only if the new number of elements
is greater than capacity()
.
Amortized constant on average, worst case linear in size()
.
Strong guarantee. Calls to memory_resource::allocate
may throw.
A std::pair
where first
is an iterator to the existing or inserted element, and second
is true
if the insertion took
place or false
otherwise.
Name |
Description |
---|---|
|
The key used for lookup and insertion |
|
The argument used to construct the value. This will be passed
as |
Type |
Thrown On |
---|---|
|
if key is too long |