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

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

Variables

constexpr map_field_t kumi::map_field {}

Detailed Description

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

Variable Documentation

◆ map_field

map_field_t kumi::map_field {}
inlineconstexprnodiscard

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/kumi.hpp>

Call Signature

namespace kumi
{
template<typename Function, concepts::product_type T, concepts::product_type... Ts>
constexpr auto map_field(Function && f, T && t, Ts &&... ts);
}
Concept specifying a type follows the Product Type semantic.
Definition concepts.hpp:77
constexpr map_field_t map_field
Definition map.hpp:279
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::record_type T,
kumi::concepts::sized_product_type<kumi::size_v<T>>... Ts>
using map_field_t =
template<typename Function,
kumi::concepts::record_type T,
kumi::concepts::sized_product_type<kumi::size_v<T>>... Ts>
struct map_field
{
using type = kumi::result::map_field_t<Function, T, Ts...>;
};

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";
}
Compile-time text based identifier.
Definition identifier.hpp:165
Fixed-size collection of heterogeneous fields with distinct labels.
Definition record.hpp:36