AK: Add decrement operator to Checked

This commit is contained in:
Tom 2021-03-08 13:07:58 -07:00 committed by Andreas Kling
parent 8688259ed9
commit 8a8bdb2cd7

View file

@ -251,6 +251,19 @@ public:
return old; return old;
} }
constexpr Checked& operator--()
{
sub(1);
return *this;
}
constexpr Checked operator--(int)
{
Checked old { *this };
sub(1);
return old;
}
template<typename U, typename V> template<typename U, typename V>
static constexpr bool addition_would_overflow(U u, V v) static constexpr bool addition_would_overflow(U u, V v)
{ {