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

◆ for_each_index()

template<typename Function , product_type Tuple, product_type... Tuples>
constexpr void kumi::for_each_index ( Function  f,
Tuple &&  t,
Tuples &&...  ts 
)
constexpr

Applies the Callable object f on each element of a kumi::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.
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

Example

#include <kumi/tuple.hpp>
#include <iostream>
int main()
{
auto t = kumi::tuple{ 1, 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, Tuple &&t, Tuples &&... ts)
Applies the Callable object f on each element of a kumi::product_type and its index.
Definition: for_each.hpp:69
Fixed-size collection of heterogeneous values.
Definition: tuple.hpp:35