| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
|
| 3 |
template<typename T1, typename T2> |
| 4 |
struct is_same |
| 5 |
{ static const bool value = false; }; |
| 6 |
|
| 7 |
template<typename T> |
| 8 |
struct is_same<T, T> |
| 9 |
{ static const bool value = true; }; |
| 10 |
|
| 11 |
enum E1 : unsigned { }; |
| 12 |
enum E2 : char { }; |
| 13 |
enum class E3 { }; |
| 14 |
enum class E4 : unsigned char { c = 1 }; |
| 15 |
enum class E5 : int { a = -1, b = 1 }; |
| 16 |
enum class E6 : long { c = __LONG_MAX__ }; |
| 17 |
|
| 18 |
typedef __underlying_type(E1) UTE1; |
| 19 |
typedef __underlying_type(E2) UTE2; |
| 20 |
typedef __underlying_type(E3) UTE3; |
| 21 |
typedef __underlying_type(E4) UTE4; |
| 22 |
typedef __underlying_type(E5) UTE5; |
| 23 |
typedef __underlying_type(E6) UTE6; |
| 24 |
|
| 25 |
template<typename T> |
| 26 |
struct underlying_type |
| 27 |
{ typedef __underlying_type(T) type; }; |
| 28 |
|
| 29 |
static_assert(is_same<underlying_type<E1>::type, UTE1>::value, "Error"); |
| 30 |
static_assert(is_same<underlying_type<E2>::type, UTE2>::value, "Error"); |
| 31 |
static_assert(is_same<underlying_type<E3>::type, UTE3>::value, "Error"); |
| 32 |
static_assert(is_same<underlying_type<E4>::type, UTE4>::value, "Error"); |
| 33 |
static_assert(is_same<underlying_type<E5>::type, UTE5>::value, "Error"); |
| 34 |
static_assert(is_same<underlying_type<E6>::type, UTE6>::value, "Error"); |
| 35 |
|
| 36 |
static_assert(is_same<underlying_type<E1>::type, unsigned>::value, "Error"); |
| 37 |
static_assert(is_same<underlying_type<E2>::type, char>::value, "Error"); |
| 38 |
static_assert(is_same<underlying_type<E3>::type, int>::value, "Error"); |
| 39 |
static_assert(is_same<underlying_type<E4>::type, |
| 40 |
unsigned char>::value, "Error"); |
| 41 |
static_assert(is_same<underlying_type<E5>::type, int>::value, "Error"); |
| 42 |
static_assert(is_same<underlying_type<E6>::type, long>::value, "Error"); |