Loading [MathJax]/extensions/tex2jax.js
kumi v3.1.0
Exquisite Epidote
 
All Classes Namespaces Functions Variables Friends Modules Pages Concepts
Loading...
Searching...
No Matches

◆ split()

template<std::size_t I0, product_type Tuple>
requires (I0 <= size_v<Tuple>)
constexpr auto kumi::split ( Tuple const t,
index_t< I0 i0 
)
constexprnoexcept

Split a tuple into two.

Split a kumi::tuple in two kumi::tuple containing all the elements before and after a given index.

Note
Does not participate in overload resolution if I0 is not in [0, sizeof...(Ts)[.
Parameters
tTuple to split.
i0Compile-time index of the split pivot.
Returns
A new kumi::tuple containing the two sub-tuple cut at index I.

Helper type

namespace kumi::result
{
template<product_type Tuple, std::size_t I0> struct split;
template<product_type Tuple, std::size_t I0>
using split_t = typename split<Tuple,I0>::type;
}
constexpr auto split(Tuple const &t, index_t< I0 > i0) noexcept
Split a tuple into two.
Definition extract.hpp:94

Computes the type returned by a call to split.

Example:

#include <kumi/tuple.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
kumi::tuple a = { 1, 2.3, 4.5f,'6',"7", short{89} };
auto[first, second] = split(a, 3_c);
std::cout << a << "\n";
std::cout << first << "\n";
std::cout << second << "\n";
}
constexpr auto from_tuple(tuple< Ts... > const &t)
Converts a kumi::tuple to an instance of an arbitrary type.
Definition convert.hpp:59
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:35