diff --git a/src/core/include/units/magnitude.h b/src/core/include/units/magnitude.h index 09343c86..4e35a4fb 100644 --- a/src/core/include/units/magnitude.h +++ b/src/core/include/units/magnitude.h @@ -44,7 +44,7 @@ constexpr bool is_prime(std::intmax_t n); // Integer rep is for prime numbers; long double is for any irrational base we permit. template -concept BaseRep = std::is_same_v || std::is_same_v; +concept BaseRep = std::is_same_v || std::is_same_v; /** * @brief A basis vector in our magnitude representation, raised to some rational power. @@ -60,11 +60,21 @@ concept BaseRep = std::is_same_v || std::is_same_v; */ template struct base_power { - // The value of the basis vector. - T base; + // The rational power to which the base is raised. + ratio power{1}; + + constexpr long double get_base() const { return T::value; } +}; + +template<> +struct base_power { + // The value of the basis "vector". + int base; // The rational power to which the base is raised. ratio power{1}; + + constexpr int get_base() const { return base; } }; template U> @@ -94,10 +104,15 @@ constexpr bool is_valid_base_power(const base_power &bp) { else if constexpr (std::is_same_v) { return bp.base > 0; } else { return false; } // Unreachable. } + +template +struct is_base_power : std::false_type {}; +template +struct is_base_power> : std::true_type {}; } // namespace detail template -concept BasePower = std::is_same_v> || std::is_same_v>; +concept BasePower = detail::is_base_power::value; /** * @brief A representation for positive real numbers which optimizes taking products and rational powers. @@ -107,7 +122,7 @@ concept BasePower = std::is_same_v> || std::is_same_v requires requires { - // (is_valid_base_power(BasePowers) && ... && strictly_increasing(std::make_tuple(BasePowers.base...))); + // (is_valid_base_power(BasePowers) && ... && strictly_increasing(BasePowers.base...)); (detail::is_valid_base_power(BasePowers) && ...); } struct magnitude {};