From e9e3c63aedaca03f87f59ff89b73443053152512 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 23 Apr 2024 00:32:32 -0400 Subject: [PATCH] xo-unit: refactor: Quantity2 -> Quantity --- .../xo/unit/{Quantity2.hpp => Quantity.hpp} | 20 +++++++++---------- include/xo/unit/Quantity2_iostream.hpp | 4 ++-- utest/unit.test.cpp | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) rename include/xo/unit/{Quantity2.hpp => Quantity.hpp} (85%) diff --git a/include/xo/unit/Quantity2.hpp b/include/xo/unit/Quantity.hpp similarity index 85% rename from include/xo/unit/Quantity2.hpp rename to include/xo/unit/Quantity.hpp index 35bc985..1526504 100644 --- a/include/xo/unit/Quantity2.hpp +++ b/include/xo/unit/Quantity.hpp @@ -26,30 +26,30 @@ namespace xo { **/ template - class Quantity2 { + class Quantity { public: using repr_type = Repr; using unit_type = natural_unit; using ratio_int_type = Int; public: - constexpr Quantity2(Repr scale, + constexpr Quantity(Repr scale, const natural_unit & unit) : scale_{scale}, unit_{unit} {} constexpr const repr_type & scale() const { return scale_; } constexpr const unit_type & unit() const { return unit_; } - constexpr Quantity2 unit_qty() const { return Quantity2(1, unit_); } + constexpr Quantity unit_qty() const { return Quantity(1, unit_); } - constexpr Quantity2 reciprocal() const { return Quantity2(1.0 / scale_, unit_.reciprocal()); } + constexpr Quantity reciprocal() const { return Quantity(1.0 / scale_, unit_.reciprocal()); } template static constexpr - auto multiply(const Quantity2 & x, const OtherQuantity & y) { - using r_repr_type = std::common_type_t; - using r_int_type = std::common_type_t; auto rr = detail::nu_product(x.unit(), y.unit()); @@ -59,7 +59,7 @@ namespace xo { * static_cast(x.scale()) * static_cast(y.scale())); - return Quantity2(r_scale, + return Quantity(r_scale, rr.natural_unit_); } @@ -74,9 +74,9 @@ namespace xo { **/ template - inline constexpr Quantity2 + inline constexpr Quantity unit_qty(const scaled_unit & u) { - return Quantity2 + return Quantity (u.outer_scale_exact_.template to() * ::sqrt(u.outer_scale_sq_), u.natural_unit_); } diff --git a/include/xo/unit/Quantity2_iostream.hpp b/include/xo/unit/Quantity2_iostream.hpp index 2c1aa55..c1f6a71 100644 --- a/include/xo/unit/Quantity2_iostream.hpp +++ b/include/xo/unit/Quantity2_iostream.hpp @@ -5,7 +5,7 @@ #pragma once -#include "Quantity2.hpp" +#include "Quantity.hpp" #include namespace xo { @@ -14,7 +14,7 @@ namespace xo { typename Int = std::int64_t> inline std::ostream & operator<< (std::ostream & os, - const Quantity2 & x) + const Quantity & x) { os << "