std::is_class
From cppreference.com
Defined in header
<type_traits>
|
||
template< class T >
struct is_class; |
(since C++11) | |
If T
is a class or struct (but not a union), provides the member constant value
equal true. For any other type, value
is false.
Contents |
Inherited from std::integral_constant
Member constants
value
[static]
|
true if T is a class or struct , false otherwise (public static member constant) |
Member functions
operator bool |
converts the object to bool, returns value (public member function) |
Member types
Type | Definition |
value_type
|
bool
|
type
|
std::integral_constant<bool, value> |
[edit] Example
#include <iostream> #include <type_traits> struct A {}; class B {}; enum class C {}; int main() { std::cout << std::boolalpha; std::cout << std::is_class<A>::value << '\n'; std::cout << std::is_class<B>::value << '\n'; std::cout << std::is_class<C>::value << '\n'; std::cout << std::is_class<int>::value << '\n'; }
Output:
true true false false
[edit] See also
(C++11)
|
checks if a type is an union type (class template) |