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 7789ef3d8d.
PrevUpHomeNext
array::insert (4 of 5 overloads)

Insert elements before the specified location.

Synopsis
template<
    class InputIt>
iterator
insert(
    const_iterator pos,
    InputIt first,
    InputIt last);
Description

The elements in the range {first, last) are inserted in order. If capacity() < size() + std::distance(first, last), a reallocation occurs first, and all iterators and references are invalidated. Otherwise, only the iterators and references from the insertion point forward are invalidated. All past-the-end iterators are also invalidated.

Precondition

first and last are not iterators into *this.

Constraints
not std::is_convertible_v<InputIt, value>
Mandates
std::is_constructible_v<value, std::iterator_traits<InputIt>::reference>
Complexity

Linear in std::distance(first, last) + std::distance(pos, end()).

Exception Safety

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

Return Value

An iterator to the first inserted value, or pos if first == last.

Parameters

Name

Description

pos

Iterator before which the content will be inserted. This may be the end() iterator.

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