std::is_base_of template in C++ with Examples Last Updated : 12 Jun, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The std::is_base_of template of C++ STL is present in the <type_traits> header file. The std::is_base_of template of C++ STL is used to check whether class Base is the base class of Derived class or not. It return the boolean value true or false on the basis of above condition. Header File: #include<type_traits> Template Class: template <class Base, class Derived> struct is_base_of; Syntax: std::is_base_of<A, B>::value Parameters: It accepts the below two classes as a parameters: class A(as a Base class): It represents the base class. class B(as a Derived class): It represents the derived class. Return Value: This template returns a boolean variable as shown below: True: If the Base class(class A) is the parent of the Derived class(class B). False: If the Base class(class A) is not the parent of the Derived class(class B). Below is the program to illustrates the std::is_base_of template in C/C++: Program 1: CPP // C++ program to demonstrate the // std::is_base_of templates #include <bits/stdc++.h> #include <type_traits> using namespace std; // Base class A class A { }; // Derived Class B class B : A { }; // Class C class C { }; // Driver Code int main() { cout << boolalpha; // Check if class A is a base class // of class B cout << "A is base class of B: " << is_base_of<A, B>::value << endl; // Check if class B is a base class // of class A cout << "B is base class of A: " << is_base_of<B, A>::value << endl; // Check if class C is a base class // of class B cout << "C is base class of B: " << is_base_of<C, B>::value << endl; // Check if class C is a base class // of class C cout << "C is base class of C: " << is_base_of<C, C>::value << endl; return 0; } Output: A is base class of B: true B is base class of A: false C is base class of B: false C is base class of C: true Reference: http://www.cplusplus.com/reference/type_traits/is_base_of/ Comment More infoAdvertise with us Next Article std::is_function template in C++ with Examples B bansal_rtk_ Follow Improve Article Tags : Misc C++ CPP-Functions Practice Tags : CPPMisc Similar Reads std::is_assignable template in C++ with Examples The std::is_assignable template of C++ STL is present in the <type_traits> header file. The std::is_assignable template of C++ STL is used to check whether a value of B type can be assigned to a A. It returns the boolean value either true or false. Below is the syntax for the same: Header File 2 min read std::is_same template in C++ with Examples The std::is_same template of C++ STL is present in the <type_traits> header file. The std::is_same template of C++ STL is used to check whether the type A is same type as of B or not. It return the boolean value true if both are same, otherwise return false. Header File: #include<type_trait 3 min read std::is_convertible template in C++ with Examples The std::is_convertible template of C++ STL is present in the <type_traits> header file. The std::is_convertible template of C++ STL is used to check whether any data type A is implicitly convertible to any data type B. It returns the boolean value either true or false. Header File: #include 2 min read std::is_function template in C++ with Examples The std::is_function of C++ STL is used to check whether the given type T is function or not. It returns the boolean value either true or false. Below is the syntax for the same: Header File: #include<type_traits> Syntax: template <class T> struct is_function; Parameter: The template std 2 min read std::extent() template in C++ with Examples The std::is_const template of C++ STL is present in the <type_traits> header file. If A is an array that has a rank greater than B, the extent is the bound of the Ath dimension and if B is zero and A is the array of unknown bound, than the extent value is zero. Header File: #include<type_tr 2 min read std::is_constructible template in C++ with Examples The std::is_constructible template of C++ STL is present in the <type_traits> header file. The std::is_constructible template of C++ STL is used to check whether the given type T is constructible type with the set of arguments or not. It return the boolean value true if T is of constructible t 2 min read Like