forked from mpusz/mp-units
feat: call operator of reference does not produce a quantity anymore
This commit is contained in:
@@ -483,7 +483,7 @@ template<Quantity Q1, Quantity Q2>
|
|||||||
typename Q1::rep, typename Q2::rep>
|
typename Q1::rep, typename Q2::rep>
|
||||||
[[nodiscard]] constexpr Quantity auto operator*(const Q1& lhs, const Q2& rhs)
|
[[nodiscard]] constexpr Quantity auto operator*(const Q1& lhs, const Q2& rhs)
|
||||||
{
|
{
|
||||||
return (Q1::reference * Q2::reference)(lhs.number() * rhs.number());
|
return lhs.number() * rhs.number() * (Q1::reference * Q2::reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<Quantity Q1, Quantity Q2>
|
template<Quantity Q1, Quantity Q2>
|
||||||
@@ -492,7 +492,7 @@ template<Quantity Q1, Quantity Q2>
|
|||||||
[[nodiscard]] constexpr Quantity auto operator/(const Q1& lhs, const Q2& rhs)
|
[[nodiscard]] constexpr Quantity auto operator/(const Q1& lhs, const Q2& rhs)
|
||||||
{
|
{
|
||||||
gsl_ExpectsAudit(rhs.number() != quantity_values<typename Q2::rep>::zero());
|
gsl_ExpectsAudit(rhs.number() != quantity_values<typename Q2::rep>::zero());
|
||||||
return (Q1::reference / Q2::reference)(lhs.number() / rhs.number());
|
return lhs.number() / rhs.number() * (Q1::reference / Q2::reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<Quantity Q1, Quantity Q2>
|
template<Quantity Q1, Quantity Q2>
|
||||||
|
@@ -101,14 +101,7 @@ class quantity;
|
|||||||
* `2 / kmph`, `kmph * 3`, `kmph / 4`, `70 * isq::length[km] / isq:time[h]`.
|
* `2 / kmph`, `kmph * 3`, `kmph / 4`, `70 * isq::length[km] / isq:time[h]`.
|
||||||
*/
|
*/
|
||||||
template<QuantitySpec auto Q, Unit auto U>
|
template<QuantitySpec auto Q, Unit auto U>
|
||||||
struct reference {
|
struct reference {};
|
||||||
template<RepresentationOf<Q.character> Rep>
|
|
||||||
// TODO can we somehow return an explicit quantity type here?
|
|
||||||
[[nodiscard]] constexpr std::same_as<quantity<reference{}, Rep>> auto operator()(Rep&& value) const
|
|
||||||
{
|
|
||||||
return quantity<reference{}, Rep>(std::forward<Rep>(value));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<auto Q1, auto U1, auto Q2, auto U2>
|
template<auto Q1, auto U1, auto Q2, auto U2>
|
||||||
[[nodiscard]] consteval bool operator==(reference<Q1, U1>, reference<Q2, U2>)
|
[[nodiscard]] consteval bool operator==(reference<Q1, U1>, reference<Q2, U2>)
|
||||||
|
Reference in New Issue
Block a user