make_signed.pass.cpp revision ef7a7b730c0dbfc3bf31d6246780e0cd7e07774f
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    bzero,
21    big = 0xFFFFFFFFFFFFFFFFULL
22};
23
24template <class T, class U>
25void test_make_signed()
26{
27    static_assert((std::is_same<typename std::make_signed<T>::type, U>::value), "");
28#if _LIBCPP_STD_VER > 11
29    static_assert((std::is_same<std::make_signed_t<T>, U>::value), "");
30#endif
31}
32
33int main()
34{
35    test_make_signed< signed char, signed char >();
36    test_make_signed< unsigned char, signed char >();
37    test_make_signed< char, signed char >();
38    test_make_signed< short, signed short >();
39    test_make_signed< unsigned short, signed short >();
40    test_make_signed< int, signed int >();
41    test_make_signed< unsigned int, signed int >();
42    test_make_signed< long, signed long >();
43    test_make_signed< unsigned long, long >();
44    test_make_signed< long long, signed long long >();
45    test_make_signed< unsigned long long, signed long long >();
46    test_make_signed< wchar_t, std::conditional<sizeof(wchar_t) == 4, int, short>::type >();
47    test_make_signed< const wchar_t, std::conditional<sizeof(wchar_t) == 4, const int, const short>::type >();
48    test_make_signed< const Enum, const int >();
49    test_make_signed< BigEnum, std::conditional<sizeof(long) == 4, long long, long>::type >();
50}
51