diff --git a/src/utility/include/mp-units/math.h b/src/utility/include/mp-units/math.h index 802377dc..3c68244f 100644 --- a/src/utility/include/mp-units/math.h +++ b/src/utility/include/mp-units/math.h @@ -51,17 +51,17 @@ namespace mp_units { */ template requires detail::non_zero -[[nodiscard]] constexpr auto pow(const Q& q) noexcept +[[nodiscard]] constexpr Quantity auto pow(const Q& q) noexcept requires requires { pow(q.number(), 1.0); } || requires { std::pow(q.number(), 1.0); } { using rep = TYPENAME Q::rep; if constexpr (Num == 0) { - return rep(1); + return make_quantity(Q::reference)>(rep(1)); } else if constexpr (ratio{Num, Den} == 1) { return q; } else { using std::pow; - return make_quantity(Q::quantity_spec), pow(Q::unit)>{}>( + return make_quantity(Q::reference)>( static_cast(pow(q.number(), static_cast(Num) / static_cast(Den)))); } } @@ -80,8 +80,7 @@ template { using rep = TYPENAME Q::rep; using std::sqrt; - return make_quantity(Q::quantity_spec), pow<1, 2>(Q::unit)>{}>( - static_cast(sqrt(q.number()))); + return make_quantity(static_cast(sqrt(q.number()))); } /** @@ -98,8 +97,7 @@ template { using rep = TYPENAME Q::rep; using std::cbrt; - return make_quantity(Q::quantity_spec), pow<1, 3>(Q::unit)>{}>( - static_cast(cbrt(q.number()))); + return make_quantity(static_cast(cbrt(q.number()))); } /**