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