kumi v3.1.0
Exquisite Epidote
Loading...
Searching...
No Matches

◆ for_each_field()

template<typename Function, concepts::record_type Tuple, concepts::record_type... Tuples>
void kumi::for_each_field ( Function f,
Tuple && t,
Tuples &&... ts )
inlineconstexpr

Applies the Callable object f on each element of a kumi::record_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 kumi::field.
Parameters
fCallable object to be invoked
tkumi::record_type whose elements to be used as arguments to f
tsOther kumi::record_type whose elements to be used as arguments to f
See also
kumi::for_each

Example

#include <kumi/kumi.hpp>
#include <string_view>
#include <iostream>
int main()
{
using namespace kumi::literals;
auto t = kumi::record{"a"_id = 1, "b"_id = 2.3, "c"_id = 0.43f };
{
if(name.as<std::string_view>().ends_with("a"))
m += 10;
else if (name == "c")
m = (m * 100) -1;
else
m *= 10;
}
, t
);
std::cout << t << "\n";
}
constexpr void for_each_field(Function f, Tuple &&t, Tuples &&... ts)
Applies the Callable object f on each element of a kumi::record_type and its field.
Definition for_each.hpp:110
Compile-time text based ID.
Definition identifier.hpp:147
Fixed-size collection of heterogeneous fields necessarily named, names are unique.
Definition record.hpp:29
Static string used to create named fields.
Definition str.hpp:20