Skip to content

Commit

Permalink
xo-unit: operator<=> for (xquantity, double) pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rconybea committed May 1, 2024
1 parent 022bef0 commit 6a949d1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions include/xo/unit/xquantity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,26 @@ namespace xo {
return Quantity::compare(x, y);
}

/** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr)
**/
template <typename Quantity, double>
requires quantity2_concept<Quantity>
constexpr auto
operator<=> (const Quantity & x, double y)
{
return Quantity::compare(x, Quantity(y, nu::dimensionless));
}

/** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr)
**/
template <typename Quantity, double>
requires quantity2_concept<Quantity>
constexpr auto
operator<=> (double x, const Quantity & y)
{
return Quantity::compare(Quantity(x, nu::dimensionless), y);
}

namespace unit {
constexpr auto nanogram = natural_unit_qty(nu::nanogram);
}
Expand Down

0 comments on commit 6a949d1

Please sign in to comment.