xte::array<T>::insert_range()

Defined in header <xte/data/array.hpp>


Definition

template<std::ranges::input_range Range = xte::array<T>>
constexpr void insert_range(xte::uz index, Range&& range) & noexcept(false) requires(/* See below */);
Copies qualifiers from Range onto its element type. Inserts elements from the given range at the given index, shifting existing elements back. If Range satisfies std::ranges::sized_range<> and the range's elements fit within the currently allocated uninitialized elements, then reallocation is not performed. Requires that T is constructible from the range's elements and is move-assignable.



Example

xte::array array = { 1, 2, 3 };
array.insert_range(1, { 4, 5, 6 });
std::println("{}", array);
Output:
[1, 4, 5, 6, 2, 3]
[View in Compiler Explorer]