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

◆ reorder_fields()

template<concepts::identifier auto... Name, concepts::product_type Tuple>
auto kumi::reorder_fields ( Tuple && t)
inlineconstexpr

Reorder elements of a kumi::record.

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
Nothing prevent the number of reordered names to be lesser or greater than t size or the fact they can appear multiple times if it is applied on a named tuple.
Template Parameters
NameReordered names of elements
Parameters
tProduct type to reorder
Returns
A product type with the type of t with elements equal to get<Name>(t).

Helper type

namespace kumi::result
{
template<product_type Tuple,std::size_t... Idx> struct reorder_fields;
template<product_type Tuple,std::size_t... Idx>
using reorder_fields_t = typename reorder_fields<Tuple,Idx...>::type;
}
constexpr auto reorder_fields(Tuple &&t)
Reorder elements of a kumi::record.
Definition reorder.hpp:92

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 tagged fields, tags are unique.
Definition record.hpp:36