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// make_signed 13 14#include <type_traits> 15 16#include "test_macros.h" 17 18enum Enum {zero, one_}; 19 20#if TEST_STD_VER >= 11 21enum BigEnum : unsigned long long // MSVC's ABI doesn't follow the Standard 22#else 23enum BigEnum 24#endif 25{ 26 bigzero, 27 big = 0xFFFFFFFFFFFFFFFFULL 28}; 29 30#if !defined(_LIBCPP_HAS_NO_INT128) && !defined(_LIBCPP_HAS_NO_STRONG_ENUMS) 31enum HugeEnum : __uint128_t 32{ 33 hugezero 34}; 35#endif 36 37template <class T, class U> 38void test_make_signed() 39{ 40 static_assert((std::is_same<typename std::make_signed<T>::type, U>::value), ""); 41#if TEST_STD_VER > 11 42 static_assert((std::is_same<std::make_signed_t<T>, U>::value), ""); 43#endif 44} 45 46int main() 47{ 48 test_make_signed< signed char, signed char >(); 49 test_make_signed< unsigned char, signed char >(); 50 test_make_signed< char, signed char >(); 51 test_make_signed< short, signed short >(); 52 test_make_signed< unsigned short, signed short >(); 53 test_make_signed< int, signed int >(); 54 test_make_signed< unsigned int, signed int >(); 55 test_make_signed< long, signed long >(); 56 test_make_signed< unsigned long, long >(); 57 test_make_signed< long long, signed long long >(); 58 test_make_signed< unsigned long long, signed long long >(); 59 test_make_signed< wchar_t, std::conditional<sizeof(wchar_t) == 4, int, short>::type >(); 60 test_make_signed< const wchar_t, std::conditional<sizeof(wchar_t) == 4, const int, const short>::type >(); 61 test_make_signed< const Enum, std::conditional<sizeof(Enum) == sizeof(int), const int, const signed char>::type >(); 62 test_make_signed< BigEnum, std::conditional<sizeof(long) == 4, long long, long>::type >(); 63#ifndef _LIBCPP_HAS_NO_INT128 64 test_make_signed< __int128_t, __int128_t >(); 65 test_make_signed< __uint128_t, __int128_t >(); 66# ifndef _LIBCPP_HAS_NO_STRONG_ENUMS 67 test_make_signed< HugeEnum, __int128_t >(); 68# endif 69#endif 70} 71