std::underlying_type
Aus cppreference.com
[] |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| definiert in Header <type_traits>
|
||
template< class T > struct underlying_type; |
(seit C++11) | |
Legt ein Mitglied typedef
type der Typ, der zugrunde liegende Typ fr die Zhlung T ist . Original:
Defines a member typedef
type of type that is the underlying type for the enumeration T. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Mitglied Typen
Name
Original: Name The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
type
|
der zugrunde liegende Typ fr
T Original: the underlying type for T The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Notes
Jeder Aufzhlungstyp hat einen zugrunde liegenden Typ, der sein kann
Original:
Each enumeration type has an underlying type, which can be
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Ein. Explizit (beide scoped und ohne Bereichseinschrnkung Aufzhlungen) angegeben
Original:
1. Specified explicitly (both scoped and unscoped enumerations)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2. Weggelassen wird, in welchem Fall es
int ist fr scoped Aufzhlungen oder eine Implementierung definiert integraler Typ, der stellvertretend fr alle Werte der Enum (fr ohne Bereichseinschrnkung Aufzhlungen)Original:
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)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Beispiel
#include <iostream>
#include <type_traits>
enum e1 {};
enum class e2: int {};
int main() {
bool e1_type = std::is_same<
unsigned
,typename std::underlying_type<e1>::type
>::value;
bool e2_type = std::is_same<
int
,typename std::underlying_type<e2>::type
>::value;
std::cout
<< "underlying type for 'e1' is " << (e1_type?"unsigned":"non-unsigned") << '\n'
<< "underlying type for 'e2' is " << (e2_type?"int":"non-int") << '\n';
}
Output:
underlying type for 'e1' is unsigned
underlying type for 'e2' is int