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

Callable object reindex elements of a Product Type. More...

Variables

template<kumi::concepts::projection_map auto Projections>
constexpr reindex_t< Projections > kumi::reindex {}

Detailed Description

Callable object reindex elements of a Product Type.

Variable Documentation

◆ reindex

template<kumi::concepts::projection_map auto Projections>
reindex_t<Projections> kumi::reindex {}
inlineconstexprnodiscard

This function will issue a compile time error if one of the identifiers is not in t or if any index is outside [0, size_v<T>[ at any given level of the input type.

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

Note
Nothing prevents the number of reordered names from being lesser or greater than the size of t or from appearing multiple times if it is applied on a named tuple.

Header file

#include <kumi/kumi.hpp>

Call Signature

namespace kumi
{
template<concepts::projection_map auto Projections, concepts::product_type T>
constexpr auto reindex(T && t);
}
constexpr reindex_t< Projections > reindex
Definition reorder.hpp:270
Main KUMI namespace.
Definition algorithm.hpp:11

Template Parameters

  • Projections: kumi::projection_map of the indexes or identifiers to select, a nested map building a nested product type

Parameters

  • t: Product Type to reorder

Return value

  • A potentially nested tuple corresponding to recursive applications of reorder

Helper type

template<kumi::concepts::product_type T, kumi::concepts::projection_map auto Indexes>
using reindex_t = decltype(kumi::reindex<Indexes>(kumi::declval<T>()));
template<kumi::concepts::product_type T, kumi::concepts::projection_map auto Indexes> struct reindex
{
using type = kumi::result::reindex_t<T, Indexes>;
};

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

Examples

  • Tuple
    #include <kumi/kumi.hpp>
    #include <iostream>
    int main()
    {
    using namespace kumi::literals;
    auto values = kumi::tuple { 1, 'a', 0.1 };
    constexpr auto basic = kumi::indexes(2_c,1_c,0_c);
    constexpr auto stack = kumi::projection_map(2_c,1_c,0_c, kumi::indexes(0_c,1_c,2_c));
    constexpr auto pairs = kumi::projection_map(kumi::indexes(0_c,0_c), kumi::indexes(1_c,1_c));
    std::cout << values << "\n";
    std::cout << kumi::reindex<basic>(values) << "\n";
    std::cout << kumi::reindex<stack>(values) << "\n";
    std::cout << kumi::reindex<pairs>(values) << "\n";
    }
    consteval auto indexes(Ts...) noexcept
    Definition projections.hpp:149
    projection_map(Ts...) -> projection_map< Ts
    Definition projections.hpp:130
    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 };
    constexpr auto basic = kumi::indexes(2_c,1_c,0_c);
    std::cout << values << "\n";
    std::cout << kumi::reindex<basic>(values) << "\n";
    }
    Fixed-size collection of heterogeneous fields with distinct labels.
    Definition record.hpp:36