Callable object reindex elements of a Product Type.
This function will issue a compile time error if one of the identifiers is not in t or if any index is outside [0, size_v<T>[ at any given level of the input type.
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.
#include <kumi/algorithm/reorder.hpp>
constexpr auto reindex<Ids...>(T && t);
constexpr reindex_t< Projections > reindex
Callable object reindex elements of a Product Type.
Definition reorder.hpp:246
identifier definition class
Definition identifier.hpp:86
- Ids Identifiers of the elements to reorder
- t: Product Type to reorder
- A potentially nested tuple corresponding to recursive applications of reorder
template<kumi::concepts::product_type T, kumi::concepts::projection_map auto Indexes>
struct reindex
{
};
template<kumi::concepts::product_type T, kumi::concepts::projection_map auto Indexes>
using reindex_t = typename kumi::result::reindex<T, Indexes>::type;
Computes the return type of a call to kumi::reindex
#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
std::cout << values << "\n";
std::cout << kumi::reindex<basic>(values) << "\n";
std::cout << kumi::reindex<stack>(values) << "\n";
std::cout << kumi::reindex<pairs>(values) << "\n";
}
consteval auto indexes(Ts...) noexcept
Creates a kumi::projection_map object, deducing the target type from the types of arguments.
Definition projections.hpp:147
KUMI_CUDA projection_map(Ts...) -> projection_map< Ts
kumi::projection_map deduction guide
Definition projections.hpp:131
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::reindex<basic>(values) << "\n";
}
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36