From a91c90fad4088db26a218e1f28a070875661d5ad Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 1 May 2024 10:25:44 -0500 Subject: [PATCH] xo-unit: operator+ overloads for (xquantity, double) --- 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 84807aa4..92e31a89 100644 --- a/include/xo/unit/xquantity.hpp +++ b/include/xo/unit/xquantity.hpp @@ -311,6 +311,26 @@ namespace xo { return Quantity::add(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 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(x, nu::dimensionless) + y; + } + /** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr) **/ template