xo-unit: + Quantity.compare()
This commit is contained in:
parent
c46a66565c
commit
be56b6f609
1 changed files with 9 additions and 1 deletions
|
|
@ -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{};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue