How to use a c++ concept to detect whether a class has a base or not?

190 Views Asked by At
template<typename T>
concept has_base = ???; // What code should be put here?

struct A
{};

struct B : A
{};

int main()
{
    static_assert(has_base<A> == false);    
    static_assert(has_base<B> == true);
}

Is there a way to detect whether a class has a base or not?

0

There are 0 best solutions below