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
-
| t | Tuple to split. |
| i0 | Compile-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 &&t, index_t< I0 > i0) noexcept
Split a tuple into two.
Definition extract.hpp:98
Computes the type returned by a call to split.
Examples:
#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
auto[first, second] =
split(a, 3_c);
std::cout << a << "\n";
std::cout << first << "\n";
std::cout << second << "\n";
}
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:37
#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
kumi::record a = {
"a"_f = 1,
"b"_f = 2.3,
"c"_f = 4.5f,
"d"_f =
'6',
"e"_f = "7", "f"_f = short{89} };
auto[first, second] =
split(a, 3_c);
std::cout << a << "\n";
std::cout << first << "\n";
std::cout << second << "\n";
}
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition traits.hpp:366