KUMI v4.0.0
Flawless Fluorite
Loading...
Searching...
No Matches

◆ map_field

map_field_t kumi::map_field {}
inlineconstexprnodiscard

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

Applies the given function to all the records passed as arguments along with their names and stores the result in another records, keeping the original elements order.

Note
Does not participate in overload resolution if records' size are not equal or if f can't be called on each record's fields and their names.

Header file

#include <kumi/algorithm/map.hpp>

Call Signature

template<typename Function, product_type T, product_type... Ts>
constexpr auto map_index(Function && f, T && t, Ts &&... ts);
constexpr map_index_t map_index
Callable object applying the Callable object f on each product types elements and their indexes.
Definition map.hpp:215

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::record_type T,
kumi::concepts::sized_product_type<kumi::size_v<T>>... Ts>
struct map_field
{
using type = decltype(kumi::map_field(std::declval<Function>(), std::declval<T>(), std::declval<Ts>()...));
};
template<typename Function,
kumi::concepts::record_type T,
kumi::concepts::sized_product_type<kumi::size_v<T>>... Ts>
using map_field_t = typename kumi::result::map_field<Function, T, Ts...>::type;

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

See also
kumi::map
kumi::map_index

Example

#include <kumi/kumi.hpp>
#include <iostream>
using namespace kumi::literals;
int main()
{
auto lhs = kumi::record{"a"_id = 1 , "b"_id = 2 , "c"_id = 3 };
auto rhs = kumi::record{"a"_id = 2.4, "b"_id = 4.6, "c"_id = 6.8};
auto res = kumi::map_field( [](auto name, auto l, auto r)
{
if (name == "a") return l + r;
else return 1000*+(l*r);
}
, lhs, rhs
);
std::cout << res << "\n";
}
constexpr map_field_t map_field
Callable object applying the Callable object f on each product types elements and their associated la...
Definition map.hpp:270
Compile-time text based identifier.
Definition identifier.hpp:162
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36