| 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 |
__underlying_type(E1) i1 = __INT_MAX__ * 2U + 1; |
| 19 |
__underlying_type(E2) i2 = (char(-1) < 0 |
| 20 |
? __SCHAR_MAX__ |
| 21 |
: __SCHAR_MAX__ * 2U + 1); |
| 22 |
__underlying_type(E3) i3 = __INT_MAX__; |
| 23 |
__underlying_type(E4) i4 = __SCHAR_MAX__ * 2U + 1; |
| 24 |
__underlying_type(E5) i5 = int(E5::b); |
| 25 |
__underlying_type(E6) i6 = __LONG_MAX__; |
| 26 |
|
| 27 |
static_assert(is_same<__underlying_type(E1), unsigned>::value, "Error"); |
| 28 |
static_assert(is_same<__underlying_type(E2), char>::value, "Error"); |
| 29 |
static_assert(is_same<__underlying_type(E3), int>::value, "Error"); |
| 30 |
static_assert(is_same<__underlying_type(E4), unsigned char>::value, "Error"); |
| 31 |
static_assert(is_same<__underlying_type(E5), int>::value, "Error"); |
| 32 |
static_assert(is_same<__underlying_type(E6), long>::value, "Error"); |