◐ Shell
clean mode source ↗

std::is_enum - cppreference.com

提供: cppreference.com

<tbody> </tbody>

template< class T > struct is_enum;

(C++11以上)

T列挙型かどうか調べます。 T が列挙型であれば、 true に等しいメンバ定数 value が提供されます。 そうでなければ、 valuefalse に等しくなります。

is_enum または is_enum_v (C++17以上) に対して特殊化を追加するプログラムは未定義です。

テンプレート引数

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

<tbody> </tbody>

template< class T > inline constexpr bool is_enum_v = is_enum<T>::value;

(C++17以上)

std::integral_constant から継承

メンバ定数

T が列挙型ならば true、そうでなければ false
(パブリック静的メンバ定数)

メンバ関数

オブジェクトを bool に変換します。 value を返します
(パブリックメンバ関数)
value を返します
(パブリックメンバ関数)

メンバ型

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

#include <iostream>
#include <type_traits>

class A {};

enum E {};

enum class Ec : int {};

int main() 
{
    std::cout << std::boolalpha;
    std::cout << std::is_enum<A>::value << '\n';
    std::cout << std::is_enum<E>::value << '\n';
    std::cout << std::is_enum<Ec>::value << '\n';
    std::cout << std::is_enum<int>::value << '\n';
}

出力:

関連項目