From bce35c49276564bf371ececb4d0a9c54e8f13b20 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 10 Nov 2024 10:33:19 +0000 Subject: [PATCH] Simplified definition of is_base_of --- include/etl/generators/type_traits_generator.h | 9 ++------- include/etl/type_traits.h | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index f086b841..9e414080 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -639,18 +639,13 @@ namespace etl struct is_base_of { private: - - template struct dummy {}; - struct internal: TDerived, dummy{}; - static TBase* check(TBase*) { return (TBase*)0; } - template - static char check(dummy*) { return 0; } + static char check(...) { return 0; } public: - static const bool value = (sizeof(check((internal*)0)) == sizeof(TBase*)); + static const bool value = (sizeof(check((TDerived*)0)) == sizeof(TBase*)); }; // For when TBase or TDerived is a fundamental type. diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 47489c2c..327f164b 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -627,18 +627,13 @@ namespace etl struct is_base_of { private: - - template struct dummy {}; - struct internal: TDerived, dummy{}; - static TBase* check(TBase*) { return (TBase*)0; } - template - static char check(dummy*) { return 0; } + static char check(...) { return 0; } public: - static const bool value = (sizeof(check((internal*)0)) == sizeof(TBase*)); + static const bool value = (sizeof(check((TDerived*)0)) == sizeof(TBase*)); }; // For when TBase or TDerived is a fundamental type.