mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-08 06:34:27 +02:00
fix: quantity construction fixed in some operators
This commit is contained in:
@@ -378,16 +378,14 @@ public:
|
|||||||
requires detail::InvokeResultOf<quantity_spec.character, std::multiplies<>, rep, const Value&>
|
requires detail::InvokeResultOf<quantity_spec.character, std::multiplies<>, rep, const Value&>
|
||||||
[[nodiscard]] friend constexpr Quantity auto operator*(const quantity& q, const Value& v)
|
[[nodiscard]] friend constexpr Quantity auto operator*(const quantity& q, const Value& v)
|
||||||
{
|
{
|
||||||
using ret = quantity<R, std::invoke_result_t<std::multiplies<>, rep, Value>>;
|
return q.number() * v * R;
|
||||||
return ret(q.number() * v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<Representation Value>
|
template<Representation Value>
|
||||||
requires detail::InvokeResultOf<quantity_spec.character, std::multiplies<>, const Value&, rep>
|
requires detail::InvokeResultOf<quantity_spec.character, std::multiplies<>, const Value&, rep>
|
||||||
[[nodiscard]] friend constexpr Quantity auto operator*(const Value& v, const quantity& q)
|
[[nodiscard]] friend constexpr Quantity auto operator*(const Value& v, const quantity& q)
|
||||||
{
|
{
|
||||||
using ret = quantity<R, std::invoke_result_t<std::multiplies<>, Value, rep>>;
|
return v * q.number() * R;
|
||||||
return ret(v * q.number());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Value>
|
template<typename Value>
|
||||||
@@ -395,8 +393,7 @@ public:
|
|||||||
[[nodiscard]] friend constexpr Quantity auto operator/(const quantity& q, const Value& v)
|
[[nodiscard]] friend constexpr Quantity auto operator/(const quantity& q, const Value& v)
|
||||||
{
|
{
|
||||||
gsl_ExpectsAudit(v != quantity_values<Value>::zero());
|
gsl_ExpectsAudit(v != quantity_values<Value>::zero());
|
||||||
using ret = quantity<R, std::invoke_result_t<std::divides<>, rep, Value>>;
|
return q.number() / v * R;
|
||||||
return ret(q.number() / v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Value>
|
template<typename Value>
|
||||||
@@ -412,16 +409,14 @@ public:
|
|||||||
[[nodiscard]] friend constexpr Quantity auto operator%(const quantity& q, const Value& v)
|
[[nodiscard]] friend constexpr Quantity auto operator%(const quantity& q, const Value& v)
|
||||||
{
|
{
|
||||||
gsl_ExpectsAudit(v != quantity_values<Value>::zero());
|
gsl_ExpectsAudit(v != quantity_values<Value>::zero());
|
||||||
using ret = quantity<R, std::invoke_result_t<std::modulus<>, rep, Value>>;
|
return q.number() % v * R;
|
||||||
return ret(q.number() % v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] friend constexpr Quantity auto operator%(const quantity& lhs, const quantity& rhs)
|
[[nodiscard]] friend constexpr Quantity auto operator%(const quantity& lhs, const quantity& rhs)
|
||||||
requires(!treat_as_floating_point<rep>) && detail::InvokeResultOf<quantity_spec.character, std::modulus<>, rep, rep>
|
requires(!treat_as_floating_point<rep>) && detail::InvokeResultOf<quantity_spec.character, std::modulus<>, rep, rep>
|
||||||
{
|
{
|
||||||
gsl_ExpectsAudit(rhs.number() != quantity_values<rep>::zero());
|
gsl_ExpectsAudit(rhs.number() != quantity_values<rep>::zero());
|
||||||
using ret = quantity<R, std::invoke_result_t<std::modulus<>, rep, rep>>;
|
return lhs.number() % rhs.number() * R;
|
||||||
return ret(lhs.number() % rhs.number());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] friend constexpr auto operator<=>(const quantity& lhs, const quantity& rhs)
|
[[nodiscard]] friend constexpr auto operator<=>(const quantity& lhs, const quantity& rhs)
|
||||||
|
Reference in New Issue
Block a user