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 an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
object::insert (1 of 3 overloads)

Insert elements.

Synopsis
template<
    class P>
std::pair< iterator, bool >
insert(
    P&& p);
Description

Inserts p, from which value_type must be constructible.

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

std::length_error

key is too long.

std::length_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 if the assignment took place.


PrevUpHomeNext