diff --git a/src/core/include/units/bits/expression_template.h b/src/core/include/units/bits/expression_template.h index d7bedadd..e142ddce 100644 --- a/src/core/include/units/bits/expression_template.h +++ b/src/core/include/units/bits/expression_template.h @@ -24,6 +24,7 @@ #include #include +#include #include namespace units { @@ -65,10 +66,10 @@ template<> inline constexpr bool valid_ratio<0, 0> = false; template -inline constexpr bool positive_ratio = (Num > 0); +inline constexpr bool positive_ratio = gt_zero; template -inline constexpr bool positive_ratio = (Num * Den > 0); +inline constexpr bool positive_ratio = gt_zero; template inline constexpr bool ratio_one = false; diff --git a/src/core/include/units/bits/math_concepts.h b/src/core/include/units/bits/math_concepts.h index e92acef1..00d67490 100644 --- a/src/core/include/units/bits/math_concepts.h +++ b/src/core/include/units/bits/math_concepts.h @@ -26,10 +26,10 @@ namespace units::detail { -template +template concept gt_zero = (N > 0); -template +template concept non_zero = (N != 0); } // namespace units::detail diff --git a/src/core/include/units/magnitude.h b/src/core/include/units/magnitude.h index 52e4e789..4e10452c 100644 --- a/src/core/include/units/magnitude.h +++ b/src/core/include/units/magnitude.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -732,7 +733,7 @@ namespace detail { // Helper to perform prime factorization at compile time. template - requires(N > 0) + requires gt_zero struct prime_factorization { [[nodiscard]] static consteval std::intmax_t get_or_compute_first_factor() { @@ -767,16 +768,15 @@ inline constexpr auto prime_factorization_v = prime_factorization::value; * This will be the main way end users create Magnitudes. They should rarely (if ever) create a magnitude<...> by * manually adding base powers. */ - template - requires(R.num > 0) + requires detail::gt_zero inline constexpr Magnitude auto mag = detail::prime_factorization_v / detail::prime_factorization_v; /** * @brief Create a Magnitude which is some rational number raised to a rational power. */ template - requires(Base.num > 0) + requires detail::gt_zero inline constexpr Magnitude auto mag_power = pow(mag); namespace detail {