mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-06 16:09:30 +00:00
AK: Add decrement operator to Checked
This commit is contained in:
parent
8688259ed9
commit
8a8bdb2cd7
13
AK/Checked.h
13
AK/Checked.h
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue