diff --git a/include/xo/unit/quantity.hpp b/include/xo/unit/quantity.hpp index a121afe5..dea30c2b 100644 --- a/include/xo/unit/quantity.hpp +++ b/include/xo/unit/quantity.hpp @@ -34,6 +34,8 @@ namespace xo { constexpr quantity() : scale_{0} {} explicit constexpr quantity(Repr scale) : scale_{scale} {} + static constexpr bool always_constexpr_unit = true; + constexpr const repr_type & scale() const { return scale_; } constexpr const unit_type & unit() const { return s_unit; } diff --git a/include/xo/unit/xquantity.hpp b/include/xo/unit/xquantity.hpp index 3d3bc6e3..f2d49b2d 100644 --- a/include/xo/unit/xquantity.hpp +++ b/include/xo/unit/xquantity.hpp @@ -41,9 +41,11 @@ namespace xo { constexpr xquantity() : scale_{0}, unit_{natural_unit()} {} constexpr xquantity(Repr scale, - const natural_unit & unit) + const natural_unit & unit) : scale_{scale}, unit_{unit} {} + static constexpr bool always_constexpr_unit = false; + constexpr const repr_type & scale() const { return scale_; } constexpr const unit_type & unit() const { return unit_; } @@ -105,7 +107,7 @@ namespace xo { * static_cast(y.scale())); return xquantity(r_scale, - rr.natural_unit_); + rr.natural_unit_); } template @@ -221,7 +223,7 @@ namespace xo { Repr scale_ = Repr{}; /** @brief unit for this quantity **/ natural_unit unit_; - }; /*Quantity*/ + }; /*xquantity*/ /** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr) **/