(C++17) | ||||
| Sequence | ||||
(C++11) | ||||
(C++26) | ||||
(C++26) | ||||
(C++11) | ||||
| Associative | ||||
| Unordered associative | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Adaptors | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
| Views | ||||
(C++20) | ||||
(C++23) | ||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
| Member types | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Non-member functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
template<container-compatible-range<T> R> constexpr iterator insert_range( const_iterator pos, R&& rg); | (since C++26) | |
Inserts, in non-reversing order, copies of elements inrg beforepos.
| This section is incomplete |
Each iterator in the rangerg is dereferenced exactly once.
Ifrg overlaps with*this, the behavior is undefined.
Contents |
| pos | - | iterator before which the content will be inserted (pos may be theend() iterator) |
| rg | - | acontainer compatible range, that is, aninput_range whose elements are convertible toT |
| Type requirements | ||
-If any of the following conditions is satisfied, the behavior is undefined:
| ||
An iterator to the first element inserted into*this, orpos ifrg is empty.
T) or by anyLegacyInputIterator operation. The elements of*this in the range[0, pos) are not modified.#include <cassert>#include <inplace_vector>#include <iterator>#include <new>#include <print> int main(){auto v=std::inplace_vector<int,8>{0,1,2,3};auto pos=std::next(v.begin(),2);assert(*pos==2);constauto rg={-1,-2,-3}; v.insert_range(pos, rg);std::println("{}", v); try{assert(v.size()+ rg.size()> v.capacity()); v.insert_range(pos, rg);// throws: no space}catch(conststd::bad_alloc& ex){std::println("{}", ex.what());}}
Possible output:
[0, 1, -1, -2, -3, 2, 3]std::bad_alloc
| inserts elements (public member function) | |
| adds a range of elements to the end (public member function) | |
| tries to add a range of elements to the end (public member function) |