is_enum Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at is_enum Class.

Tests if type is an enumeration.

template <class Ty>  
struct is_enum;  

Parameters

Ty
The type to query.

An instance of the type predicate holds true if the type Ty is an enumeration type or a cv-qualified form of an enumeration type, otherwise it holds false.

// std_tr1__type_traits__is_enum.cpp   
// compile with: /EHsc   
#include <type_traits>   
#include <iostream>   
  
struct trivial   
    {   
    int val;   
    };   
  
enum color {   
    red, greed, blue};   
  
int main()   
    {   
    std::cout << "is_enum<trivial> == " << std::boolalpha   
        << std::is_enum<trivial>::value << std::endl;   
    std::cout << "is_enum<color> == " << std::boolalpha   
        << std::is_enum<color>::value << std::endl;   
    std::cout << "is_enum<int> == " << std::boolalpha   
        << std::is_enum<int>::value << std::endl;   
  
    return (0);   
    }  
  

is_enum<trivial> == false  
is_enum<color> == true  
is_enum<int> == false  

Header: <type_traits>

Namespace: std

<type_traits>
is_integral Class

Show: