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

Callable object reordering elements of a Record Type. More...

Variables

template<kumi::concepts::identifier auto... Name>
constexpr reorder_fields_t< Name... > kumi::reorder_fields {}

Detailed Description

Callable object reordering elements of a Record Type.

Variable Documentation

◆ reorder_fields

template<kumi::concepts::identifier auto... Name>
reorder_fields_t<Name...> kumi::reorder_fields {}
inlineconstexprnodiscard

This function will issue a compile time error if the identifiers are not in 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 identifiers may be lesser or greater than the size of t. An identifier may appear several times on a kumi::tuple of fields, and a repeated identifier fails to compile on a record, since a record holds each label once.

Header file

#include <kumi/kumi.hpp>

Call Signature

namespace kumi
{
constexpr auto reorder_fields(T && t);
}
Concept specifying a type represents an identifier.
Definition concepts.hpp:204
Concept specifying a type follows the Product Type semantic.
Definition concepts.hpp:77
constexpr reorder_fields_t< Name... > reorder_fields
Definition reorder.hpp:198
Main KUMI namespace.
Definition algorithm.hpp:11

Template Parameters

  • Ids Identifiers of the elements to reorder

Parameters

  • t: Product Type to reorder

Return value

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

Helper type

template<kumi::concepts::product_type Tuple, kumi::concepts::identifier auto... Name>
using reorder_fields_t = decltype(kumi::reorder_fields<Name...>(kumi::declval<Tuple>()));
template<kumi::concepts::product_type Tuple, kumi::concepts::identifier auto... Name> struct reorder_fields
{
using type = kumi::result::reorder_fields_t<Tuple, Name...>;
};

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

Example

#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_fields<"b"_id,"a"_id,"c"_id>(values) << "\n";
}
Fixed-size collection of heterogeneous fields with distinct labels.
Definition record.hpp:36