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

◆ transpose()

template<concepts::product_type T>
requires (_::supports_transpose<T>)
auto kumi::transpose ( T && t)
inlinenodiscardconstexpr

Transpose a product type of product types by shifting elements in their transposed position always returning a tuple as the external product type.

Parameters
tProduct type to transpose
Returns
A tuple containing the transposed elements of t.

Helper type

namespace kumi::result
{
template<product_type T> struct transpose;
template<product_type T>
using transpose_t = typename transpose<T>::type;
}
constexpr auto transpose(T &&t)
Transpose a product type of product types by shifting elements in their transposed position always re...
Definition transpose.hpp:38

Computes the return type of a call to kumi::transpose

Examples:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
auto values = kumi::tuple { kumi::tuple{ 1, 'a', 0.1 }
, kumi::tuple{ 2, 'b', 0.01 }
};
auto r = kumi::transpose(values );
std::cout << r << "\n";
}
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:29
#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
auto status = kumi::record{"a"_id = true, "b"_id = false};
auto id = kumi::record{"aa"_id = 'a', "bb"_id = 'b', "cc"_id = 'c'};
auto value = kumi::record{"aaa"_id = 1.0,"bbb"_id = 2.1, "ccc"_id = 4.2, "d"_id = 8.4};
auto r = kumi::cartesian_product( status, id, value );
kumi::for_each_index( [](auto i, auto e)
{
std::cout << "# " << i
<< ":" << std::boolalpha
<< e << "\n";
}
, r
);
}
constexpr auto cartesian_product(Ts &&... ts)
Return the Cartesian Product of all elements of its arguments product types.
Definition cartesian_product.hpp:64
constexpr void for_each_index(Function f, Tuple &&t, Tuples &&... ts)
Applies the Callable object f on each element of a kumi::product_type and its index.
Definition for_each.hpp:79
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition record.hpp:29