From e585fd9e37f917059219876f9da348afa46b646d Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sun, 1 Dec 2024 13:39:14 +0100 Subject: [PATCH] refactor: `reference` now returns explicit types for `inverse`, `pow`, `sqrt`, and `cbrt` --- .../include/mp-units/framework/reference.h | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/core/include/mp-units/framework/reference.h b/src/core/include/mp-units/framework/reference.h index 1ce19b70f..ee9f1ad29 100644 --- a/src/core/include/mp-units/framework/reference.h +++ b/src/core/include/mp-units/framework/reference.h @@ -135,7 +135,12 @@ struct reference { return {}; } - [[nodiscard]] friend consteval auto inverse(reference) { return detail::reference_t{}; } + [[nodiscard]] friend consteval detail::reference_t + inverse(reference) + { + return {}; + } /** * @brief Computes the value of a reference raised to the `Num/Den` power @@ -148,9 +153,11 @@ struct reference { */ template requires detail::non_zero - [[nodiscard]] friend consteval auto pow(reference) + [[nodiscard]] friend consteval detail::reference_t(Q{}))), + MP_UNITS_EXPRESSION_WORKAROUND((pow(U{})))> + pow(reference) { - return detail::reference_t(Q{}), pow(U{})>{}; + return {}; } /** @@ -160,7 +167,12 @@ struct reference { * * @return The result of computation */ - [[nodiscard]] friend consteval auto sqrt(reference) { return detail::reference_t{}; } + [[nodiscard]] friend consteval detail::reference_t + sqrt(reference) + { + return {}; + } /** * @brief Computes the cubic root of a reference @@ -169,7 +181,12 @@ struct reference { * * @return The result of computation */ - [[nodiscard]] friend consteval auto cbrt(reference) { return detail::reference_t{}; } + [[nodiscard]] friend consteval detail::reference_t + cbrt(reference) + { + return {}; + } template [[nodiscard]] friend consteval bool convertible(reference, reference)