Callable object reordering elements of a product type.
This function will issue a compile time error if any Idx is outside [0, size_v<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 index to be lesser or greater than t size or the fact they can appear multiple times.
-
reorder(tuple) works and is equivalent to reorder<>(tuple)
#include <kumi/algorithm/reorder.hpp>
template<std::size_t...Idx, product_type T>
constexpr auto reorder<Idx...>(T && t);
constexpr reorder_t< I... > reorder
Callable object reordering elements of a product type.
Definition reorder.hpp:127
- Idx Index of elements to reorder
- t: Product Type to reorder
- A product type with the type of t with elements equal to get<Idx>(t) for each given index.
template<kumi::concepts::product_type T, std::size_t... Idx>
struct reorder
{
};
template<kumi::concepts::product_type T, std::size_t... Idx>
using reorder_t = typename kumi::result::reorder<T, Idx...>::type;
Computes the return type of a call to kumi::reorder
#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
std::cout << values << "\n";
std::cout << kumi::reorder<2,1,0>(values) << "\n";
std::cout << kumi::reorder<2,1,0,1,2>(values) << "\n";
std::cout << kumi::reorder<1,1>(values) << "\n";
}
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:33
#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<2,1,0>(values) << "\n";
}
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36