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

◆ zip()

template<concepts::product_type T0, concepts::sized_product_type< size_v< T0 > >... Ts>
requires (concepts::follows_same_semantic<T0, Ts...>)
auto kumi::zip ( T0 && t0,
Ts &&... ts )
inlinenodiscardconstexpr

Constructs a tuple where the ith element is the prduct type of all ith elements of ts...

Parameters
t0Product type to convert
tsProduct types to convert
Returns
The tuple of all combination of elements from t0, ts...
Note
Every inner product type should be of the same sizes, otherwise see zip_min or zip_max

Helper type

namespace kumi::result
{
template<product_type T> struct zip;
template<product_type T>
using zip_t = typename zip<T>::type;
}
constexpr auto zip(T0 &&t0, Ts &&... ts)
Constructs a tuple where the ith element is the prduct type of all ith elements of ts....
Definition zip.hpp:86

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

Examples:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
auto nbrs = kumi::tuple{1,2,3};
auto ltrs = kumi::tuple{'a','b','c'};
auto ratio = kumi::tuple{0.1,0.01,0.001};
auto r = kumi::zip( nbrs, ltrs, ratio );
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