feat: call operator of reference does not produce a quantity anymore

This commit is contained in:
Mateusz Pusz
2023-02-06 22:39:23 -08:00
parent ebccabc94c
commit 8de74eb6f7
2 changed files with 3 additions and 10 deletions

View File

@@ -483,7 +483,7 @@ template<Quantity Q1, Quantity Q2>
typename Q1::rep, typename Q2::rep>
[[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>
@@ -492,7 +492,7 @@ template<Quantity Q1, Quantity Q2>
[[nodiscard]] constexpr Quantity auto operator/(const Q1& lhs, const Q2& rhs)
{
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>

View File

@@ -101,14 +101,7 @@ class quantity;
* `2 / kmph`, `kmph * 3`, `kmph / 4`, `70 * isq::length[km] / isq:time[h]`.
*/
template<QuantitySpec auto Q, Unit auto U>
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));
}
};
struct reference {};
template<auto Q1, auto U1, auto Q2, auto U2>
[[nodiscard]] consteval bool operator==(reference<Q1, U1>, reference<Q2, U2>)