mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 12:54:25 +02:00
feat: quantity_point
compound assignment now preserves the value category
This commit is contained in:
@@ -224,18 +224,22 @@ public:
|
||||
}
|
||||
|
||||
// compound assignment operators
|
||||
constexpr quantity_point& operator+=(const quantity_type& q)
|
||||
requires requires { quantity_from_origin_ += q; }
|
||||
template<typename QP>
|
||||
requires std::derived_from<std::remove_cvref_t<QP>, 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>(qp);
|
||||
}
|
||||
|
||||
constexpr quantity_point& operator-=(const quantity_type& q)
|
||||
requires requires { quantity_from_origin_ -= q; }
|
||||
template<typename QP>
|
||||
requires std::derived_from<std::remove_cvref_t<QP>, 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>(qp);
|
||||
}
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user