fix: expr_less now also sorts powers

This commit is contained in:
Mateusz Pusz
2025-04-03 08:03:47 +01:00
parent b6c01ffe9a
commit 8cf0f4791e

View File

@ -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>