Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / meta / meta.unary / meta.unary.prop / is_unsigned.pass.cpp
blobabf21e60b59270e0239b646a961201418da2402a
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // type_traits
11 // is_unsigned
13 #include <type_traits>
14 #include "test_macros.h"
16 template <class T>
17 void test_is_unsigned()
19 static_assert( std::is_unsigned<T>::value, "");
20 static_assert( std::is_unsigned<const T>::value, "");
21 static_assert( std::is_unsigned<volatile T>::value, "");
22 static_assert( std::is_unsigned<const volatile T>::value, "");
23 #if TEST_STD_VER > 14
24 static_assert( std::is_unsigned_v<T>, "");
25 static_assert( std::is_unsigned_v<const T>, "");
26 static_assert( std::is_unsigned_v<volatile T>, "");
27 static_assert( std::is_unsigned_v<const volatile T>, "");
28 #endif
31 template <class T>
32 void test_is_not_unsigned()
34 static_assert(!std::is_unsigned<T>::value, "");
35 static_assert(!std::is_unsigned<const T>::value, "");
36 static_assert(!std::is_unsigned<volatile T>::value, "");
37 static_assert(!std::is_unsigned<const volatile T>::value, "");
38 #if TEST_STD_VER > 14
39 static_assert(!std::is_unsigned_v<T>, "");
40 static_assert(!std::is_unsigned_v<const T>, "");
41 static_assert(!std::is_unsigned_v<volatile T>, "");
42 static_assert(!std::is_unsigned_v<const volatile T>, "");
43 #endif
46 class Class
48 public:
49 ~Class();
52 struct A; // incomplete
54 class incomplete_type;
56 class Empty {};
58 class NotEmpty {
59 virtual ~NotEmpty();
62 union Union {};
64 struct bit_zero {
65 int : 0;
68 class Abstract {
69 virtual ~Abstract() = 0;
72 enum Enum { zero, one };
74 enum EnumSigned : int { two };
76 enum EnumUnsigned : unsigned { three };
78 enum class EnumClass { zero, one };
80 typedef void (*FunctionPtr)();
82 int main(int, char**)
84 // Cases where !is_arithmetic implies !is_unsigned
85 test_is_not_unsigned<std::nullptr_t>();
86 test_is_not_unsigned<void>();
87 test_is_not_unsigned<int&>();
88 test_is_not_unsigned<int&&>();
89 test_is_not_unsigned<Class>();
90 test_is_not_unsigned<int*>();
91 test_is_not_unsigned<const int*>();
92 test_is_not_unsigned<char[3]>();
93 test_is_not_unsigned<char[]>();
94 test_is_not_unsigned<Union>();
95 test_is_not_unsigned<Enum>();
96 test_is_not_unsigned<EnumSigned>();
97 test_is_not_unsigned<EnumUnsigned>();
98 test_is_not_unsigned<EnumClass>();
99 test_is_not_unsigned<FunctionPtr>();
100 test_is_not_unsigned<Empty>();
101 test_is_not_unsigned<incomplete_type>();
102 test_is_not_unsigned<A>();
103 test_is_not_unsigned<bit_zero>();
104 test_is_not_unsigned<NotEmpty>();
105 test_is_not_unsigned<Abstract>();
107 test_is_not_unsigned<signed char>();
108 test_is_not_unsigned<short>();
109 test_is_not_unsigned<int>();
110 test_is_not_unsigned<long>();
111 test_is_not_unsigned<float>();
112 test_is_not_unsigned<double>();
114 test_is_unsigned<unsigned char>();
115 test_is_unsigned<unsigned short>();
116 test_is_unsigned<unsigned int>();
117 test_is_unsigned<unsigned long>();
119 test_is_unsigned<bool>();
120 test_is_unsigned<unsigned>();
122 #ifndef TEST_HAS_NO_INT128
123 test_is_unsigned<__uint128_t>();
124 test_is_not_unsigned<__int128_t>();
125 #endif
127 return 0;