enumのbase typeを取得する

C++11で、enum/enum classに元となる整数型を指定できるようになりました。
これにともない、にstd::underlying_typeというenumのbase typeを取得するメタ関数が入りました。

#include <type_traits>

enum class e1 : int {};
enum class e2 : char {};
enum e3 : std::size_t { e };

using e1_type = std::underlying_type<e1>::type;
using e2_type = std::underlying_type<e2>::type;
using e3_type = std::underlying_type<e3>::type;

static_assert(std::is_same<e1_type, int>::value, "");
static_assert(std::is_same<e2_type, char>::value, "");
static_assert(std::is_same<e3_type, std::size_t>::value, "");

int main() {}

std::underlying_typeは、元はN2947 Additional Type Traits for C++0xで提案されたenum_baseの名前が変わったものですね。