From c5a0539cef215b9fb95dbbd48c41915f4b1c6cd2 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 2 Jun 2023 10:53:34 +0200 Subject: [PATCH] refactor: all non-trigonometric math functions made constexpr --- src/utility/include/mp-units/math.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/utility/include/mp-units/math.h b/src/utility/include/mp-units/math.h index 94b3532d..802377dc 100644 --- a/src/utility/include/mp-units/math.h +++ b/src/utility/include/mp-units/math.h @@ -51,7 +51,7 @@ namespace mp_units { */ template requires detail::non_zero -[[nodiscard]] inline auto pow(const Q& q) noexcept +[[nodiscard]] constexpr 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; @@ -75,7 +75,7 @@ template * @return Quantity The result of computation */ template -[[nodiscard]] inline Quantity auto sqrt(const Q& q) noexcept +[[nodiscard]] constexpr Quantity auto sqrt(const Q& q) noexcept requires requires { sqrt(q.number()); } || requires { std::sqrt(q.number()); } { using rep = TYPENAME Q::rep; @@ -93,7 +93,7 @@ template * @return Quantity The result of computation */ template -[[nodiscard]] inline Quantity auto cbrt(const Q& q) noexcept +[[nodiscard]] constexpr Quantity auto cbrt(const Q& q) noexcept requires requires { cbrt(q.number()); } || requires { std::cbrt(q.number()); } { using rep = TYPENAME Q::rep; @@ -111,7 +111,7 @@ template * @return Quantity The value of the same quantity type */ template Q> -[[nodiscard]] inline Q exp(const Q& q) +[[nodiscard]] constexpr Q exp(const Q& q) requires requires { exp(q.number()); } || requires { std::exp(q.number()); } { using std::exp; @@ -125,7 +125,7 @@ template Q> * @return Quantity The absolute value of a provided quantity */ template -[[nodiscard]] inline Q abs(const Q& q) noexcept +[[nodiscard]] constexpr Q abs(const Q& q) noexcept requires requires { abs(q.number()); } || requires { std::abs(q.number()); } { using std::abs; @@ -269,7 +269,7 @@ template * without undue overflow or underflow at intermediate stages of the computation */ template -[[nodiscard]] inline QuantityOf auto hypot( +[[nodiscard]] constexpr QuantityOf auto hypot( const Q1& x, const Q2& y) noexcept requires requires { common_reference(Q1::reference, Q2::reference); } && ( @@ -285,7 +285,7 @@ template * without undue overflow or underflow at intermediate stages of the computation */ template -[[nodiscard]] inline QuantityOf auto +[[nodiscard]] constexpr QuantityOf auto hypot(const Q1& x, const Q2& y, const Q3& z) noexcept requires requires { common_reference(Q1::reference, Q2::reference, Q3::reference); } && (