From 6a949d16c53bf83a825c340883842b54b2fb61ee Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 1 May 2024 14:30:51 -0400 Subject: [PATCH] xo-unit: operator<=> for (xquantity, double) pairs --- include/xo/unit/xquantity.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/xo/unit/xquantity.hpp b/include/xo/unit/xquantity.hpp index c03de0e..ca2bb2e 100644 --- a/include/xo/unit/xquantity.hpp +++ b/include/xo/unit/xquantity.hpp @@ -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 + requires quantity2_concept + 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 + requires quantity2_concept + 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); }