From 530a569cfa01de2a82b0de421e2f7d7b3754d801 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 10 Jun 2024 12:03:34 -0400 Subject: [PATCH] xo-unit: + quantity methods is_negative()/is_positive() --- include/xo/unit/quantity.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/xo/unit/quantity.hpp b/include/xo/unit/quantity.hpp index e986b95f..ac75e04a 100644 --- a/include/xo/unit/quantity.hpp +++ b/include/xo/unit/quantity.hpp @@ -78,6 +78,11 @@ namespace xo { /** @brief s_unit in quantity representing amount (@c scale_ * @c s_unit) **/ constexpr const unit_type & unit() const { return s_scaled_unit; } + /** @brief true iff this quantity is strictly negative **/ + constexpr bool is_negative() const { return scale_ < Repr{0}; } + /** @brief true iff this quantity is strictly positive **/ + constexpr bool is_positive() const { return scale_ > Repr{0}; } + /** @brief true iff this quantity represents a dimensionless value **/ static constexpr bool is_dimensionless() { return s_scaled_unit.is_dimensionless();