mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
AK: Add decrement operator to Checked
This commit is contained in:
Notes:
sideshowbarker
2024-07-18 21:25:26 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/8a8bdb2cd77 Pull-request: https://github.com/SerenityOS/serenity/pull/5740
13
AK/Checked.h
13
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user