From cc521ee72345acc5f29a3829b3f9cfb304801b56 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 3 Oct 2024 20:40:46 +0200 Subject: [PATCH] fix: magnitude compilation fixed --- .../include/mp-units/framework/magnitude.h | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/core/include/mp-units/framework/magnitude.h b/src/core/include/mp-units/framework/magnitude.h index c52074e8b..1c9287838 100644 --- a/src/core/include/mp-units/framework/magnitude.h +++ b/src/core/include/mp-units/framework/magnitude.h @@ -80,6 +80,8 @@ concept MagConstant = { +T::value } -> std::same_as; }; +template +concept MagArg = std::integral || MagConstant; /** * @brief Any type which can be used as a basis vector in a PowerV. @@ -241,8 +243,8 @@ template template [[nodiscard]] consteval auto only_negative_mag_constants(magnitude m); -template - requires detail::gt_zero +template + requires(detail::get_base_value(Base) > 0) [[nodiscard]] consteval Magnitude auto mag_power_lazy(); template @@ -344,13 +346,13 @@ constexpr Out print_separator(Out out, const unit_symbol_formatting& fmt) template Out, auto... Ms> requires(sizeof...(Ms) == 0) -[[nodiscard]] consteval auto mag_constants_text(Out out, magnitude, const unit_symbol_formatting&, bool) +[[nodiscard]] constexpr auto mag_constants_text(Out out, magnitude, const unit_symbol_formatting&, bool) { return out; } template Out, auto M, auto... Rest> -[[nodiscard]] consteval auto mag_constants_text(Out out, magnitude, const unit_symbol_formatting& fmt, +[[nodiscard]] constexpr auto mag_constants_text(Out out, magnitude, const unit_symbol_formatting& fmt, bool negative_power) { auto to_symbol = [&](T v) { @@ -527,7 +529,7 @@ struct magnitude : detail::magnitude_base> { } template - [[nodiscard]] friend consteval detail::ratio _get_power(T base, magnitude) + [[nodiscard]] friend consteval detail::ratio _get_power([[maybe_unused]] T base, magnitude) { return ((detail::get_base_value(Ms) == base ? detail::get_exponent(Ms) : detail::ratio{0}) + ... + detail::ratio{0}); @@ -688,9 +690,6 @@ constexpr auto prime_factorization_v = prime_factorization::value; } // namespace detail -template -concept MagArg = std::integral || MagConstant; - namespace detail { template @@ -707,9 +706,7 @@ template MP_UNITS_EXPORT_BEGIN template -#if !(defined MP_UNITS_COMP_CLANG && MP_UNITS_COMP_CLANG < 18) - requires detail::gt_zero -#endif + requires(detail::get_base_value(V) > 0) constexpr Magnitude auto mag = detail::make_magnitude(); template @@ -720,7 +717,7 @@ 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 - requires detail::gt_zero + requires(detail::get_base_value(Base) > 0) constexpr Magnitude auto mag_power = pow(mag); /** @@ -741,8 +738,8 @@ MP_UNITS_EXPORT_END namespace detail { // This is introduced to break the dependency cycle between `magnitude::_magnitude_text` and `prime_factorization` -template - requires detail::gt_zero +template + requires(detail::get_base_value(Base) > 0) [[nodiscard]] consteval Magnitude auto mag_power_lazy() { return pow(mag);