KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches

Callable object applying the Callable object f on each product types elements and their indexes. More...

Variables

constexpr map_index_t kumi::map_index {}

Detailed Description

Callable object applying the Callable object f on each product types elements and their indexes.

Variable Documentation

◆ map_index

map_index_t kumi::map_index {}
inlineconstexprnodiscard

Applies the given function to all the product types passed as arguments along with their indexes and stores the result in another product type, 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 and their indexes.

Header file

#include <kumi/kumi.hpp>

Call Signature

namespace kumi
{
template<typename Function, concepts::product_type T, concepts::product_type... Ts>
constexpr auto map_index(Function && f, T && t, Ts &&... ts);
}
Concept specifying a type follows the Product Type semantic.
Definition concepts.hpp:77
constexpr map_index_t map_index
Definition map.hpp:217
Main KUMI namespace.
Definition algorithm.hpp:11

Parameters

  • f: Callable object to apply
  • t: Product Type to operate on
  • ts: Other Product Types to operate on

Return value

Helper type

template<typename Function,
kumi::concepts::product_type T,
kumi::concepts::sized_product_type<kumi::size_v<T>>... Ts>
using map_index_t =
template<typename Function,
kumi::concepts::product_type T,
kumi::concepts::sized_product_type<kumi::size_v<T>>... Ts>
struct map_index
{
using type = kumi::result::map_index_t<Function, T, Ts...>;
};

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

See also
kumi::map
kumi::map_field

Example

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
auto lhs = kumi::tuple{1,2,3};
auto rhs = kumi::tuple{2.4,4.6,6.8};
auto res = kumi::map_index( [](auto i, auto l, auto r) { return 1000*(i+1)+(l*r); }
, lhs, rhs
);
std::cout << res << "\n";
}
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:35