Unify "H1 base smaller" test cases

This might actually fix the error!
This commit is contained in:
Chip Hogg
2022-01-12 10:47:59 -05:00
parent 038616c901
commit 1c70b18709

View File

@@ -287,12 +287,14 @@ constexpr auto operator*(Magnitude auto m, magnitude<>) { return m; }
// Recursive case for the product of any two non-identity Magnitudes.
template<BasePower auto H1, BasePower auto... T1, BasePower auto H2, BasePower auto... T2>
constexpr auto operator*(magnitude<H1, T1...>, magnitude<H2, T2...>) {
// Shortcut for the "pure prepend" case, which makes it easier to implement some of the other cases.
if constexpr ((sizeof...(T1) == 0) && H1.get_base() < H2.get_base()) { return magnitude<H1, H2, T2...>{}; }
// Case for when H1 has the smaller base.
if constexpr(H1.get_base() < H2.get_base()){
return magnitude<H1>{} * (magnitude<T1...>{} * magnitude<H2, T2...>{});
if constexpr (sizeof...(T1) == 0) {
// Shortcut for the "pure prepend" case, which makes it easier to implement some of the other cases.
return magnitude<H1, H2, T2...>{};
} else {
return magnitude<H1>{} * (magnitude<T1...>{} * magnitude<H2, T2...>{});
}
}
// Case for when H2 has the smaller base.