Skip to content

Latest commit

 

History

History
51 lines (42 loc) · 1.32 KB

MaxElement.md

File metadata and controls

51 lines (42 loc) · 1.32 KB

<CppML/Algorithm/MaxElement.hpp>

MaxElement

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

MaxElement<Compare, Pipe>

MaxElement<Compare, Pipe> is a metafunction that passes to Pipe the element U of the parameter pack Ts... which is maximal, given the Compare metafunction. Pipe defaults to ml::Identity.

f:: Ts... -> U >-> Pipe

Compare

Compare must be a metafunction acting on two types and returning ml::Bool<truth_value>.

f:: (T, U) -> ml::Bool<truth_value>

Example

using T0 = ml::f<
                 ml::MaxElement<
                      ml::Map<
                              ml::AlignOf<>,
                              ml::Greater<>>>,
                 int, double, char>;
static_assert(
              std::is_same_v<
                  T, double>);

NOTE that

ml::Map<
        ml::AlignOf<>, // maps each element by taking its aligment
        ml::Greater<>>      // and pipes the resulting parameter pack into greater

is a metafunction of type

(T, U) -> (AlignOf(T), AligmentOf(U)) >-> Greater

and is as such a valid compare metafunction. See ml::Map.