KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches

Callable object reordering elements of a product type. More...

Variables

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

Detailed Description

Callable object reordering elements of a product type.

Variable Documentation

◆ reorder

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

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
The number of indexes may be lesser or greater than the size of t, and an index may appear several times, except on a record, where a repeated index fails to compile since a record holds each label once.

Header file

#include <kumi/kumi.hpp>

Call Signature

namespace kumi
{
template<std::size_t...Idx, concepts::product_type T>
constexpr auto reorder(T && t);
}
Concept specifying a type follows the Product Type semantic.
Definition concepts.hpp:77
constexpr reorder_t< I... > reorder
Definition reorder.hpp:135
Main KUMI namespace.
Definition algorithm.hpp:11

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>
using reorder_t = decltype(kumi::reorder<Idx...>(kumi::declval<T>()));
template<kumi::concepts::product_type T, std::size_t... Idx> struct reorder
{
using type = kumi::result::reorder_t<T, Idx...>;
};

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:35
  • 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 fields with distinct labels.
    Definition record.hpp:36