From 04cbeb841ed32f65c0f6a6948d63917487f6bc47 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 9 Nov 2019 14:09:30 +0000 Subject: [PATCH] Disabled prefix/postfix increment/decrement operators (resolves #18) --- src/include/units/quantity.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/include/units/quantity.h b/src/include/units/quantity.h index 010a3cf7..14a69603 100644 --- a/src/include/units/quantity.h +++ b/src/include/units/quantity.h @@ -236,22 +236,28 @@ namespace units { [[nodiscard]] static constexpr quantity min() noexcept { return quantity(quantity_values::min()); } [[nodiscard]] static constexpr quantity max() noexcept { return quantity(quantity_values::max()); } - [[nodiscard]] constexpr quantity operator+() const { return quantity(*this); } + [[nodiscard]] constexpr quantity operator+() const { return *this; } [[nodiscard]] constexpr quantity operator-() const { return quantity(-count()); } constexpr quantity& operator++() + // requires requires(rep v) { { ++v } -> std::same_as; } // TODO gated by gcc-9 (fixed in gcc-10) { ++value_; return *this; } - constexpr quantity operator++(int) { return quantity(value_++); } + constexpr quantity operator++(int) + // requires requires(rep v) { { v++ } -> std::same_as; } // TODO gated by gcc-9 (fixed in gcc-10) + { return quantity(value_++); } constexpr quantity& operator--() + // requires requires(rep v) { { --v } -> std::same_as; } // TODO gated by gcc-9 (fixed in gcc-10) { --value_; return *this; } - constexpr quantity operator--(int) { return quantity(value_--); } + constexpr quantity operator--(int) + // requires requires(rep v) { { v-- } -> std::same_as; } // TODO gated by gcc-9 (fixed in gcc-10) + { return quantity(value_--); } constexpr quantity& operator+=(const quantity& q) {