mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 18:37:15 +02:00
fix: expr_less
now also sorts powers
This commit is contained in:
@ -308,19 +308,23 @@ struct expr_simplify<type_list<power<T, Ints1...>, NRest...>, type_list<power<T,
|
||||
|
||||
|
||||
// expr_less
|
||||
template<typename Lhs, typename Rhs, template<typename, typename, auto...> typename Pred>
|
||||
template<typename Lhs, typename Rhs, template<typename, typename> typename Pred>
|
||||
struct expr_less_impl : Pred<expr_type<Lhs>, expr_type<Rhs>> {};
|
||||
|
||||
template<typename T, int... Ints, template<typename, typename, auto...> typename Pred>
|
||||
template<typename T, int... Ints, template<typename, typename> typename Pred>
|
||||
struct expr_less_impl<T, power<T, Ints...>, Pred> : std::true_type {};
|
||||
|
||||
template<typename T, int... Ints1, int... Ints2, template<typename, typename> typename Pred>
|
||||
struct expr_less_impl<power<T, Ints1...>, power<T, Ints2...>, Pred> :
|
||||
std::bool_constant<ratio{Ints1...} < ratio{Ints2...}> {};
|
||||
|
||||
/**
|
||||
* @brief Compares two types with a given predicate
|
||||
*
|
||||
* Algorithm accounts not only for explicit types but also for the case when they
|
||||
* are wrapped within `power<T, Num, Den>`.
|
||||
*/
|
||||
template<typename Lhs, typename Rhs, template<typename, typename, auto...> typename Pred>
|
||||
template<typename Lhs, typename Rhs, template<typename, typename> typename Pred>
|
||||
using expr_less = expr_less_impl<Lhs, Rhs, Pred>;
|
||||
|
||||
template<typename T1, typename T2>
|
||||
|
Reference in New Issue
Block a user