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// UNSUPPORTED: c++98, c++03, c++11
11// <experimental/type_traits>
12
13#include <experimental/type_traits>
14
15namespace ex = std::experimental;
16
17struct class_type {};
18enum enum_type {};
19union union_type {};
20
21int main()
22{
23    {
24        typedef void T;
25        static_assert(ex::is_void_v<T>, "");
26        static_assert(std::is_same<decltype(ex::is_void_v<T>), const bool>::value, "");
27        static_assert(ex::is_void_v<T> == std::is_void<T>::value, "");
28    }
29    {
30        typedef int T;
31        static_assert(!ex::is_void_v<T>, "");
32        static_assert(ex::is_void_v<T> == std::is_void<T>::value, "");
33    }
34    {
35        typedef decltype(nullptr) T;
36        static_assert(ex::is_null_pointer_v<T>, "");
37        static_assert(std::is_same<decltype(ex::is_null_pointer_v<T>), const bool>::value, "");
38        static_assert(ex::is_null_pointer_v<T> == std::is_null_pointer<T>::value, "");
39    }
40    {
41        typedef int T;
42        static_assert(!ex::is_null_pointer_v<T>, "");
43        static_assert(ex::is_null_pointer_v<T> == std::is_null_pointer<T>::value, "");
44    }
45    {
46        typedef int T;
47        static_assert(ex::is_integral_v<T>, "");
48        static_assert(std::is_same<decltype(ex::is_integral_v<T>), const bool>::value, "");
49        static_assert(ex::is_integral_v<T> == std::is_integral<T>::value, "");
50    }
51    {
52        typedef void T;
53        static_assert(!ex::is_integral_v<T>, "");
54        static_assert(ex::is_integral_v<T> == std::is_integral<T>::value, "");
55    }
56    {
57        typedef float T;
58        static_assert(ex::is_floating_point_v<T>, "");
59        static_assert(std::is_same<decltype(ex::is_floating_point_v<T>), const bool>::value, "");
60        static_assert(ex::is_floating_point_v<T> == std::is_floating_point<T>::value, "");
61    }
62    {
63        typedef int T;
64        static_assert(!ex::is_floating_point_v<T>, "");
65        static_assert(ex::is_floating_point_v<T> == std::is_floating_point<T>::value, "");
66    }
67    {
68        typedef int(T)[42];
69        static_assert(ex::is_array_v<T>, "");
70        static_assert(std::is_same<decltype(ex::is_array_v<T>), const bool>::value, "");
71        static_assert(ex::is_array_v<T> == std::is_array<T>::value, "");
72    }
73    {
74        typedef int T;
75        static_assert(!ex::is_array_v<T>, "");
76        static_assert(ex::is_array_v<T> == std::is_array<T>::value, "");
77    }
78    {
79        typedef void* T;
80        static_assert(ex::is_pointer_v<T>, "");
81        static_assert(std::is_same<decltype(ex::is_pointer_v<T>), const bool>::value, "");
82        static_assert(ex::is_pointer_v<T> == std::is_pointer<T>::value, "");
83    }
84    {
85        typedef int T;
86        static_assert(!ex::is_pointer_v<T>, "");
87        static_assert(ex::is_pointer_v<T> == std::is_pointer<T>::value, "");
88    }
89    {
90        typedef int & T;
91        static_assert(ex::is_lvalue_reference_v<T>, "");
92        static_assert(std::is_same<decltype(ex::is_lvalue_reference_v<T>), const bool>::value, "");
93        static_assert(ex::is_lvalue_reference_v<T> == std::is_lvalue_reference<T>::value, "");
94    }
95    {
96        typedef int T;
97        static_assert(!ex::is_lvalue_reference_v<T>, "");
98        static_assert(ex::is_lvalue_reference_v<T> == std::is_lvalue_reference<T>::value, "");
99    }
100    {
101        typedef int && T;
102        static_assert(ex::is_rvalue_reference_v<T>, "");
103        static_assert(std::is_same<decltype(ex::is_rvalue_reference_v<T>), const bool>::value, "");
104        static_assert(ex::is_rvalue_reference_v<T> == std::is_rvalue_reference<T>::value, "");
105    }
106    {
107        typedef int T;
108        static_assert(!ex::is_rvalue_reference_v<T>, "");
109        static_assert(ex::is_rvalue_reference_v<T> == std::is_rvalue_reference<T>::value, "");
110    }
111    {
112        typedef int class_type::*T;
113        static_assert(ex::is_member_object_pointer_v<T>, "");
114        static_assert(std::is_same<decltype(ex::is_member_object_pointer_v<T>), const bool>::value, "");
115        static_assert(ex::is_member_object_pointer_v<T> == std::is_member_object_pointer<T>::value, "");
116    }
117    {
118        typedef int T;
119        static_assert(!ex::is_member_object_pointer_v<T>, "");
120        static_assert(ex::is_member_object_pointer_v<T> == std::is_member_object_pointer<T>::value, "");
121    }
122    {
123        typedef void(class_type::*T)();
124        static_assert(ex::is_member_function_pointer_v<T>, "");
125        static_assert(std::is_same<decltype(ex::is_member_function_pointer_v<T>), const bool>::value, "");
126        static_assert(ex::is_member_function_pointer_v<T> == std::is_member_function_pointer<T>::value, "");
127    }
128    {
129        typedef int T;
130        static_assert(!ex::is_member_function_pointer_v<T>, "");
131        static_assert(ex::is_member_function_pointer_v<T> == std::is_member_function_pointer<T>::value, "");
132    }
133    {
134        typedef enum_type T;
135        static_assert(ex::is_enum_v<T>, "");
136        static_assert(std::is_same<decltype(ex::is_enum_v<T>), const bool>::value, "");
137        static_assert(ex::is_enum_v<T> == std::is_enum<T>::value, "");
138    }
139    {
140        typedef int T;
141        static_assert(!ex::is_enum_v<T>, "");
142        static_assert(ex::is_enum_v<T> == std::is_enum<T>::value, "");
143    }
144    {
145        typedef union_type T;
146        static_assert(ex::is_union_v<T>, "");
147        static_assert(std::is_same<decltype(ex::is_union_v<T>), const bool>::value, "");
148        static_assert(ex::is_union_v<T> == std::is_union<T>::value, "");
149    }
150    {
151        typedef int T;
152        static_assert(!ex::is_union_v<T>, "");
153        static_assert(ex::is_union_v<T> == std::is_union<T>::value, "");
154    }
155    {
156        typedef class_type T;
157        static_assert(ex::is_class_v<T>, "");
158        static_assert(std::is_same<decltype(ex::is_class_v<T>), const bool>::value, "");
159        static_assert(ex::is_class_v<T> == std::is_class<T>::value, "");
160    }
161    {
162        typedef int T;
163        static_assert(!ex::is_class_v<T>, "");
164        static_assert(ex::is_class_v<T> == std::is_class<T>::value, "");
165    }
166    {
167        typedef void(T)();
168        static_assert(ex::is_function_v<T>, "");
169        static_assert(std::is_same<decltype(ex::is_function_v<T>), const bool>::value, "");
170        static_assert(ex::is_function_v<T> == std::is_function<T>::value, "");
171    }
172    {
173        typedef int T;
174        static_assert(!ex::is_function_v<T>, "");
175        static_assert(ex::is_function_v<T> == std::is_function<T>::value, "");
176    }
177}
178
179