From 5fd8269dcc1371129affa06120b9416785785c02 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 24 Apr 2024 11:35:10 -0400 Subject: [PATCH] xo-unit: + Dimensionless/Quantity --- include/xo/unit/Quantity.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/xo/unit/Quantity.hpp b/include/xo/unit/Quantity.hpp index 604664b2..8f02c32f 100644 --- a/include/xo/unit/Quantity.hpp +++ b/include/xo/unit/Quantity.hpp @@ -242,8 +242,7 @@ namespace xo { return Quantity::divide(x, y); } - /** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr) - **/ + /** note: doesn not require unit scaling, so constexpr with c++23 **/ template requires quantity2_concept && std::is_arithmetic_v constexpr auto @@ -252,6 +251,15 @@ namespace xo { return x.divide_by(y); } + /** note: doesn not require unit scaling, so constexpr with c++23 **/ + template + requires std::is_arithmetic_v && quantity2_concept + constexpr auto + operator/ (Dimensionless x, const Quantity & y) + { + return y.divide_into(x); + } + /** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr) **/ template