From 14d18a9d3ad1ed56f73f890b406cf69420c32c7b Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 31 Aug 2023 19:00:35 +0200 Subject: [PATCH] style: order of operators changed --- src/core/include/mp-units/quantity.h | 45 +++++++++++----------- src/core/include/mp-units/quantity_point.h | 1 + 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/core/include/mp-units/quantity.h b/src/core/include/mp-units/quantity.h index 13d9e9fa..f35ff1cd 100644 --- a/src/core/include/mp-units/quantity.h +++ b/src/core/include/mp-units/quantity.h @@ -232,6 +232,7 @@ public: return make_quantity(value_--); } + // compound assignment operators constexpr quantity& operator+=(const quantity& q) requires requires(rep a, rep b) { { @@ -254,6 +255,18 @@ public: return *this; } + constexpr quantity& operator%=(const quantity& q) + requires(!treat_as_floating_point) && requires(rep a, rep b) { + { + a %= b + } -> std::same_as; + } + { + gsl_ExpectsAudit(q.numerical_value() != quantity_values::zero()); + value_ %= q.numerical_value(); + return *this; + } + template requires(!Quantity) && requires(rep a, const Value b) { { @@ -304,18 +317,6 @@ public: return *this; } - constexpr quantity& operator%=(const quantity& q) - requires(!treat_as_floating_point) && requires(rep a, rep b) { - { - a %= b - } -> std::same_as; - } - { - gsl_ExpectsAudit(q.numerical_value() != quantity_values::zero()); - value_ %= q.numerical_value(); - return *this; - } - private: #if defined MP_UNITS_COMP_CLANG && MP_UNITS_COMP_CLANG < 17 template @@ -352,6 +353,16 @@ template return make_quantity(ret(lhs).numerical_value() - ret(rhs).numerical_value()); } +template + requires(!treat_as_floating_point) && (!treat_as_floating_point) && + detail::InvocableQuantities, quantity, quantity> +[[nodiscard]] constexpr Quantity auto operator%(const quantity& lhs, const quantity& rhs) +{ + gsl_ExpectsAudit(rhs.numerical_value() != quantity_values::zero()); + using ret = detail::common_quantity_for, quantity, quantity>; + return make_quantity(ret(lhs).numerical_value() % ret(rhs).numerical_value()); +} + template requires detail::InvokeResultOf<(get_quantity_spec(R1) * get_quantity_spec(R2)).character, std::multiplies<>, Rep1, Rep2> @@ -401,16 +412,6 @@ template return make_quantity<::mp_units::one / R>(v / q.numerical_value()); } -template - requires(!treat_as_floating_point) && (!treat_as_floating_point) && - detail::InvocableQuantities, quantity, quantity> -[[nodiscard]] constexpr Quantity auto operator%(const quantity& lhs, const quantity& rhs) -{ - gsl_ExpectsAudit(rhs.numerical_value() != quantity_values::zero()); - using ret = detail::common_quantity_for, quantity, quantity>; - return make_quantity(ret(lhs).numerical_value() % ret(rhs).numerical_value()); -} - template requires requires { typename std::common_type_t, quantity>; } && std::equality_comparable, quantity>::rep> diff --git a/src/core/include/mp-units/quantity_point.h b/src/core/include/mp-units/quantity_point.h index bc5519f7..d736d279 100644 --- a/src/core/include/mp-units/quantity_point.h +++ b/src/core/include/mp-units/quantity_point.h @@ -192,6 +192,7 @@ public: return quantity_point(q_--); } + // compound assignment operators constexpr quantity_point& operator+=(const quantity_type& q) requires requires { q_ += q; } {