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

◆ count_if()

template<typename Pred , product_type T>
constexpr std::size_t kumi::count_if ( T &&  ts,
Pred  p 
)
inlineconstexprnoexcept

Counts the number of elements of t satisfying predicates p.

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

Example:

#include <kumi/kumi.hpp>
#include <iostream>
#include <type_traits>
int main()
{
auto t = kumi::tuple{1, 2., 3.f, 'z'};
std::cout << std::boolalpha
<< kumi::count_if( t, kumi::predicate<std::is_floating_point>() ) << "\n";
}
constexpr std::size_t count_if(T &&ts, Pred p) noexcept
Counts the number of elements of t satisfying predicates p.
Definition predicates.hpp:121
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:37