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

◆ for_each()

template<typename Function , product_type Tuple, product_type... Tuples>
requires ( (compatible_product_types<Tuple, Tuples...>) && (_::supports_call<Function&, Tuple, Tuples...>))
constexpr void kumi::for_each ( Function  f,
Tuple &&  t,
Tuples &&...  ts 
)
inlineconstexpr

Applies the Callable object f on each element of a kumi::product_type. f is applied on the values if the given product_type is a kumi::record.

Note
This function does not take part in overload resolution if f can't be applied to the elements of t and/or ts.
Parameters
fCallable object to be invoked
tkumi::product_type whose elements to be used as arguments to f
tsOther kumi::product_type whose elements to be used as arguments to f
See also
kumi::for_each_index

Example

#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";
}
constexpr void for_each(Function f, Tuple &&t, Tuples &&... ts)
Applies the Callable object f on each element of a kumi::product_type. f is applied on the values if ...
Definition for_each.hpp:32
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:37
#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
using namespace kumi::literals;
auto t = kumi::record{ "a"_f = 1, "b"_f = 2.3, "c"_f = 0.43f };
kumi::for_each( [](auto& m) { m *= 10; }
, t
);
std::cout << t << "\n";
}
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition traits.hpp:366