diff --git a/include/xo/unit/quantity.hpp b/include/xo/unit/quantity.hpp index dded38d5..de061b1f 100644 --- a/include/xo/unit/quantity.hpp +++ b/include/xo/unit/quantity.hpp @@ -160,68 +160,70 @@ namespace xo { return x.template rescale(); } - struct quantity_util { - /* parallel implementation to Quantity multiply, - * but return type will have dimension computed at compile-time - */ - template - requires (quantity_concept - && quantity_concept - && Q1::always_constexpr_unit - && Q2::always_constexpr_unit) - static constexpr auto multiply(Q1 x, Q2 y) { - using r_repr_type = std::common_type_t; - using r_int_type = std::common_type_t; - using r_int2x_type = std::common_type_t; + namespace detail { + struct quantity_util { + /* parallel implementation to Quantity multiply, + * but return type will have dimension computed at compile-time + */ + template + requires (quantity_concept + && quantity_concept + && Q1::always_constexpr_unit + && Q2::always_constexpr_unit) + static constexpr auto multiply(Q1 x, Q2 y) { + using r_repr_type = std::common_type_t; + using r_int_type = std::common_type_t; + using r_int2x_type = std::common_type_t; - constexpr auto rr = detail::su_product(x.unit(), y.unit()); + constexpr auto rr = detail::su_product(x.unit(), y.unit()); - r_repr_type r_scale = (((rr.outer_scale_sq_ == 1.0) - ? 1.0 - : ::sqrt(rr.outer_scale_sq_)) - * rr.outer_scale_factor_.template convert_to() - * static_cast(x.scale()) - * static_cast(y.scale())); + r_repr_type r_scale = (((rr.outer_scale_sq_ == 1.0) + ? 1.0 + : ::sqrt(rr.outer_scale_sq_)) + * rr.outer_scale_factor_.template convert_to() + * static_cast(x.scale()) + * static_cast(y.scale())); - return quantity(r_scale); - } + return quantity(r_scale); + } - template - requires (quantity_concept - && quantity_concept - && Q1::always_constexpr_unit - && Q2::always_constexpr_unit) - static constexpr auto divide(Q1 x, Q2 y) { - using r_repr_type = std::common_type_t; - using r_int_type = std::common_type_t; - using r_int2x_type = std::common_type_t; + template + requires (quantity_concept + && quantity_concept + && Q1::always_constexpr_unit + && Q2::always_constexpr_unit) + static constexpr auto divide(Q1 x, Q2 y) { + using r_repr_type = std::common_type_t; + using r_int_type = std::common_type_t; + using r_int2x_type = std::common_type_t; - constexpr auto rr = detail::su_ratio(x.unit(), y.unit()); + constexpr auto rr = detail::su_ratio(x.unit(), y.unit()); - r_repr_type r_scale = (((rr.outer_scale_sq_ == 1.0) - ? 1.0 - : ::sqrt(rr.outer_scale_sq_)) - * rr.outer_scale_factor_.template convert_to() - * static_cast(x.scale()) - / static_cast(y.scale())); + r_repr_type r_scale = (((rr.outer_scale_sq_ == 1.0) + ? 1.0 + : ::sqrt(rr.outer_scale_sq_)) + * rr.outer_scale_factor_.template convert_to() + * static_cast(x.scale()) + / static_cast(y.scale())); - return quantity(r_scale); - } - }; + return quantity(r_scale); + } + }; + } /*namespace detail*/ template Unit = Q2::s_unit> requires (quantity_concept @@ -244,7 +246,7 @@ namespace xo { constexpr auto operator* (const Q1 & x, const Q2 & y) { - return quantity_util::multiply(x, y); + return detail::quantity_util::multiply(x, y); } /** note: won't have constexpr result w/ fractional dimension until c++26 (when ::sqrt(), ::pow() are constexpr) @@ -257,7 +259,7 @@ namespace xo { constexpr auto operator/ (const Q1 & x, const Q2 & y) { - return quantity_util::divide(x, y); + return detail::quantity_util::divide(x, y); } namespace qty { diff --git a/include/xo/unit/scaled_unit.hpp b/include/xo/unit/scaled_unit.hpp index 9c936af6..a7e286df 100644 --- a/include/xo/unit/scaled_unit.hpp +++ b/include/xo/unit/scaled_unit.hpp @@ -46,8 +46,6 @@ namespace xo { } namespace su { - /* note: probably retire these */ - constexpr auto nanogram = detail::make_unit_rescale_result(nu::nanogram); constexpr auto microgram = detail::make_unit_rescale_result(nu::microgram); diff --git a/utest/quantity.test.cpp b/utest/quantity.test.cpp index 3496841d..2dd8f3f7 100644 --- a/utest/quantity.test.cpp +++ b/utest/quantity.test.cpp @@ -407,7 +407,7 @@ namespace xo { static_assert(rr.outer_scale_sq_ == 1.0); } - constexpr auto q2 = quantity_util::multiply(ms, ms); + constexpr auto q2 = detail::quantity_util::multiply(ms, ms); /* proof that q2 is constexpr */ static_assert(q2.scale() == 1.0); @@ -460,7 +460,7 @@ namespace xo { static_assert(rr.outer_scale_sq_ == 1.0); } - constexpr auto q2 = quantity_util::divide(ms, ms); + constexpr auto q2 = detail::quantity_util::divide(ms, ms); /* proof that q2 is constexpr */ static_assert(q2.scale() == 1.0);