util/OptionalCounter: add operator+= and operator-=
This commit is contained in:
parent
5670d98c54
commit
78d8b5f73c
@ -44,6 +44,8 @@ public:
|
|||||||
constexpr void reset() noexcept {}
|
constexpr void reset() noexcept {}
|
||||||
constexpr auto &operator++() noexcept { return *this; }
|
constexpr auto &operator++() noexcept { return *this; }
|
||||||
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<>
|
template<>
|
||||||
@ -71,4 +73,16 @@ public:
|
|||||||
--value;
|
--value;
|
||||||
return *this;
|
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;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user