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.
#include <kumi/algorithm/map.hpp>
template<typename Function, product_type T, product_type... Ts>
constexpr auto map_index(Function && f, T && t, Ts &&... ts);
- f: Callable object to apply
- t: Product Type to operate on
- ts: Other Product Types to operate on
template<typename Function,
kumi::concepts::record_type T,
kumi::concepts::sized_product_type<kumi::size_v<T>>... Ts>
{
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
#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};
{
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:162
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36