diff --git a/src/core/include/mp-units/quantity_point.h b/src/core/include/mp-units/quantity_point.h index 1f4a4940a..68dc3c4f9 100644 --- a/src/core/include/mp-units/quantity_point.h +++ b/src/core/include/mp-units/quantity_point.h @@ -224,18 +224,22 @@ class quantity_point { } // compound assignment operators - constexpr quantity_point& operator+=(const quantity_type& q) - requires requires { quantity_from_origin_ += q; } + template + requires std::derived_from, quantity_point> && + requires(quantity_type q) { quantity_from_origin_ += q; } + friend constexpr decltype(auto) operator+=(QP&& qp, const quantity_type& q) { - quantity_from_origin_ += q; - return *this; + qp.quantity_from_origin_ += q; + return std::forward(qp); } - constexpr quantity_point& operator-=(const quantity_type& q) - requires requires { quantity_from_origin_ -= q; } + template + requires std::derived_from, quantity_point> && + requires(quantity_type q) { quantity_from_origin_ -= q; } + friend constexpr decltype(auto) operator-=(QP&& qp, const quantity_type& q) { - quantity_from_origin_ -= q; - return *this; + qp.quantity_from_origin_ -= q; + return std::forward(qp); } private: