blob: 479c2529f02a51caf724d025b3cfdf6559f2ae64 [file] [log] [blame]
Howard Hinnantc52f43e2010-08-22 00:59:46 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantc52f43e2010-08-22 00:59:46 +00007//
8//===----------------------------------------------------------------------===//
9
10// type_traits
11
12// is_signed
13
14#include <type_traits>
15
16template <class T>
17void test_is_signed()
18{
19 static_assert( std::is_signed<T>::value, "");
20 static_assert( std::is_signed<const T>::value, "");
21 static_assert( std::is_signed<volatile T>::value, "");
22 static_assert( std::is_signed<const volatile T>::value, "");
23}
24
25template <class T>
26void test_is_not_signed()
27{
28 static_assert(!std::is_signed<T>::value, "");
29 static_assert(!std::is_signed<const T>::value, "");
30 static_assert(!std::is_signed<volatile T>::value, "");
31 static_assert(!std::is_signed<const volatile T>::value, "");
32}
33
34class Class
35{
36public:
37 ~Class();
38};
39
40int main()
41{
42 test_is_not_signed<void>();
43 test_is_not_signed<int&>();
44 test_is_not_signed<Class>();
45 test_is_not_signed<int*>();
46 test_is_not_signed<const int*>();
47 test_is_not_signed<char[3]>();
Marshall Clowe33e03e2014-09-02 16:19:38 +000048 test_is_not_signed<char[]>();
Howard Hinnantc52f43e2010-08-22 00:59:46 +000049 test_is_not_signed<bool>();
50 test_is_not_signed<unsigned>();
51
52 test_is_signed<int>();
53 test_is_signed<double>();
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +000054
55#ifndef _LIBCPP_HAS_NO_INT128
56 test_is_signed<__int128_t>();
57 test_is_not_signed<__uint128_t>();
58#endif
Howard Hinnantc52f43e2010-08-22 00:59:46 +000059}