diff options
author | Linus Groh <mail@linusgroh.de> | 2021-07-22 18:48:48 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-07-22 21:19:40 +0100 |
commit | 42b6bffbf2b6aa34f4f82cd4c3c34ed5528790ad (patch) | |
tree | 87fc2746bd510f0dbf8bfa1a52aae0e6f458a38a /AK/Checked.h | |
parent | 8f26f5158080911d5cc54e26b34227a8d8123a8b (diff) | |
download | serenity-42b6bffbf2b6aa34f4f82cd4c3c34ed5528790ad.zip |
AK: Make TypeBoundsChecker<UnsignedIntegralT, FloatingPointT> work
By replacing MakeUnsigned<Source> in this specific specialization with a
simple negativity check this now works for floating point source types.
Previously it would attempt a comparison of the destination type and
void.
Diffstat (limited to 'AK/Checked.h')
-rw-r--r-- | AK/Checked.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/AK/Checked.h b/AK/Checked.h index fcdb50cec6..bac072dfbe 100644 --- a/AK/Checked.h +++ b/AK/Checked.h @@ -58,7 +58,7 @@ template<typename Destination, typename Source> struct TypeBoundsChecker<Destination, Source, false, false, true> { static constexpr bool is_within_range(Source value) { - return static_cast<MakeUnsigned<Source>>(value) <= NumericLimits<Destination>::max(); + return value >= 0 && value <= NumericLimits<Destination>::max(); } }; |