is_class template in C++
The std::is_class template of C++ STL is used to check whether the given type is class or not. It returns a boolean value showing the same.
Syntax:
template <class T> struct is_class;
Parameter: This template accepts single parameter T (Trait class) to check whether T is a class or not.
Return Value: This template returns a boolean value as shown below:
- True: If a type is a class class.
- False: If a type is a class class.
Below programs illustrate the std::is_class template in C++:
Program 1::
// C++ program to illustrate // is_class template #include <iostream> #include <type_traits> using namespace std; class GFG1 { }; union GFG2 { int var1; float var2; }; int main() { cout << boolalpha; cout << "is_class:" << endl; cout << "GFG1: " << is_class<GFG1>::value << endl; cout << "GFG2: " << is_class<GFG2>::value << endl; return 0; } |
is_class: GFG1: true GFG2: false
Program 2:
// C++ program to illustrate // is_class template #include <iostream> #include <type_traits> using namespace std; class GFG1 { int var1; float var2; char var3; }; struct GFG2 { union { int var4; float var5; }; }; int main() { cout << boolalpha; cout << "is_class:" << endl; cout << "int: " << is_class<int>::value << endl; cout << "GFG1: " << is_class<GFG1>::value << endl; cout << "GFG2: " << is_class<GFG2>::value << endl; return 0; } |
is_class: int: false GFG1: true GFG2: true
Recommended Posts:
- is_final template in C++14
- is_volatile template in C++
- is_void template in C++
- std::is_integral template in C++
- std::is_enum Template in C++
- std is_union() template in C++
- is_abstract template in C++
- is_polymorphic template in C++
- is_fundamental Template in C++
- is_pod template in C++
- is_signed template in C++
- is_pointer Template in C++
- is_unsigned template in C++
- is_scalar template in C++
- std::is_compound Template in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : rajasethupathi



