Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
object::insert (2 of 3 overloads)

Insert elements.

Synopsis
template<
    class InputIt>
void
insert(
    InputIt first,
    InputIt last);
Description

The elements in the range [first, last) are inserted one at a time, in order. Any element with key that is a duplicate of a key already present in container will be skipped. This also means, that if there are two keys within the range that are equal to each other, only the first will be inserted. If the size necessary to accomodate elements from the range exceeds capacity(), a rehashing can occur. In that case all iterators and references are invalidated. Otherwise, they are not affected.

Precondition

first and last are not iterators into *this. first and last form a valid range.

Constraints
std::is_constructible_v<value_type, std::iterator_traits<InputIt>::value_type>
Complexity

Linear in std::distance(first, last).

Exception Safety

Basic guarantee. Calls to memory_resource::allocate may throw.

Parameters

Name

Description

first

An input iterator pointing to the first element to insert, or pointing to the end of the range.

last

An input iterator pointing to the end of the range.

Template Parameters

Type

Description

InputIt

a type satisfying the requirements of InputIterator.


PrevUpHomeNext