kumi v3.1.0
Exquisite Epidote
 
Loading...
Searching...
No Matches

◆ reorder()

template<std::size_t... Idx, product_type Tuple>
requires ((Idx < size_v<Tuple>) && ...)
KUMI_TRIVIAL_NODISCARD constexpr auto kumi::reorder ( Tuple &&  t)
constexpr

Reorder elements of a kumi::product_type.

This function does not participate in overload resolution if any IDx is outside [0, size_v<T>[.

Note
Nothing prevent the number of reordered index to be lesser or greater than t size or the fact they can appear multiple times.
Template Parameters
IdxReordered index of elements
Parameters
tkumi::product_type to reorder
Returns
A tuple equivalent to kumi::make_tuple(t[index<Idx>]...);

Helper type

namespace kumi::result
{
template<product_type Tuple,std::size_t... Idx> struct reorder;
template<product_type Tuple,std::size_t... Idx>
using reorder_t = typename reorder<Tuple,Idx...>::type;
}
Concept specifying a type follows the Product Type semantic.
Definition: concepts.hpp:33
KUMI_TRIVIAL_NODISCARD constexpr auto reorder(Tuple &&t)
Reorder elements of a kumi::product_type.
Definition: reorder.hpp:43

Computes the return type of a call to kumi::reorder

Example

#include <kumi/tuple.hpp>
#include <iostream>
int main()
{
auto values = kumi::tuple { 1, 'a', 0.1 };
std::cout << values << "\n";
std::cout << kumi::reorder<2,1,0>(values) << "\n";
std::cout << kumi::reorder<2,1,0,1,2>(values) << "\n";
std::cout << kumi::reorder<1,1>(values) << "\n";
}
Fixed-size collection of heterogeneous values.
Definition: tuple.hpp:35