KUMI v4.0.0
Flawless Fluorite
Loading...
Searching...
No Matches

◆ reorder_fields

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

Callable object reordering elements of a Record Type.

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.
reorder(tuple) works and is equivalent to reorder<>(tuple)

Header file

#include <kumi/algorithm/reorder.hpp>

Call Signature

template<identifier auto...Ids, product_type T>
constexpr auto reorder_fields<Ids...>(T && t);
constexpr reorder_fields_t< Name... > reorder_fields
Callable object reordering elements of a Record Type.
Definition reorder.hpp:185
identifier definition class
Definition identifier.hpp:86

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 identifer.

Helper type

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

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