KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches

Callable object constructing a tuple where the ith element is the product type of all ith elements of t,ts... More...

Variables

constexpr zip_t kumi::zip {}

Detailed Description

Callable object constructing a tuple where the ith element is the product type of all ith elements of t,ts...

Variable Documentation

◆ zip

zip_t kumi::zip {}
inlineconstexprnodiscard

On record types, this function operates on elements as if they were ordered. The considered order is the order of declaration.

Note
This function does not take part in overload resolution if the product types do not follow the same semantic.
See also
kumi::concepts::follows_same_semantic
zip_min
zip_max

Header file

#include <kumi/kumi.hpp>

Call Signature

namespace kumi
{
constexpr auto zip(T && t, Ts &&... ts);
}
Concept specifying a type follows the Product Type semantic.
Definition concepts.hpp:77
constexpr zip_t zip
Definition zip.hpp:160
Main KUMI namespace.
Definition algorithm.hpp:11

Parameters

  • t: Product type to convert
  • ts: Product types to convert

Return value

  • The tuple of all combinations of elements from t, ts...

Helper type

//
template<kumi::concepts::product_type T0, kumi::concepts::product_type... Ts>
using zip_t = decltype(kumi::zip(kumi::declval<T0>(), kumi::declval<Ts>()...));
template<kumi::concepts::product_type T0, kumi::concepts::sized_product_type<kumi::size_v<T0>>... Ts> struct zip
{
using type = kumi::result::zip_t<T0, Ts...>;
};

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

Examples

  • Tuple
    #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:35
  • Record
    #include <kumi/kumi.hpp>
    #include <iostream>
    int main()
    {
    using namespace kumi::literals;
    auto nbrs = kumi::record{"a"_id=1 ,"b"_id=2 ,"c"_id=3 };
    auto ltrs = kumi::record{"d"_id='a',"e"_id='b' ,"f"_id='c' };
    auto ratio = kumi::record{"g"_id=0.1,"h"_id=0.01,"i"_id=0.001};
    auto r = kumi::zip( nbrs, ltrs, ratio );
    std::cout << r << "\n";
    }
    Fixed-size collection of heterogeneous fields with distinct labels.
    Definition record.hpp:36