std::underlying_type
From cppreference.com
Defined in header <type_traits>
|
||
template< class T > struct underlying_type; |
(since C++11) | |
If T
is a complete enumeration type, provides a member typedef type
that names the underlying type of T
.
Otherwise, the behavior is undefined.
Member types
Name | Definition |
type
|
the underlying type of T
|
Helper types
template< class T > using underlying_type_t = typename underlying_type<T>::type; |
(since C++14) | |
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)
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 2396 | C++11 | incomplete enumeration types were allowed | complete enumeration type required |