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

◆ count_if()

template<typename Pred, concepts::product_type T>
std::size_t kumi::count_if ( T && t,
Pred p )
inlinenodiscardconstexprnoexcept

Counts the number of elements of t satisfying predicates p.

Parameters
tProduct Type to process
pUnary predicate. p must return a value convertible to bool for every element of t.
Returns
Number of elements satisfying the condition.

On a record type, the function operates on the underlying elements of the fields.

Examples:

Tuple:

#include <kumi/kumi.hpp>
#include <iostream>
#include <type_traits>
int main()
{
auto t = kumi::tuple{1, 2., 3.f, 'z'};
std::cout << std::boolalpha
}
constexpr std::size_t count_if(T &&t, Pred p) noexcept
Counts the number of elements of t satisfying predicates p.
Definition predicates.hpp:172
constexpr auto predicate() noexcept
Convert a unary template meta-program in a running predicate.
Definition ct_helpers.hpp:182
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:33

Record:

#include <kumi/kumi.hpp>
#include <iostream>
#include <type_traits>
int main()
{
using namespace kumi::literals;
auto r = kumi::record{"a"_id = 1, "b"_id = 2.,"c"_id = 3.f, "d"_id = 'z'};
std::cout << std::boolalpha
}
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36