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

◆ for_each_field

for_each_field_t kumi::for_each_field {}
inlineconstexpr

Callable object applying the Callable object f on each element of a product type and its field.

Note
This function does not take part in overload resolution if f can't be applied to the elements of t and/or ts and a field or if the product types are not compatible.
See also
kumi::concepts::compatible_product_types

This function can only be applied to record types. The function needs to be defined to handle types modeling kumi::concepts::field.

Header file

#include <kumi/algorithm/for_each.hpp>

Call Signature

template<typename Function, product_type T, product_type... Ts>
constexpr decltype(auto) for_each_field(Function && f, T && t, Ts &&... ts);
constexpr for_each_field_t for_each_field
Callable object applying the Callable object f on each element of a product type and its field.
Definition for_each.hpp:223

Parameters

  • f: Callable object to be invoked
  • t: Product Type whose elements are used as arguments to f
  • ts: Other product types whose elements are used as arguments to f
See also
kumi::for_each
kumi::for_each_index

Examples

#include <kumi/kumi.hpp>
#include <iostream>
using namespace kumi::literals;
int main()
{
auto r = kumi::record{ "name"_id = std::string{"kumi"}, "size"_id = 4 };
kumi::for_each_field( [](auto field, auto& m)
{ std::cout << field << " = " << m << "\n"; }
, r
);
std::cout << "\n";
}
Named wrapper over a type.
Definition field.hpp:26
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36