From 1a8a386460191e16232aa0bb712805b2f70c02a5 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 3 Oct 2024 10:25:23 +0200 Subject: [PATCH] feat: fractional exponents support added to `mag_power` --- src/core/include/mp-units/framework/magnitude.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/include/mp-units/framework/magnitude.h b/src/core/include/mp-units/framework/magnitude.h index 3ec0254c..898ee2b5 100644 --- a/src/core/include/mp-units/framework/magnitude.h +++ b/src/core/include/mp-units/framework/magnitude.h @@ -248,7 +248,7 @@ template template [[nodiscard]] consteval auto remove_positive_power(magnitude m); -template +template requires detail::gt_zero [[nodiscard]] consteval Magnitude auto mag_power_lazy(); @@ -409,7 +409,7 @@ struct magnitude : detail::magnitude_base> { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Magnitude rational powers implementation. - template + template [[nodiscard]] friend consteval auto pow(magnitude) { if constexpr (Num == 0) { @@ -605,9 +605,9 @@ constexpr Magnitude auto mag_ratio = detail::prime_factorization_v / detail:: /** * @brief Create a Magnitude which is some rational number raised to a rational power. */ -template +template requires detail::gt_zero -constexpr Magnitude auto mag_power = pow(mag); +constexpr Magnitude auto mag_power = pow(mag); /** * @brief A convenient Magnitude constant for pi, which we can manipulate like a regular number. @@ -627,11 +627,11 @@ MP_UNITS_EXPORT_END namespace detail { // This is introduced to break the dependency cycle between `magnitude::_magnitude_text` and `prime_factorization` -template +template requires detail::gt_zero [[nodiscard]] consteval Magnitude auto mag_power_lazy() { - return pow(mag); + return pow(mag); } } // namespace detail