KUMI v4.0.0
Flawless Fluorite
Loading...
Searching...
No Matches

◆ reorder

template<std::size_t... I>
reorder_t<I...> kumi::reorder {}
inlineconstexprnodiscard

Callable object reordering elements of a product type.

This function will issue a compile time error if any Idx is outside [0, size_v<T>[.

On record types, this function operates on elements as if they were ordered. The considered order is the order of declaration.

Note
Nothing prevent the number of reordered index to be lesser or greater than t size or the fact they can appear multiple times.
reorder(tuple) works and is equivalent to reorder<>(tuple)

Header file

#include <kumi/algorithm/reorder.hpp>

Call Signature

template<std::size_t...Idx, product_type T>
constexpr auto reorder<Idx...>(T && t);
constexpr reorder_t< I... > reorder
Callable object reordering elements of a product type.
Definition reorder.hpp:127

Template Parameters

  • Idx Index of elements to reorder

Parameters

  • t: Product Type to reorder

Return value

  • A product type with the type of t with elements equal to get<Idx>(t) for each given index.

Helper type

template<kumi::concepts::product_type T, std::size_t... Idx> struct reorder
{
using type = decltype(kumi::reorder<Idx...>(std::declval<T>()));
};
template<kumi::concepts::product_type T, std::size_t... Idx>
using reorder_t = typename kumi::result::reorder<T, Idx...>::type;

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

Examples

Tuple

#include <kumi/kumi.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:33

Record

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
auto values = kumi::record { "a"_id = 1, "b"_id = 'a', "c"_id = 0.1 };
std::cout << values << "\n";
std::cout << kumi::reorder<2,1,0>(values) << "\n";
}
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36