KUMI v4.0.0
Flawless Fluorite
Loading...
Searching...
No Matches

◆ cartesian_product

cartesian_product_t kumi::cartesian_product {}
inlineconstexprnodiscard

Callable object returning the Cartesian Product of all elements of its arguments product types.

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

Header file

#include <kumi/algorithm/cartesian_product.hpp>

Call Signature

template<product_type... Ts>
[[nodiscard]] constexpr auto cartesian_product(Ts &&... ts);
constexpr cartesian_product_t cartesian_product
Callable object returning the Cartesian Product of all elements of its arguments product types.
Definition cartesian_product.hpp:89

Parameters

  • ts: Product Types to process

Return value

  • A tuple containing all the product types built from all combination of all ts' elements

Helper type

template<typename... Ts> struct cartesian_product
{
using type = decltype(kumi::cartesian_product(std::declval<Ts>()...));
};
template<typename... Ts> using cartesian_product_t = typename kumi::result::cartesian_product<Ts...>::type;

Computes the return type of 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
);
}
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