5 Quantities and units library [quantities]

5.7 Quantity point [qty.pt]

5.7.12 Arithmetic operations [qty.pt.arith.ops]

In the following descriptions, let @ be the operator.
template<std::derived_from<quantity_point> QP, auto R2, typename Rep2> friend constexpr QuantityPoint auto operator+(const QP& qp, const quantity<R2, Rep2>& q) requires see below; template<std::derived_from<quantity_point> QP, auto R2, typename Rep2> friend constexpr QuantityPoint auto operator+(const quantity<R2, Rep2>& q, const QP& qp) requires see below; template<std::derived_from<quantity_point> QP, auto R2, typename Rep2> friend constexpr QuantityPoint auto operator-(const QP& qp, const quantity<R2, Rep2>& q) requires see below;
Effects: Equivalent to: if constexpr (is-specialization-of<PO, zeroth_point_origin>()) return ::mp_units::quantity_point{qp.quantity_ref_from(PO) @ q}; else return ::mp_units::quantity_point{qp.quantity_ref_from(PO) @ q, PO};
Remarks: The expression in the requires-clause is equivalent to: ReferenceOf<decltype(R2), PO.quantity-spec> && requires { qp.quantity_ref_from(PO) @ q; }
template<std::derived_from<quantity_point> QP, QuantityPointOf<absolute_point_origin> QP2> friend constexpr Quantity auto operator-(const QP& lhs, const QP2& rhs) requires see below;
Effects: Equivalent to: return lhs.quantity_ref_from(point_origin) - rhs.quantity_ref_from(QP2::point_origin) + (lhs.point_origin - rhs.point_origin);
Remarks: The expression in the requires-clause is equivalent to: requires { lhs.quantity_ref_from(point_origin) - rhs.quantity_ref_from(QP2::point_origin); }
Recommended practice: The subtraction of two equal origins is not evaluated.
template<std::derived_from<quantity_point> QP, PointOrigin PO2> requires see below friend constexpr Quantity auto operator-(const QP& qp, PO2 po); template<std::derived_from<quantity_point> QP, PointOrigin PO2> requires see below friend constexpr Quantity auto operator-(PO2 po, const QP& qp);
Effects: For the first signature, equivalent to: if constexpr (point_origin == po) return qp.quantity_ref_from(point_origin); else if constexpr (is-derived-from-specialization-of<PO2, ::mp_units::absolute_point_origin>()) { return qp.quantity_ref_from(point_origin) + (qp.point_origin - qp.absolute_point_origin); } else { return qp.quantity_ref_from(point_origin) - po.quantity-point.quantity_ref_from(po.quantity-point.point_origin) + (qp.point_origin - po.quantity-point.point_origin); }
For the second signature, equivalent to: return -(qp - po);
Remarks: The expression in the requires-clause is equivalent to: QuantityPointOf<quantity_point, PO2{}> && ReferenceOf<decltype(auto(reference)), PO2::quantity-spec>
Recommended practice: The subtraction of two equal origins is not evaluated.