diff options
author | Tom <tomut@yahoo.com> | 2021-03-08 13:07:58 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-13 10:17:28 +0100 |
commit | 8a8bdb2cd777a8fbefcc711132ee2ba4041578ac (patch) | |
tree | efdae1290bf16e371a60bcba46af88383e3235a0 | |
parent | 8688259ed95c87ebcb36ce08fab9cb6088688db0 (diff) | |
download | serenity-8a8bdb2cd777a8fbefcc711132ee2ba4041578ac.zip |
AK: Add decrement operator to Checked
-rw-r--r-- | AK/Checked.h | 13 |
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) { |