Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the master branch, built from commit 064f557086.
PrevUpHomeNext
object::insert (1 of 3 overloads)

Insert elements.

Synopsis
template<
    class P>
std::pair< iterator, bool >
insert(
    P&& p);
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.

Parameters

Name

Description

p

The value to insert.

Exceptions

Type

Thrown On

boost::system::system_error

key is too long.

boost::system::system_error

size() >= max_size().

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.


PrevUpHomeNext