Skip to content

Commit

Permalink
etl/type_traits: fix etl::is_base_of for the case when TDerived is final
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Pinchuk committed Oct 2, 2024
1 parent b066e2a commit e7cbb62
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions include/etl/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e7cbb62

Please sign in to comment.