...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Insert elements before the specified location.
template< class InputIt> iterator insert( const_iterator pos, InputIt first, InputIt last);
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.
first
and last
are not iterators into *this
.
not std::is_convertible_v<InputIt, value>
std::is_constructible_v<value, std::iterator_traits<InputIt>::reference>
Linear in std::distance(first, last) + std::distance(pos, end())
.
Strong guarantee. Calls to memory_resource::allocate
may throw.
An iterator to the first inserted value, or pos
if first ==
last
.
Name |
Description |
---|---|
|
Iterator before which the content will be inserted. This may
be the |
|
An input iterator pointing to the first element to insert, or pointing to the end of the range. |
|
An input iterator pointing to the end of the range. |
Type |
Description |
---|---|
|
a type satisfying the requirements of InputIterator. |