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

◆ map()

template<product_type Tuple, typename Function , sized_product_type< size< Tuple >::value >... Tuples>
requires _::supports_call<Function, Tuple&&, Tuples&&...>
constexpr auto kumi::map ( Function  f,
Tuple &&  t0,
Tuples &&...  others 
)
constexpr

Apply the Callable object f on each tuples' elements.

Applies the given function to all the tuples passed as arguments and stores the result in another tuple, keeping the original elements order.

Note
Does not participate in overload resolution if tuples' size are not equal or if f can't be called on each tuple's elements.
Parameters
fCallable function to apply
t0Tuple to operate on
othersTuples to operate on
Returns
The tuple of f calls results.

Helper type

namespace kumi::result
{
template<typename Function, product_type T, product_type... Ts> struct map;
template<typename Function, product_type T, product_type... Ts>
using map_t = typename map<Function,Tuple>::type;
}
Concept specifying a type follows the Product Type semantic.
Definition: concepts.hpp:33
constexpr auto map(Function f, Tuple &&t0, Tuples &&...others)
Apply the Callable object f on each tuples' elements.
Definition: map.hpp:45

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

Example

#include <kumi/tuple.hpp>
#include <iostream>
int main()
{
auto lhs = kumi::tuple{1,2,3};
auto rhs = kumi::tuple{2.5,3.6,4.7};
auto r = kumi::map( [](auto l, auto r) { return l*r; }, lhs, rhs);
std::cout << r << "\n";
}
Fixed-size collection of heterogeneous values.
Definition: tuple.hpp:35