Callable object reordering elements of a product type.
template<std::size_t... I>
| reorder_t<I...> kumi::reorder {} |
|
inlineconstexprnodiscard |
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
- The number of indexes may be lesser or greater than the size of t, and an index may appear several times, except on a record, where a repeated index fails to compile since a record holds each label once.
{
}
Concept specifying a type follows the Product Type semantic.
Definition concepts.hpp:77
constexpr reorder_t< I... > reorder
Definition reorder.hpp:135
Main KUMI namespace.
Definition algorithm.hpp:11
- 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>
template<kumi::concepts::product_type T, std::size_t... Idx> struct reorder
{
using type = kumi::result::reorder_t<T, Idx...>;
};
Computes the return type of a call to kumi::reorder
- Tuple
#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:35
- Record
#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 fields with distinct labels.
Definition record.hpp:36