From d6d17c6c6ee509958836d5ff88e785ef2ab26991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Sun, 31 May 2020 15:07:27 -0400 Subject: [PATCH] refactor: nodiscard to type level --- src/include/units/quantity_point.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/include/units/quantity_point.h b/src/include/units/quantity_point.h index f15e20e4..d80711b5 100644 --- a/src/include/units/quantity_point.h +++ b/src/include/units/quantity_point.h @@ -38,7 +38,7 @@ namespace units { * @tparam Rep a type to be used to represent values of a quantity point */ template U, Scalar Rep = double> -class quantity_point { +class [[nodiscard]] quantity_point { public: using quantity_type = quantity; using dimension = typename quantity_type::dimension; @@ -67,7 +67,7 @@ public: [[nodiscard]] constexpr quantity_type relative() const noexcept { return q_; } template - [[nodiscard]] static constexpr quantity_point min() noexcept + static constexpr quantity_point min() noexcept requires requires { Q::min(); } // requires requires { quantity_type::min(); } // TODO gated by gcc-9 (fixed in gcc-10) { @@ -75,7 +75,7 @@ public: } template - [[nodiscard]] static constexpr quantity_point max() noexcept + static constexpr quantity_point max() noexcept requires requires { Q::max(); } // requires requires { quantity_type::max(); } // TODO gated by gcc-9 (fixed in gcc-10) { @@ -202,19 +202,19 @@ public: template quantity_point(quantity) -> quantity_point; -[[nodiscard]] constexpr QuantityPoint AUTO operator+(const QuantityPoint AUTO& lhs, const Quantity AUTO& rhs) +constexpr QuantityPoint AUTO operator+(const QuantityPoint AUTO& lhs, const Quantity AUTO& rhs) requires requires { lhs.relative() + rhs; } { return quantity_point(lhs.relative() + rhs); } -[[nodiscard]] constexpr QuantityPoint AUTO operator+(const Quantity AUTO& lhs, const QuantityPoint AUTO& rhs) +constexpr QuantityPoint AUTO operator+(const Quantity AUTO& lhs, const QuantityPoint AUTO& rhs) requires requires { rhs + lhs; } { return rhs + lhs; } -[[nodiscard]] constexpr QuantityPoint AUTO operator-(const QuantityPoint AUTO& lhs, const Quantity AUTO& rhs) +constexpr QuantityPoint AUTO operator-(const QuantityPoint AUTO& lhs, const Quantity AUTO& rhs) requires requires { lhs.relative() - rhs; } { return quantity_point(lhs.relative() - rhs);