From b00d061ac8853ddaa12330eb2bc59a61129cf0c0 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 16 Nov 2024 22:10:51 +0100 Subject: [PATCH] refactor: explicit type of `op/` for `quantity` and `reference` replaced with constrained placeholder This prevents additional instantiations of inversed quantities --- src/core/include/mp-units/framework/quantity.h | 2 +- src/core/include/mp-units/framework/reference.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/include/mp-units/framework/quantity.h b/src/core/include/mp-units/framework/quantity.h index 544bfe21f..85c891118 100644 --- a/src/core/include/mp-units/framework/quantity.h +++ b/src/core/include/mp-units/framework/quantity.h @@ -584,7 +584,7 @@ class quantity { template Q> requires(!Quantity) && (!Reference) && detail::InvokeResultOf, const Value&, Rep> - [[nodiscard]] friend constexpr QuantityOf auto operator/(const Value& val, const Q& q) + [[nodiscard]] friend constexpr Quantity auto operator/(const Value& val, const Q& q) { return ::mp_units::quantity{val / q.numerical_value_ref_in(unit), ::mp_units::one / R}; } diff --git a/src/core/include/mp-units/framework/reference.h b/src/core/include/mp-units/framework/reference.h index 10d0597d0..102b09a9c 100644 --- a/src/core/include/mp-units/framework/reference.h +++ b/src/core/include/mp-units/framework/reference.h @@ -199,7 +199,7 @@ template template Rep = std::remove_cvref_t> requires(!detail::OffsetUnit) -[[nodiscard]] constexpr quantity operator/(FwdRep&& lhs, R) +[[nodiscard]] constexpr Quantity auto operator/(FwdRep&& lhs, R) { return quantity{std::forward(lhs), inverse(R{})}; }