1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // type_traits 11 12 // underlying_type 13 14 #include <type_traits> 15 #include <climits> 16 17 enum E { V = INT_MIN }; 18 enum F { W = UINT_MAX }; 19 20 int main() 21 { 22 static_assert((std::is_same<std::underlying_type<E>::type, int>::value), 23 "E has the wrong underlying type"); 24 static_assert((std::is_same<std::underlying_type<F>::type, unsigned>::value), 25 "F has the wrong underlying type"); 26 27 #if _LIBCPP_STD_VER > 11 28 static_assert((std::is_same<std::underlying_type_t<E>, int>::value), ""); 29 static_assert((std::is_same<std::underlying_type_t<F>, unsigned>::value), ""); 30 #endif 31 32 #if __has_feature(cxx_strong_enums) 33 enum G : char { }; 34 35 static_assert((std::is_same<std::underlying_type<G>::type, char>::value), 36 "G has the wrong underlying type"); 37 #if _LIBCPP_STD_VER > 11 38 static_assert((std::is_same<std::underlying_type_t<G>, char>::value), ""); 39 #endif 40 #endif // __has_feature(cxx_strong_enums) 41 } 42