From 8a8bdb2cd777a8fbefcc711132ee2ba4041578ac Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 8 Mar 2021 13:07:58 -0700 Subject: [PATCH] AK: Add decrement operator to Checked --- AK/Checked.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/AK/Checked.h b/AK/Checked.h index 3ed63f0132..eaeb1bc3f2 100644 --- a/AK/Checked.h +++ b/AK/Checked.h @@ -251,6 +251,19 @@ public: return old; } + constexpr Checked& operator--() + { + sub(1); + return *this; + } + + constexpr Checked operator--(int) + { + Checked old { *this }; + sub(1); + return old; + } + template static constexpr bool addition_would_overflow(U u, V v) {