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

◆ for_each

for_each_t kumi::for_each {}
inlineconstexpr

Callable object applying the Callable object f on each element of a product type.

f is applied on the values if the given product_type is a record type.

Note
This function does not take part in overload resolution if f can't be applied to the elements of t and/or ts, or if the product type are not compatible.
See also
compatible_product_types.

Header file

#include <kumi/algorithm/for_each.hpp>

Call Signature

template<typename Function, product_type T, product_type... Ts>
constexpr decltype(auto) for_each(Function && f, T && t, Ts &&... ts);
constexpr for_each_t for_each
Callable object applying the Callable object f on each element of a product type.
Definition for_each.hpp:152

Parameters

  • f: Callable object to be invoked
  • t: Product Type whose elements are used as arguments to f
  • ts: Other product types whose elements are used as arguments to f
See also
kumi::for_each_index
kumi::for_each_field

Examples

  • Tuple
    #include <kumi/kumi.hpp>
    #include <iostream>
    int main()
    {
    auto t = kumi::tuple{ 1, 2.3, 0.43f };
    kumi::for_each( [](auto& m) { m *= 10; }
    , t
    );
    std::cout << t << "\n";
    }
    Fixed-size collection of heterogeneous values.
    Definition tuple.hpp:33
  • Record
    #include <kumi/kumi.hpp>
    #include <iostream>
    int main()
    {
    using namespace kumi::literals;
    auto t = kumi::record{ "a"_id = 1, "b"_id = 2.3, "c"_id = 0.43f };
    kumi::for_each( [](auto& m) { m *= 10; }
    , t
    );
    std::cout << t << "\n";
    }
    Fixed-size collection of heterogeneous tagged fields, tags are unique.
    Definition record.hpp:36