mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-02 11:54:27 +02:00
style: order of operators changed
This commit is contained in:
@@ -232,6 +232,7 @@ public:
|
||||
return make_quantity<reference>(value_--);
|
||||
}
|
||||
|
||||
// compound assignment operators
|
||||
constexpr quantity& operator+=(const quantity& q)
|
||||
requires requires(rep a, rep b) {
|
||||
{
|
||||
@@ -254,6 +255,18 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr quantity& operator%=(const quantity& q)
|
||||
requires(!treat_as_floating_point<rep>) && requires(rep a, rep b) {
|
||||
{
|
||||
a %= b
|
||||
} -> std::same_as<rep&>;
|
||||
}
|
||||
{
|
||||
gsl_ExpectsAudit(q.numerical_value() != quantity_values<rep>::zero());
|
||||
value_ %= q.numerical_value();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
requires(!Quantity<Value>) && requires(rep a, const Value b) {
|
||||
{
|
||||
@@ -304,18 +317,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr quantity& operator%=(const quantity& q)
|
||||
requires(!treat_as_floating_point<rep>) && requires(rep a, rep b) {
|
||||
{
|
||||
a %= b
|
||||
} -> std::same_as<rep&>;
|
||||
}
|
||||
{
|
||||
gsl_ExpectsAudit(q.numerical_value() != quantity_values<rep>::zero());
|
||||
value_ %= q.numerical_value();
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
#if defined MP_UNITS_COMP_CLANG && MP_UNITS_COMP_CLANG < 17
|
||||
template<auto R2, typename Rep2>
|
||||
@@ -352,6 +353,16 @@ template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
return make_quantity<ret::reference>(ret(lhs).numerical_value() - ret(rhs).numerical_value());
|
||||
}
|
||||
|
||||
template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
requires(!treat_as_floating_point<Rep1>) && (!treat_as_floating_point<Rep2>) &&
|
||||
detail::InvocableQuantities<std::modulus<>, quantity<R1, Rep1>, quantity<R2, Rep2>>
|
||||
[[nodiscard]] constexpr Quantity auto operator%(const quantity<R1, Rep1>& lhs, const quantity<R2, Rep2>& rhs)
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.numerical_value() != quantity_values<Rep1>::zero());
|
||||
using ret = detail::common_quantity_for<std::modulus<>, quantity<R1, Rep1>, quantity<R2, Rep2>>;
|
||||
return make_quantity<ret::reference>(ret(lhs).numerical_value() % ret(rhs).numerical_value());
|
||||
}
|
||||
|
||||
template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
requires detail::InvokeResultOf<(get_quantity_spec(R1) * get_quantity_spec(R2)).character, std::multiplies<>, Rep1,
|
||||
Rep2>
|
||||
@@ -401,16 +412,6 @@ template<typename Value, auto R, typename Rep>
|
||||
return make_quantity<::mp_units::one / R>(v / q.numerical_value());
|
||||
}
|
||||
|
||||
template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
requires(!treat_as_floating_point<Rep1>) && (!treat_as_floating_point<Rep2>) &&
|
||||
detail::InvocableQuantities<std::modulus<>, quantity<R1, Rep1>, quantity<R2, Rep2>>
|
||||
[[nodiscard]] constexpr Quantity auto operator%(const quantity<R1, Rep1>& lhs, const quantity<R2, Rep2>& rhs)
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.numerical_value() != quantity_values<Rep1>::zero());
|
||||
using ret = detail::common_quantity_for<std::modulus<>, quantity<R1, Rep1>, quantity<R2, Rep2>>;
|
||||
return make_quantity<ret::reference>(ret(lhs).numerical_value() % ret(rhs).numerical_value());
|
||||
}
|
||||
|
||||
template<auto R1, typename Rep1, auto R2, typename Rep2>
|
||||
requires requires { typename std::common_type_t<quantity<R1, Rep1>, quantity<R2, Rep2>>; } &&
|
||||
std::equality_comparable<typename std::common_type_t<quantity<R1, Rep1>, quantity<R2, Rep2>>::rep>
|
||||
|
@@ -192,6 +192,7 @@ public:
|
||||
return quantity_point(q_--);
|
||||
}
|
||||
|
||||
// compound assignment operators
|
||||
constexpr quantity_point& operator+=(const quantity_type& q)
|
||||
requires requires { q_ += q; }
|
||||
{
|
||||
|
Reference in New Issue
Block a user