Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 1.1 KB

CountIf.md

File metadata and controls

43 lines (34 loc) · 1.1 KB

<CppML/Algorithm/CountIf.hpp>

CountIf

template <typename Predicate, typename Pipe = ml::Identity>
struct CountIf {
  template <typename ...Ts>
  using f = /* .... */;
};

CountIf<Predicate, Pipe>

CountIf<Predicate, Pipe> is a metafunction that passes to Pipe and ml::Int<count>, where count is the number of elements of the parameter pack Ts, for which the Predicate holds. Pipedefaults to ml::Identity.

f:: Ts... -> ml::Int<count> >-> Pipe

Predicate

Predicate must be a metafunction returning ml::Bool<truth_value>.

f:: T -> ml::Bool<truth_value>

Example

using T0 = ml::f<
                 ml::CountIf<ml::IsClass<>>,
                 int, char, std::string>;
static_assert(
              std::is_same_v<T, ml::Int<1>);

using T1 = ml::f<
                 ml::CountIf<
                           ml::IsClass<>,
                           ml::Increment<>>,
                 int, char, std::string>;
static_assert(
              std::is_same_v<T, ml::Int<2>);