diff --git a/src/core/include/mp-units/framework/magnitude.h b/src/core/include/mp-units/framework/magnitude.h index 814b2e8c..66cec209 100644 --- a/src/core/include/mp-units/framework/magnitude.h +++ b/src/core/include/mp-units/framework/magnitude.h @@ -515,11 +515,11 @@ MP_UNITS_EXPORT_BEGIN */ template requires(decltype(is_integral(magnitude{}))::value) || treat_as_floating_point -constexpr auto get_value(const magnitude&) +constexpr T get_value(const magnitude&) { // Force the expression to be evaluated in a constexpr context, to catch, e.g., overflow. - constexpr auto result = detail::checked_static_cast((detail::compute_base_power(Ms) * ... * T{1})); - return std::integral_constant{}; + constexpr T result = detail::checked_static_cast((detail::compute_base_power(Ms) * ... * T{1})); + return result; } /** @@ -859,14 +859,14 @@ template // TODO address the below static_assert(base{} == num{} / den{}, "Printing rational powers, or irrational bases, not yet supported"); - using num_value = decltype(get_value(num{})); - using den_value = decltype(get_value(den{})); + constexpr auto num_value = get_value(num{}); + constexpr auto den_value = get_value(den{}); - if constexpr (num_value{} == 1 && den_value{} == 1 && exp10 != 0) { + if constexpr (num_value == 1 && den_value == 1 && exp10 != 0) { return base_multiplier + superscript(); - } else if constexpr (num_value{} != 1 || den_value{} != 1 || exp10 != 0) { - auto txt = symbol_text("[") + regular(); - if constexpr (den_value{} == 1) { + } else if constexpr (num_value != 1 || den_value != 1 || exp10 != 0) { + auto txt = symbol_text("[") + regular(); + if constexpr (den_value == 1) { if constexpr (exp10 == 0) { return txt + symbol_text("]"); } else { @@ -874,9 +874,9 @@ template } } else { if constexpr (exp10 == 0) { - return txt + symbol_text("/") + regular() + symbol_text("]"); + return txt + symbol_text("/") + regular() + symbol_text("]"); } else { - return txt + symbol_text("/") + regular() + symbol_text(" ") + base_multiplier + + return txt + symbol_text("/") + regular() + symbol_text(" ") + base_multiplier + superscript() + symbol_text("]"); } } diff --git a/src/systems/include/mp-units/systems/si/chrono.h b/src/systems/include/mp-units/systems/si/chrono.h index f5ae45a7..e86dd153 100644 --- a/src/systems/include/mp-units/systems/si/chrono.h +++ b/src/systems/include/mp-units/systems/si/chrono.h @@ -118,8 +118,7 @@ namespace detail { constexpr auto as_ratio(Magnitude auto m) requires(decltype(is_rational(decltype(m){}))::value) { - return std::ratio(numerator(m))){}, - decltype(get_value(denominator(m))){}>{}; + return std::ratio(numerator(m)), get_value(denominator(m))>{}; } } // namespace detail