KUMI v4.0.0
Flawless Fluorite
Loading...
Searching...
No Matches

◆ count_if

count_if_t kumi::count_if {}
inlineconstexprnoexcept

Callable object counting the number of elements of t satisfying predicates p.

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

Header file

#include <kumi/algorithm/predicates.hpp>

Call Signature

template<product_type T, typename Pred>
constexpr auto count_if(T && t, Pred p) noexcept;
constexpr count_if_t count_if
Callable object counting the number of elements of t satisfying predicates p.
Definition predicates.hpp:318

Parameters

  • t: Product Type to process
  • p: Unary predicate

Return value

  • Number of elements satisfying the condition.

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 auto predicate() noexcept
    Convert a unary template meta-program in a running predicate.
    Definition ct_helpers.hpp:148
    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