Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 1.11 KB

FindIdIf.md

File metadata and controls

44 lines (35 loc) · 1.11 KB

<CppML/Algorithm/FindIdIf.hpp>

FindIdIf

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

FindIdIf<Predicate, Pipe>

FindIdIf<Predicate, Pipe> is a metafunction that passes to Pipe the index ml::Int<index> of the first element of the parameter pack Ts..., for which the predicate holds. Pipe defaults to ml::Identity.

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

Predicate

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

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

Example

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

using T1 = ml::f<
                 ml::FindIdIf<
                           ml::IsClass<ml::Not<>>>,
                 int, char, std::string>;
static_assert(
              std::is_same_v<
                  T, ml::Int<0>>);