mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +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
|
// compound assignment operators
|
||||||
constexpr quantity_point& operator+=(const quantity_type& q)
|
template<typename QP>
|
||||||
requires requires { quantity_from_origin_ += q; }
|
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;
|
qp.quantity_from_origin_ += q;
|
||||||
return *this;
|
return std::forward<QP>(qp);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr quantity_point& operator-=(const quantity_type& q)
|
template<typename QP>
|
||||||
requires requires { quantity_from_origin_ -= q; }
|
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;
|
qp.quantity_from_origin_ -= q;
|
||||||
return *this;
|
return std::forward<QP>(qp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user