From d6002ce419902382d4b7565481ab098ec973fa5b Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 26 Nov 2024 18:36:37 +0100 Subject: [PATCH] refactor: :boom: `quantity_values` renamed to representation values --- .../mp-units/framework/customization_points.h | 7 +++++-- .../include/mp-units/framework/quantity.h | 20 +++++++++---------- src/core/include/mp-units/math.h | 12 +++++------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/core/include/mp-units/framework/customization_points.h b/src/core/include/mp-units/framework/customization_points.h index f12fb0ef1..d33b111d2 100644 --- a/src/core/include/mp-units/framework/customization_points.h +++ b/src/core/include/mp-units/framework/customization_points.h @@ -87,9 +87,9 @@ constexpr bool is_tensor = false; */ template #if MP_UNITS_HOSTED -struct quantity_values : std::chrono::duration_values { +struct representation_values : std::chrono::duration_values { #else -struct quantity_values { +struct representation_values { static constexpr Rep zero() noexcept requires std::constructible_from { @@ -120,6 +120,9 @@ struct quantity_values { } }; +template +using quantity_values [[deprecated("Use `representation_values` instead")]] = representation_values; + /** * @brief Provides support for external quantity-like types * diff --git a/src/core/include/mp-units/framework/quantity.h b/src/core/include/mp-units/framework/quantity.h index ec6f26bfa..3d829769e 100644 --- a/src/core/include/mp-units/framework/quantity.h +++ b/src/core/include/mp-units/framework/quantity.h @@ -143,27 +143,27 @@ class quantity { // static member functions [[nodiscard]] static constexpr quantity zero() noexcept - requires requires { quantity_values::zero(); } + requires requires { representation_values::zero(); } { - return {quantity_values::zero(), R}; + return {representation_values::zero(), R}; } [[nodiscard]] static constexpr quantity one() noexcept - requires requires { quantity_values::one(); } + requires requires { representation_values::one(); } { - return {quantity_values::one(), R}; + return {representation_values::one(), R}; } [[nodiscard]] static constexpr quantity min() noexcept - requires requires { quantity_values::min(); } + requires requires { representation_values::min(); } { - return {quantity_values::min(), R}; + return {representation_values::min(), R}; } [[nodiscard]] static constexpr quantity max() noexcept - requires requires { quantity_values::max(); } + requires requires { representation_values::max(); } { - return {quantity_values::max(), R}; + return {representation_values::max(), R}; } // construction, assignment, destruction @@ -446,7 +446,7 @@ class quantity { } friend constexpr decltype(auto) operator/=(Q&& lhs, const Value& val) { - MP_UNITS_EXPECTS_DEBUG(val != quantity_values::zero()); + MP_UNITS_EXPECTS_DEBUG(val != representation_values::zero()); // TODO use /= when compiler bug is resolved: // https://developercommunity.visualstudio.com/t/Discrepancy-in-Behavior-of-operator-an/10732445 lhs.numerical_value_is_an_implementation_detail_ = lhs.numerical_value_is_an_implementation_detail_ / val; @@ -577,7 +577,7 @@ class quantity { (!Reference) && detail::InvokeResultOf, Rep, const Value&> [[nodiscard]] friend constexpr QuantityOf auto operator/(const Q& q, const Value& val) { - MP_UNITS_EXPECTS_DEBUG(val != quantity_values::zero()); + MP_UNITS_EXPECTS_DEBUG(val != representation_values::zero()); return ::mp_units::quantity{q.numerical_value_ref_in(unit) / val, R}; } diff --git a/src/core/include/mp-units/math.h b/src/core/include/mp-units/math.h index 490445a2f..8b9e63a70 100644 --- a/src/core/include/mp-units/math.h +++ b/src/core/include/mp-units/math.h @@ -55,7 +55,7 @@ namespace mp_units { */ template requires detail::non_zero && requires(Rep v) { - quantity_values::one(); + representation_values::one(); requires requires { pow(v, 1.0); } || requires { std::pow(v, 1.0); }; } [[nodiscard]] constexpr quantity(R), Rep> pow(const quantity& q) noexcept @@ -328,7 +328,7 @@ template requires((!treat_as_floating_point) || requires(Rep v) { floor(v); } || requires(Rep v) { std::floor(v); }) && (equivalent(To, get_unit(R)) || requires { q.force_in(To); - quantity_values::one(); + representation_values::one(); }) { const auto handle_signed_results = [&](const T& res) { @@ -365,7 +365,7 @@ template requires((!treat_as_floating_point) || requires(Rep v) { ceil(v); } || requires(Rep v) { std::ceil(v); }) && (equivalent(To, get_unit(R)) || requires { q.force_in(To); - quantity_values::one(); + representation_values::one(); }) { const auto handle_signed_results = [&](const T& res) { @@ -404,7 +404,7 @@ template requires((!treat_as_floating_point) || requires(Rep v) { round(v); } || requires(Rep v) { std::round(v); }) && (equivalent(To, get_unit(R)) || requires { ::mp_units::floor(q); - quantity_values::one(); + representation_values::one(); }) { if constexpr (equivalent(To, get_unit(R))) { @@ -438,11 +438,11 @@ template template [[nodiscard]] constexpr QuantityOf auto inverse(const quantity& q) requires requires { - quantity_values::one(); + representation_values::one(); value_cast(1 / q); } { - return (quantity_values::one() * one).force_in(To * quantity::unit) / q; + return (representation_values::one() * one).force_in(To * quantity::unit) / q; } /**