Inserts, in non-reversing order, copies of elements in rg before pos.
Each iterator in the range rg is dereferenced exactly once.
If rg overlaps with *this, the behavior is undefined.
[edit] Parameters [edit] Return valueAn iterator to the first element inserted into *this, or pos if rg is empty.
ExceptionsT
) or by any LegacyInputIterator 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); const auto 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(const std::bad_alloc& ex) { std::println("{}", ex.what()); } }
Possible output:
[0, 1, -1, -2, -3, 2, 3] std::bad_alloc[edit] See also inserts elements
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4