diff --git a/src/core/include/units/quantity.h b/src/core/include/units/quantity.h index 84044f09..6621f74a 100644 --- a/src/core/include/units/quantity.h +++ b/src/core/include/units/quantity.h @@ -404,12 +404,6 @@ template Q2> return ret(ret(lhs).count() - ret(rhs).count()); } -template -[[nodiscard]] constexpr Quantity auto operator*(const Rep& lhs, reference) -{ - return quantity(lhs); -} - template requires quantity_value_for_, typename Q1::rep, typename Q2::rep> [[nodiscard]] constexpr Quantity auto operator*(const Q1& lhs, const Q2& rhs) @@ -417,12 +411,6 @@ template return detail::make_quantity(lhs.count() * rhs.count()); } -template -[[nodiscard]] constexpr Quantity auto operator/(const Rep& lhs, reference) -{ - return lhs / quantity::one(); -} - template requires quantity_value_for_, typename Q1::rep, typename Q2::rep> [[nodiscard]] constexpr Quantity auto operator/(const Q1& lhs, const Q2& rhs) diff --git a/src/core/include/units/reference.h b/src/core/include/units/reference.h index 6b32e4a7..89afef24 100644 --- a/src/core/include/units/reference.h +++ b/src/core/include/units/reference.h @@ -27,6 +27,9 @@ namespace units { +template U, QuantityValue Rep> +class quantity; + template U> struct reference; @@ -92,24 +95,28 @@ struct reference { // Hidden Friends // Below friend functions are to be found via argument-dependent lookup only -#if !UNITS_COMP_MSVC - template - friend constexpr Quantity auto operator*(const Rep& lhs, reference); + template + [[nodiscard]] friend constexpr reference_multiply operator*(reference, R2) { return {}; } - template - friend constexpr Quantity auto operator/(const Rep& lhs, reference); -#endif + template + [[nodiscard]] friend constexpr reference_divide operator/(reference, R2) { return {}; } + + template + [[nodiscard]] friend constexpr Quantity auto operator*(const Rep& lhs, reference) + { + return quantity(lhs); + } + + template + [[nodiscard]] friend constexpr Quantity auto operator/(const Rep& lhs, reference) + { + return lhs / quantity::one(); + } friend void /*Use `q * (1 * r)` rather than `q * r`.*/ operator*(Quantity auto, reference) = delete; friend void /*Use `q / (1 * r)` rather than `q / r`.*/ operator/(Quantity auto, reference) = delete; }; -template -[[nodiscard]] constexpr reference_multiply operator*(R1, R2) { return {}; } - -template -[[nodiscard]] constexpr reference_divide operator/(R1, R2) { return {}; } - // type traits namespace detail {