KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches
kumi::count

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

Variables

constexpr count_t kumi::count {}

Detailed Description

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

Variable Documentation

◆ count

count_t kumi::count {}
inlineconstexprnoexcept

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

Header file

#include <kumi/kumi.hpp>

Call Signature

namespace kumi
{
template<concepts::product_type T>
constexpr auto count(T && t) noexcept;
}
constexpr count_t count
Definition predicates.hpp:398
Main KUMI namespace.
Definition algorithm.hpp:11

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:35
  • 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 fields with distinct labels.
    Definition record.hpp:36