underlying_type.pass.cpp revision 737a351850d18b63a8f89c195cb9ebfdfaa44f6d
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 17int main() 18{ 19 enum E { V = INT_MIN }; 20 enum F { W = UINT_MAX }; 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 __has_feature(cxx_strong_enums) 28 enum G : char { }; 29 30 static_assert((std::is_same<std::underlying_type<G>::type, char>::value), 31 "G has the wrong underlying type"); 32#endif // __has_feature(cxx_strong_enums) 33} 34