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
ヘッダーで定義 <type_traits>
template < class T >
struct is_enum ;
(C++11以降)

std::is_enum UnaryTypeTrait です。

T 列挙型 かどうかをチェックします。 T が列挙型の場合、メンバ定数 value true に等しくなります。それ以外の場合、 value false に等しくなります。

プログラムが std::is_enum または std::is_enum_v に対する特殊化を追加する場合、動作は未定義です。

目次

テンプレートパラメータ

T - チェックする型

ヘルパー変数テンプレート

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

std:: integral_constant から継承

メンバ定数

value
[static]
true T が列挙型の場合)、 false (それ以外の場合)
(public static member constant)

メンバ関数

operator bool
オブジェクトを bool に変換し、 value を返す
(public member function)
operator()
(C++14)
value を返す
(public member function)

メンバ型

定義
value_type bool
type std:: integral_constant < bool , value >

#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() {}

関連項目

型が整数型かどうかをチェックする
(クラステンプレート)
型が算術型かどうかをチェックする
(クラステンプレート)
(C++11)
型がスカラ型かどうかをチェックする
(クラステンプレート)
型がスコープ付き列挙型かどうかをチェックする
(クラステンプレート)