summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AK/Checked.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/AK/Checked.h b/AK/Checked.h
index 062fb962f4..9514a8fb9d 100644
--- a/AK/Checked.h
+++ b/AK/Checked.h
@@ -234,6 +234,25 @@ public:
return *this;
}
+ template<typename U, typename V, typename X>
+ static bool multiplication_would_overflow(U u, V v)
+ {
+ Checked checked;
+ checked = u;
+ checked *= v;
+ return checked.has_overflow();
+ }
+
+ template<typename U, typename V, typename X>
+ static bool multiplication_would_overflow(U u, V v, X x)
+ {
+ Checked checked;
+ checked = u;
+ checked *= v;
+ checked *= x;
+ return checked.has_overflow();
+ }
+
private:
T m_value;
bool m_overflow { false };