5 Quantities and units library [quantities]

5.6 Quantity [qty]

5.6.11 Arithmetic operations [qty.arith.ops]

In the following descriptions, let @ be the operator.
template<std::derived_from<quantity> Q, auto R2, typename Rep2> requires CommonlyInvocableQuantities<std::plus<>, quantity, quantity<R2, Rep2>> friend constexpr Quantity auto operator+(const Q& lhs, const quantity<R2, Rep2>& rhs); template<std::derived_from<quantity> Q, auto R2, typename Rep2> requires CommonlyInvocableQuantities<std::minus<>, quantity, quantity<R2, Rep2>> friend constexpr Quantity auto operator-(const Q& lhs, const quantity<R2, Rep2>& rhs); template<std::derived_from<quantity> Q, auto R2, typename Rep2> requires(!treat_as_floating_point<Rep>) && (!treat_as_floating_point<Rep2>) && CommonlyInvocableQuantities<std::modulus<>, quantity, quantity<R2, Rep2>> friend constexpr Quantity auto operator%(const Q& lhs, const quantity<R2, Rep2>& rhs);
Let F be the first argument to CommonlyInvocableQuantities.
Preconditions: If @ is %, then is_neq_zero(rhs) is true.
Effects: Equivalent to: using ret = common-quantity-for<F, quantity, quantity<R2, Rep2>>; const ret ret_lhs(lhs); const ret ret_rhs(rhs); return ::mp_units::quantity{ ret_lhs.numerical_value_ref_in(ret::unit) @ ret_rhs.numerical_value_ref_in(ret::unit), ret::reference};
template<std::derived_from<quantity> Q, Representation Value> requires(Q::unit == ::mp_units::one) && InvokeResultOf<quantity_spec, std::plus<>, Rep, const Value&> friend constexpr Quantity auto operator+(const Q& lhs, const Value& rhs); template<std::derived_from<quantity> Q, Representation Value> requires(Q::unit == ::mp_units::one) && InvokeResultOf<quantity_spec, std::minus<>, Rep, const Value&> friend constexpr Quantity auto operator-(const Q& lhs, const Value& rhs); template<std::derived_from<quantity> Q, Representation Value> requires(Q::unit == ::mp_units::one) && InvokeResultOf<quantity_spec, std::modulus<>, Rep, const Value&> friend constexpr Quantity auto operator%(const Q& lhs, const Value& rhs);
Effects: Equivalent to: return lhs @ ​::​mp_units​::​quantity{rhs};
template<std::derived_from<quantity> Q, Representation Value> requires(Q::unit == ::mp_units::one) && InvokeResultOf<quantity_spec, std::plus<>, Rep, const Value&> friend constexpr Quantity auto operator+(const Value& lhs, const Q& rhs); template<std::derived_from<quantity> Q, Representation Value> requires(Q::unit == ::mp_units::one) && InvokeResultOf<quantity_spec, std::minus<>, Rep, const Value&> friend constexpr Quantity auto operator-(const Value& lhs, const Q& rhs); template<std::derived_from<quantity> Q, Representation Value> requires(Q::unit == ::mp_units::one) && InvokeResultOf<quantity_spec, std::modulus<>, Rep, const Value&> friend constexpr Quantity auto operator%(const Value& lhs, const Q& rhs);
Effects: Equivalent to: return ​::​mp_units​::​quantity{lhs} @ rhs;
template<std::derived_from<quantity> Q, auto R2, typename Rep2> requires InvocableQuantities<std::multiplies<>, quantity, quantity<R2, Rep2>> friend constexpr Quantity auto operator*(const Q& lhs, const quantity<R2, Rep2>& rhs); template<std::derived_from<quantity> Q, auto R2, typename Rep2> requires InvocableQuantities<std::divides<>, quantity, quantity<R2, Rep2>> friend constexpr Quantity auto operator/(const Q& lhs, const quantity<R2, Rep2>& rhs);
Preconditions: If @ is /, then is_neq_zero(rhs) is true.
Effects: Equivalent to: return ::mp_units::quantity{ lhs.numerical_value_ref_in(unit) @ rhs.numerical_value_ref_in(rhs.unit), R @ R2};
template<std::derived_from<quantity> Q, typename Value> requires(!Quantity<Value>) && (!Reference<Value>) && InvokeResultOf<quantity_spec, std::multiplies<>, Rep, const Value&> friend constexpr QuantityOf<quantity_spec> auto operator*(const Q& lhs, const Value& rhs); template<std::derived_from<quantity> Q, typename Value> requires(!Quantity<Value>) && (!Reference<Value>) && InvokeResultOf<quantity_spec, std::divides<>, Rep, const Value&> friend constexpr QuantityOf<quantity_spec> auto operator/(const Q& lhs, const Value& rhs);
Preconditions: If @ is /, then rhs != representation_values<Value>​::​zero() is true.
Effects: Equivalent to: return ::mp_units::quantity{lhs.numerical_value_ref_in(unit) @ rhs, R};
template<typename Value, std::derived_from<quantity> Q> requires(!Quantity<Value>) && (!Reference<Value>) && InvokeResultOf<quantity_spec, std::multiplies<>, const Value&, Rep> friend constexpr QuantityOf<quantity_spec> auto operator*(const Value& lhs, const Q& rhs); template<typename Value, std::derived_from<quantity> Q> requires(!Quantity<Value>) && (!Reference<Value>) && InvokeResultOf<quantity_spec, std::divides<>, const Value&, Rep> friend constexpr Quantity auto operator/(const Value& lhs, const Q& rhs);
Preconditions: If @ is /, then is_neq_zero(rhs) is true.
Effects: Equivalent to: return ::mp_units::quantity{lhs @ rhs.numerical_value_ref_in(unit), ::mp_units::one @ R};