File sorted.hpp
↰ Parent directory (include
)
Compile-time quicksort over a heterogenous typelist.
Definition (include/sorted.hpp
)
Detailed Description
Sorts a detail::HTList<...>
whose elements satisfy HasStaticSize
(i.e., each exposes a static constexpr size
convertible to std::size_t
). Order is controlled by Order::{Asc,Desc}
and comparisons are routed through op_type<"...">
predicates like "<"_ct
, ">="_ct
, etc.
Example
structA{staticconstexprstd::size_tsize=3;}; structB{staticconstexprstd::size_tsize=1;}; structC{staticconstexprstd::size_tsize=2;};
usingL=:ref:exhale_struct_structctql_1_1detail_1_1HTList; usingSorted=:ref:exhale_struct_structctql_1_1sort__list;//==>HTList<B,C,A>
Key mapping with TypeSort
//IfSize<T>isa”key”typethatitselfsatisfiesHasStaticSize(e.g.,Size<T>::size=T::size), //TypeSortproducesalistofthekeys(nottheoriginalTs): usingOut=:ref:exhale_typedef_sorted_8hpp_1ae6127fc54c05e4d80ea5380deec6f144;//HTList<Size<B>,Size<C>,Size<A>>
This is a quicksort-style split on the first element; it is not stable. @complexity Expected O(n log n) template instantiations; worst-case O(n^2).
Includes
htlist.hpp
(File htlist.hpp)partition.hpp
(File partition.hpp)predicates.hpp
(File predicates.hpp)