Callable object invoking the callable object f with the elements of the product type unrolled as arguments.
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.
#include <kumi/algorithm/apply.hpp>
template<typename Function, product_type T>
constexpr decltype(
auto)
apply_field(Function && f, T && t)
noexcept;
- f: Callable object to be invoked
- t: Product Type whose elements are used as arguments to f
template<
typename Function, kumi::concepts::record_type R>
struct apply_field
{
using type =
decltype(
kumi::apply_field(std::declval<Function>(), std::declval<R>()));
};
template<typename Function, concepts::record_type R> using apply_field_t = typename apply_field<Function, R>::type;
Computes the return type of a call to kumi::apply_field
#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 << ']';
}, 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 tagged fields, tags are unique.
Definition record.hpp:36
Computes the number of elements of a kumi::product_type.
Definition traits.hpp:120