Simplified definition of is_base_of

This commit is contained in:
John Wellbelove 2024-11-10 10:33:19 +00:00
parent fd82a9c113
commit d0a9d696fe
2 changed files with 4 additions and 14 deletions

View File

@ -639,18 +639,13 @@ namespace etl
struct is_base_of
{
private:
template<typename T> struct dummy {};
struct internal: TDerived, dummy<int>{};
static TBase* check(TBase*) { return (TBase*)0; }
template<typename T>
static char check(dummy<T>*) { 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.

View File

@ -627,18 +627,13 @@ namespace etl
struct is_base_of
{
private:
template<typename T> struct dummy {};
struct internal: TDerived, dummy<int>{};
static TBase* check(TBase*) { return (TBase*)0; }
template<typename T>
static char check(dummy<T>*) { 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.