xo-unit: + Quantity.compare()

This commit is contained in:
Roland Conybeare 2024-04-24 11:32:17 -04:00
commit be56b6f609

View file

@ -94,7 +94,7 @@ namespace xo {
* static_cast<r_repr_type>(y.scale()));
return Quantity<r_repr_type, r_int_type>(r_scale,
rr.natural_unit_);
rr.natural_unit_);
}
template <typename Quantity2>
@ -169,6 +169,14 @@ namespace xo {
}
}
template <typename Quantity2>
static constexpr
auto compare(const Quantity & x, const Quantity2 & y) {
Quantity y2 = y.rescale(x.unit_);
return x.scale() <=> y2.scale();
}
private:
/** @brief quantity represents this multiple of a unit amount **/
Repr scale_ = Repr{};