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

◆ cartesian_product()

template<product_type... Ts>
constexpr auto kumi::cartesian_product ( Ts &&...  ts)
constexpr

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

Parameters
tsTuples to process
Returns
a tuple containing all the tuple build from all combination of all ts' elements

Helper type

namespace kumi
{
template<product_type... Tuples> struct cartesian_product;
template<product_type... Tuples>
using cartesian_product_t = typename cartesian_product<Tuples...>::type;
}
Concept specifying a type follows the Product Type semantic.
Definition: concepts.hpp:33
constexpr auto cartesian_product(Ts &&... ts)
Return the Cartesian Product of all elements of its arguments product types.
Definition: cartesian_product.hpp:64
Main KUMI namespace.
Definition: algorithm.hpp:11

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

Example:

#include <kumi/tuple.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, Tuple &&t, Tuples &&... ts)
Applies the Callable object f on each element of a kumi::product_type and its index.
Definition: for_each.hpp:69
Fixed-size collection of heterogeneous values.
Definition: tuple.hpp:35