diff --git a/src/util/OptionalCounter.hxx b/src/util/OptionalCounter.hxx index ad4a43988..f00e846b3 100644 --- a/src/util/OptionalCounter.hxx +++ b/src/util/OptionalCounter.hxx @@ -44,6 +44,8 @@ public: constexpr void reset() noexcept {} constexpr auto &operator++() noexcept { return *this; } constexpr auto &operator--() noexcept { return *this; } + constexpr auto &operator+=(std::size_t) noexcept { return *this; } + constexpr auto &operator-=(std::size_t) noexcept { return *this; } }; template<> @@ -71,4 +73,16 @@ public: --value; return *this; } + + constexpr auto &operator+=(std::size_t n) noexcept { + value += n; + return *this; + } + + constexpr auto &operator-=(std::size_t n) noexcept { + assert(value >= n); + + value -= n; + return *this; + } };