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

◆ cartesian_product()

template<concepts::product_type... Ts>
requires (concepts::follows_same_semantic<Ts...>)
auto kumi::cartesian_product ( Ts &&... ts)
inlinenodiscardconstexpr

Return the Cartesian Product of all elements of its arguments product types.

Parameters
tsProduct types to process
Returns
A tuple containing all the product types built from all combination of all ts' elements
Note
This function does not take part in overload resolution if the input product types do not follow the same semantic.
See also
concepts::follows_same_semantic

Helper type

namespace kumi
{
template<product_type... Ts> struct cartesian_product;
template<product_type... Ts>
using cartesian_product_t = typename cartesian_product<Ts...>::type;
}
constexpr auto cartesian_product(Ts &&... ts)
Return the Cartesian Product of all elements of its arguments product types.
Definition cartesian_product.hpp:71
Main KUMI namespace.
Definition algorithm.hpp:11

Computes the type returned by a call to kumi::cartesian_product.

Examples:

Tuple:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
auto status = kumi::tuple{true, false};
auto id = kumi::tuple{'a','b','c'};
auto value = kumi::tuple{1.0,2.1,4.2,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 void for_each_index(Function f, T &&t, Ts &&... ts)
Applies the Callable object f on each element of a product type and its index.
Definition for_each.hpp:81
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:33

Record:

#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
);
}
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36