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

Callable object invoking the callable object f with the elements of the product type unrolled as arguments. More...

Variables

constexpr apply_field_t kumi::apply_field {}

Detailed Description

Callable object invoking the callable object f with the elements of the product type unrolled as arguments.

Variable Documentation

◆ apply_field

apply_field_t kumi::apply_field {}
inlineconstexprnoexcept

f is applied on the fields when the input t is a record type.

Note
This function does not take part in overload resolution if f can't be applied to the elements of t.

Header file

#include <kumi/kumi.hpp>

Call Signature

namespace kumi
{
template<typename Function, concepts::product_type T>
constexpr decltype(auto) apply_field(Function && f, T && t) noexcept;
}
constexpr apply_field_t apply_field
Definition apply.hpp:162
Main KUMI namespace.
Definition algorithm.hpp:11

Parameters

  • f: Callable object to be invoked
  • t: Product Type whose elements are used as arguments to f

Return value

  • The value returned by f.

Helper type

template<typename Function, concepts::record_type R>
using apply_field_t = decltype(kumi::apply_field(kumi::declval<Function>(), kumi::declval<R>()));
template<typename Function, kumi::concepts::record_type R> struct apply_field
{
using type = kumi::result::apply_field_t<Function, R>;
};

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

Example

Record

#include <kumi/kumi.hpp>
#include <iostream>
template<kumi::concepts::record_type Record>
void print(std::ostream& os, Record const& t)
{
(
[&os](auto const&... args)
{
os << '[';
std::size_t n{0};
((os << args << (++n != kumi::size<Record>::value ? ", " : "")), ...);
os << ']';
}, t
);
os << '\n';
}
int main()
{
using namespace kumi::literals;
auto r = kumi::record{"x"_id = 1, "y"_id = 2., "z"_id = 3.f};
print(std::cout, r);
}
Fixed-size collection of heterogeneous fields with distinct labels.
Definition record.hpp:36