KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches
kumi::cartesian_product

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

Variables

constexpr cartesian_product_t kumi::cartesian_product {}

Detailed Description

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

Variable Documentation

◆ cartesian_product

cartesian_product_t kumi::cartesian_product {}
inlineconstexprnodiscard
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/kumi.hpp>

Call Signature

namespace kumi
{
template<concepts::product_type... Ts>
[[nodiscard]] constexpr auto cartesian_product(Ts &&... ts);
}
Concept specifying a type follows the Product Type semantic.
Definition concepts.hpp:77
constexpr cartesian_product_t cartesian_product
Definition cartesian_product.hpp:107
Main KUMI namespace.
Definition algorithm.hpp:11

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> using cartesian_product_t = decltype(kumi::cartesian_product(kumi::declval<Ts>()...));
template<typename... Ts> struct cartesian_product
{
using type = kumi::result::cartesian_product_t<Ts...>;
};

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
    );
    }
    constexpr for_each_index_t for_each_index
    Definition for_each.hpp:189
    Fixed-size collection of heterogeneous values.
    Definition tuple.hpp:35
  • 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 fields with distinct labels.
    Definition record.hpp:36