From 82a63e350cb9a67cbd3aa659d909ae9e6599e93f Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Thu, 8 Aug 2024 14:21:13 +0100 Subject: [PATCH] AK: Assert that `is()` input and output types are not the same This makes it a compile error to use is() where the input and output types are known to be the same at compile time. --- AK/TypeCasts.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AK/TypeCasts.h b/AK/TypeCasts.h index eafb23f6668..9857d0bd41d 100644 --- a/AK/TypeCasts.h +++ b/AK/TypeCasts.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include @@ -15,6 +16,7 @@ namespace AK { template ALWAYS_INLINE bool is(InputType& input) { + static_assert(!SameAs); if constexpr (requires { input.template fast_is(); }) { return input.template fast_is(); }