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

◆ reorder_fields()

template<field_name... Name, product_type Tuple>
requires ( requires { get<Name>(std::declval<Tuple>()); } && ... )
constexpr auto kumi::reorder_fields ( Tuple &&  t)
inlineconstexpr

Reorder elements of a kumi::record.

This function does not participate in overload resolution if the names are not in T

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
tkumi::product_type to reorder
Returns
A product type equivalent to product_type(t[index<Idx>]...);

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;
}
Concept specifying a type follows the Product Type semantic.
Definition concepts.hpp:33
constexpr auto reorder_fields(Tuple &&t)
Reorder elements of a kumi::record.
Definition reorder.hpp:110

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"_f = 1, "b"_f = 'a', "c"_f = 0.1 };
std::cout << values << "\n";
std::cout << kumi::reorder_fields<"b"_f,"a"_f,"c"_f>(values) << "\n";
}
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition traits.hpp:366