std::is_base_of (3) - Linux Man Pages
Defined in header <type_traits>
template< class Base, class Derived > (since C++11)
If Derived is derived from Base or if both are the same non-union class (in both cases ignoring cv-qualification), provides the member constant value equal to true. Otherwise value is false.
If both Base and Derived are non-union class types, and they are not the same type (ignoring cv-qualification), Derived shall be a complete_type; otherwise the behavior is undefined.
Helper variable template
template< class Base, class Derived > (since C++17)
inline constexpr bool is_base_of_v = is_base_of<Base, Derived>::value;
Inherited from std::integral_constant
value true if Derived is derived from Base or if both are the same non-union class (in both cases ignoring cv-qualification), false otherwise
operator bool (public member function)
operator() returns value
type std::integral_constant<bool, value>
std::is_base_of<A, B>::value is true even if A is a private, protected, or ambiguous base class of B. In many situations, std::is_convertible<B*, A*> is the more appropriate test.
Although no class is its own base, std::is_base_of<T, T>::value is true because the intent of the trait is to model the "is-a" relationship, and T is a T. Despite that, std::is_base_of<int, int>::value is false because only classes participate in the relationship that this trait models.
// Run this code