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

◆ for_each_index()

template<typename Function, concepts::product_type T, concepts::product_type... Ts>
requires (!concepts::record_type<T> && (!concepts::record_type<Ts> && ...))
void kumi::for_each_index ( Function f,
T && t,
Ts &&... ts )
inlineconstexpr

Applies the Callable object f on each element of a product type and its index.

Note
This function does not take part in overload resolution if f can't be applied to the elements of t and/or ts and an integral constant. This function cannot be applied on record types.
Parameters
fCallable object to be invoked
tProduct type whose elements are used as arguments to f
tsOther product types whose elements to be used as arguments to f
See also
kumi::for_each
kumi::for_each_field

Example:

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
auto t = kumi::tuple{ 1ULL, 2.3, 0.43f };
kumi::for_each_index( [](auto i, auto& m) { m += (i+1)*10; }
, t
);
std::cout << t << "\n";
}
constexpr void for_each_index(Function f, T &&t, Ts &&... ts)
Applies the Callable object f on each element of a product type and its index.
Definition for_each.hpp:81
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:33