std::underlying_type

From Cppreference

Jump to: navigation, search
Defined in header <type_traits>

template< class T >
struct underlying_type;
(C++11 feature)

Defines a member typedef type of type that is the underlying type for the enumeration T.

[edit] Member types

Name Definition
type the underlying type for T

[edit] Notes

Each enumeration type has an underlying type, which can be

1. Specified explicitly (both scoped and unscoped enumerations)

2. Omitted, in which case it is int for scoped enumerations or an implementation-defined integral type capable of representing all values of the enum (for unscoped enumerations)

[edit] Example