template <typename Compare, typename Pipe = ml::ToList>
struct Sort {
template <typename ...Ts>
using f = /* .... */;
};
Sort<Compare, Pipe>
is a metafunction that passes to Pipe
a parameter pack Us...
which is such a reordering of the parameter pack Ts...
, that is sorted by the Compare
metafunction. Pipe
defaults to ml::ToList
.
f:: Ts... -> Us... >-> Pipe
Compare must be a metafunction acting on two types and returning ml::Bool<truth_value>
.
f:: (T, U) -> ml::Bool<truth_value>
We sort types by their alignment.
using T = ml::f<
ml::Sort<
ml::Map<
ml::AlignOf<>,
ml::Greater<>>>,
int, double, char, long>;
static_assert(
std::is_same_v<
T,
ml::ListT<
long, double, int, char>>);
NOTE that
ml::Map<
ml::AlignOf<>, // maps each element by taking its alignment
ml::Greater<>> // and pipes the resulting parameter pack into greater
is a metafunction of type
(T, U) -> (AlignOf(T), AligmentOf(U)) >-> ml::Greater