summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2021-03-08 13:07:58 -0700
committerAndreas Kling <kling@serenityos.org>2021-03-13 10:17:28 +0100
commit8a8bdb2cd777a8fbefcc711132ee2ba4041578ac (patch)
treeefdae1290bf16e371a60bcba46af88383e3235a0 /AK
parent8688259ed95c87ebcb36ce08fab9cb6088688db0 (diff)
downloadserenity-8a8bdb2cd777a8fbefcc711132ee2ba4041578ac.zip
AK: Add decrement operator to Checked
Diffstat (limited to 'AK')
-rw-r--r--AK/Checked.h13
1 files changed, 13 insertions, 0 deletions
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<typename U, typename V>
static constexpr bool addition_would_overflow(U u, V v)
{