From 2312fd7d57e279591d129b36482ad163816815f0 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 23 Apr 2024 00:30:17 -0400 Subject: [PATCH] xo-unit: refactor: use natural_unit<> instead of unit2<> --- include/xo/unit/Quantity2.hpp | 14 ++++++++------ include/xo/unit/bpu.hpp | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/xo/unit/Quantity2.hpp b/include/xo/unit/Quantity2.hpp index b44bf0f..7fe5748 100644 --- a/include/xo/unit/Quantity2.hpp +++ b/include/xo/unit/Quantity2.hpp @@ -7,7 +7,7 @@ #include "quantity2_concept.hpp" #include "scaled_unit2.hpp" -#include "unit2.hpp" +#include "natural_unit.hpp" namespace xo { namespace qty { @@ -29,11 +29,12 @@ namespace xo { class Quantity2 { public: using repr_type = Repr; - using unit_type = unit2; + using unit_type = natural_unit; using ratio_int_type = Int; public: - constexpr Quantity2(Repr scale, const unit2 & unit) + constexpr Quantity2(Repr scale, + const natural_unit & unit) : scale_{scale}, unit_{unit} {} constexpr const repr_type & scale() const { return scale_; } @@ -66,7 +67,7 @@ namespace xo { /** @brief quantity represents this multiple of a unit amount **/ Repr scale_ = Repr{}; /** @brief unit for this quantity **/ - unit2 unit_; + natural_unit unit_; }; /*Quantity2*/ /** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr) @@ -75,8 +76,9 @@ namespace xo { typename Int = std::int64_t> inline constexpr Quantity2 unit_qty(const scaled_unit2 & u) { - return Quantity2(u.outer_scale_exact_.template to() * ::sqrt(u.outer_scale_sq_), - u.natural_unit_); + return Quantity2 + (u.outer_scale_exact_.template to() * ::sqrt(u.outer_scale_sq_), + u.natural_unit_); } /** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr) diff --git a/include/xo/unit/bpu.hpp b/include/xo/unit/bpu.hpp index 2c9a6c1..74a5052 100644 --- a/include/xo/unit/bpu.hpp +++ b/include/xo/unit/bpu.hpp @@ -40,8 +40,8 @@ namespace xo { static constexpr bpu_abbrev_type bpu_abbrev(dim native_dim, - const scalefactor_ratio_type & scalefactor, - const power_ratio_type & power) + const scalefactor_ratio_type & scalefactor, + const power_ratio_type & power) { return (bpu_abbrev_type::from_flatstring (flatstring_concat