Namespaces
Variants

std:: is_enum

From cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
(C++11)
(C++11)
is_enum
(C++11)
(C++11)
(C++11)
Type properties
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
Definiert im Header <type_traits>
template < class T >
struct is_enum ;
(seit C++11)

std::is_enum ist ein UnaryTypeTrait .

Prüft, ob T ein Aufzählungstyp ist. Stellt die Memberkonstante value bereit, die gleich true ist, falls T ein Aufzählungstyp ist. Andernfalls ist value gleich false .

Wenn das Programm Spezialisierungen für std::is_enum oder std::is_enum_v hinzufügt, ist das Verhalten undefiniert.

Inhaltsverzeichnis

Template-Parameter

T - ein zu prüfender Typ

Hilfsvariablen-Template

template < class T >
constexpr bool is_enum_v = is_enum < T > :: value ;
(seit C++17)

Geerbt von std:: integral_constant

Member-Konstanten

value
[static]
true wenn T ein Aufzählungstyp ist, false andernfalls
(öffentliche statische Member-Konstante)

Member-Funktionen

operator bool
konvertiert das Objekt zu bool , gibt value zurück
(öffentliche Member-Funktion)
operator()
(C++14)
gibt value zurück
(öffentliche Member-Funktion)

Member-Typen

Typ Definition
value_type bool
type std:: integral_constant < bool , value >

Beispiel

#include <type_traits>
struct A { enum E {}; };
static_assert(std::is_enum_v<A> == false);
static_assert(std::is_enum_v<A::E> == true);
enum E {};
static_assert(std::is_enum_v<E> == true);
enum class Ec : int {};
static_assert(std::is_enum_v<Ec> == true);
static_assert(std::is_enum_v<int> == false);
int main() {}

Siehe auch

prüft, ob ein Typ ein integraler Typ ist
(Klassen-Template)
prüft, ob ein Typ ein arithmetischer Typ ist
(Klassen-Template)
(C++11)
prüft, ob ein Typ ein Skalartyp ist
(Klassen-Template)
prüft, ob ein Typ ein Scoped-Enumeration-Typ ist
(Klassen-Template)