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

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


Definitions

#0
constexpr void insert(xte::uz index) & noexcept(false) requires(/* See below */);
Default-constructs an element at the given index, shifting existing elements back. Requires that T is default-constructible and move-assignable.

#1
template<typename U = T>
constexpr void insert(xte::uz index, U&& arg, auto&&... args) & noexcept(false) requires(/* See below */);
Constructs an element at the given index with the provided arguments, shifting existing elements back. Requires that T is constructible from the provided args and is move-assignable.



Examples

#0
xte::array array = { 1, 2, 3 };
array.insert(1);
std::println("{}", array);
Output:
[1, 0, 2, 3]
[View in Compiler Explorer]

#1
xte::array<xte::array<int>> array = {
	{ 1, 2, 3 },
	{ 4, 5, 6 },
	{ 7, 8, 9 }
};
array.insert(1, { 111, 222, 333 });
std::println("{}", array);
Output:
[[1, 2, 3], [111, 222, 333], [4, 5, 6], [7, 8, 9]]
[View in Compiler Explorer]