object::insert
Insert elements.
Synopsis
template<
class P>
std::pair< object::iterator, bool >
insert(
P&& p); (1)
template<
class InputIt>
void
insert(
InputIt first,
InputIt last); (2)
void
insert(
std::initializer_list< std::pair< string_view, value_ref > > init); (3)
Description
Inserts p
if this->contains(value_type(p).key())
is false
. value_type
must be constructible from p
.
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()
.
Constraints
std::is_constructible_v<value_type, P>
Complexity
Average case amortized constant, worst case linear in size()
.
Exception Safety
Strong guarantee. Calls to memory_resource::allocate
may throw.
Template Parameters
Type | Description |
---|---|
|
a type satisfying the requirements of InputIterator. |
Return Value
A pair where first
is an iterator to the existing or inserted element, and second
is true
if the insertion took place or false
otherwise.
Parameters
Name | Description |
---|---|
|
The value to insert. |
|
An input iterator pointing to the first element to insert, or pointing to the end of the range. |
|
An input iterator pointing to the end of the range. |
|
The initializer list to insert |
Exceptions
Type | Thrown On |
---|---|
|
key is too long. |