Boost C++ Libraries Home Libraries People FAQ More

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>::value_type>
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