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

◆ count

count_t kumi::count {}
inlineconstexprnoexcept

Callable object counting the number of elements of t not equivalent to false.

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>
constexpr auto count(T && t) noexcept;
constexpr count_t count
Callable object counting the number of elements of t not equivalent to false.
Definition predicates.hpp:346

Parameters

  • t: Product Type to process

Return value

  • Number of elements not equivalent to false.

Examples

Tuple

#include <kumi/kumi.hpp>
#include <iostream>
#include <type_traits>
int main()
{
auto t = kumi::tuple{1, 0, 2., nullptr, 3.f, false, 'z'};
std::cout << std::boolalpha << kumi::count(t ) << "\n";
}
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 t = kumi::record{"a"_id = 1, "b"_id = 0, "c"_id = 2., "d"_id = nullptr
, "e"_id = 3.f, "f"_id = false, "g"_id = 'z'};
std::cout << std::boolalpha << kumi::count(t ) << "\n";
}
Fixed-size collection of heterogeneous tagged fields, tags are unique.
Definition record.hpp:36