From 9321d9d83d366ad4cf686c856063ff9ac97c18a4 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sun, 4 Jul 2021 20:03:09 +0300 Subject: [PATCH] AK: Explicitly require Checked types to be Integral These were already implicitly required to be integral via the usage of the is_within_range templated function, but making them explicit should produce nicer error messages when building, and make the IDE highlight the incorrect usage. --- AK/Checked.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/AK/Checked.h b/AK/Checked.h index 2dccd71fb44da5..fcdb50cec6c5ee 100644 --- a/AK/Checked.h +++ b/AK/Checked.h @@ -28,6 +28,7 @@ #pragma once #include +#include #include #include @@ -109,17 +110,17 @@ template return TypeBoundsChecker::is_within_range(value); } -template +template class Checked { public: constexpr Checked() = default; - constexpr Checked(T value) + explicit constexpr Checked(T value) : m_value(value) { } - template + template constexpr Checked(U value) { m_overflow = !is_within_range(value);