mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-08 06:34:27 +02:00
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>
|
||||
[[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>
|
||||
|
@@ -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>)
|
||||
|
Reference in New Issue
Block a user