2 //===-------------------------- type_traits -------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_EXPERIMENTAL_TYPE_TRAITS
12 #define _LIBCPP_EXPERIMENTAL_TYPE_TRAITS
15 experimental/type_traits synopsis
18 #include <type_traits>
21 namespace experimental {
22 inline namespace fundamentals_v1 {
24 // See C++14 20.10.4.1, primary type categories
25 template <class T> constexpr bool is_void_v
27 template <class T> constexpr bool is_null_pointer_v
28 = is_null_pointer<T>::value;
29 template <class T> constexpr bool is_integral_v
30 = is_integral<T>::value;
31 template <class T> constexpr bool is_floating_point_v
32 = is_floating_point<T>::value;
33 template <class T> constexpr bool is_array_v
35 template <class T> constexpr bool is_pointer_v
36 = is_pointer<T>::value;
37 template <class T> constexpr bool is_lvalue_reference_v
38 = is_lvalue_reference<T>::value;
39 template <class T> constexpr bool is_rvalue_reference_v
40 = is_rvalue_reference<T>::value;
41 template <class T> constexpr bool is_member_object_pointer_v
42 = is_member_object_pointer<T>::value;
43 template <class T> constexpr bool is_member_function_pointer_v
44 = is_member_function_pointer<T>::value;
45 template <class T> constexpr bool is_enum_v
47 template <class T> constexpr bool is_union_v
49 template <class T> constexpr bool is_class_v
51 template <class T> constexpr bool is_function_v
52 = is_function<T>::value;
54 // See C++14 20.10.4.2, composite type categories
55 template <class T> constexpr bool is_reference_v
56 = is_reference<T>::value;
57 template <class T> constexpr bool is_arithmetic_v
58 = is_arithmetic<T>::value;
59 template <class T> constexpr bool is_fundamental_v
60 = is_fundamental<T>::value;
61 template <class T> constexpr bool is_object_v
62 = is_object<T>::value;
63 template <class T> constexpr bool is_scalar_v
64 = is_scalar<T>::value;
65 template <class T> constexpr bool is_compound_v
66 = is_compound<T>::value;
67 template <class T> constexpr bool is_member_pointer_v
68 = is_member_pointer<T>::value;
70 // See C++14 20.10.4.3, type properties
71 template <class T> constexpr bool is_const_v
73 template <class T> constexpr bool is_volatile_v
74 = is_volatile<T>::value;
75 template <class T> constexpr bool is_trivial_v
76 = is_trivial<T>::value;
77 template <class T> constexpr bool is_trivially_copyable_v
78 = is_trivially_copyable<T>::value;
79 template <class T> constexpr bool is_standard_layout_v
80 = is_standard_layout<T>::value;
81 template <class T> constexpr bool is_pod_v
83 template <class T> constexpr bool is_literal_type_v
84 = is_literal_type<T>::value;
85 template <class T> constexpr bool is_empty_v
87 template <class T> constexpr bool is_polymorphic_v
88 = is_polymorphic<T>::value;
89 template <class T> constexpr bool is_abstract_v
90 = is_abstract<T>::value;
91 template <class T> constexpr bool is_final_v
93 template <class T> constexpr bool is_signed_v
94 = is_signed<T>::value;
95 template <class T> constexpr bool is_unsigned_v
96 = is_unsigned<T>::value;
97 template <class T, class... Args> constexpr bool is_constructible_v
98 = is_constructible<T, Args...>::value;
99 template <class T> constexpr bool is_default_constructible_v
100 = is_default_constructible<T>::value;
101 template <class T> constexpr bool is_copy_constructible_v
102 = is_copy_constructible<T>::value;
103 template <class T> constexpr bool is_move_constructible_v
104 = is_move_constructible<T>::value;
105 template <class T, class U> constexpr bool is_assignable_v
106 = is_assignable<T, U>::value;
107 template <class T> constexpr bool is_copy_assignable_v
108 = is_copy_assignable<T>::value;
109 template <class T> constexpr bool is_move_assignable_v
110 = is_move_assignable<T>::value;
111 template <class T> constexpr bool is_destructible_v
112 = is_destructible<T>::value;
113 template <class T, class... Args> constexpr bool is_trivially_constructible_v
114 = is_trivially_constructible<T, Args...>::value;
115 template <class T> constexpr bool is_trivially_default_constructible_v
116 = is_trivially_default_constructible<T>::value;
117 template <class T> constexpr bool is_trivially_copy_constructible_v
118 = is_trivially_copy_constructible<T>::value;
119 template <class T> constexpr bool is_trivially_move_constructible_v
120 = is_trivially_move_constructible<T>::value;
121 template <class T, class U> constexpr bool is_trivially_assignable_v
122 = is_trivially_assignable<T, U>::value;
123 template <class T> constexpr bool is_trivially_copy_assignable_v
124 = is_trivially_copy_assignable<T>::value;
125 template <class T> constexpr bool is_trivially_move_assignable_v
126 = is_trivially_move_assignable<T>::value;
127 template <class T> constexpr bool is_trivially_destructible_v
128 = is_trivially_destructible<T>::value;
129 template <class T, class... Args> constexpr bool is_nothrow_constructible_v
130 = is_nothrow_constructible<T, Args...>::value;
131 template <class T> constexpr bool is_nothrow_default_constructible_v
132 = is_nothrow_default_constructible<T>::value;
133 template <class T> constexpr bool is_nothrow_copy_constructible_v
134 = is_nothrow_copy_constructible<T>::value;
135 template <class T> constexpr bool is_nothrow_move_constructible_v
136 = is_nothrow_move_constructible<T>::value;
137 template <class T, class U> constexpr bool is_nothrow_assignable_v
138 = is_nothrow_assignable<T, U>::value;
139 template <class T> constexpr bool is_nothrow_copy_assignable_v
140 = is_nothrow_copy_assignable<T>::value;
141 template <class T> constexpr bool is_nothrow_move_assignable_v
142 = is_nothrow_move_assignable<T>::value;
143 template <class T> constexpr bool is_nothrow_destructible_v
144 = is_nothrow_destructible<T>::value;
145 template <class T> constexpr bool has_virtual_destructor_v
146 = has_virtual_destructor<T>::value;
148 // See C++14 20.10.5, type property queries
149 template <class T> constexpr size_t alignment_of_v
150 = alignment_of<T>::value;
151 template <class T> constexpr size_t rank_v
153 template <class T, unsigned I = 0> constexpr size_t extent_v
154 = extent<T, I>::value;
156 // See C++14 20.10.6, type relations
157 template <class T, class U> constexpr bool is_same_v
158 = is_same<T, U>::value;
159 template <class Base, class Derived> constexpr bool is_base_of_v
160 = is_base_of<Base, Derived>::value;
161 template <class From, class To> constexpr bool is_convertible_v
162 = is_convertible<From, To>::value;
164 // 3.3.2, Other type transformations
165 template <class> class invocation_type; // not defined
166 template <class F, class... ArgTypes> class invocation_type<F(ArgTypes...)>;
167 template <class> class raw_invocation_type; // not defined
168 template <class F, class... ArgTypes> class raw_invocation_type<F(ArgTypes...)>;
171 using invocation_type_t = typename invocation_type<T>::type;
173 using raw_invocation_type_t = typename raw_invocation_type<T>::type;
175 } // namespace fundamentals_v1
176 } // namespace experimental
181 #include <experimental/__config>
183 #if _LIBCPP_STD_VER > 11
185 #include <type_traits>
187 _LIBCPP_BEGIN_NAMESPACE_LFTS
189 #if __has_feature(cxx_variable_templates)
191 // C++14 20.10.4.1, primary type categories
193 template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
194 = is_void<_Tp>::value;
196 template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
197 = is_null_pointer<_Tp>::value;
199 template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
200 = is_integral<_Tp>::value;
202 template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
203 = is_floating_point<_Tp>::value;
205 template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
206 = is_array<_Tp>::value;
208 template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
209 = is_pointer<_Tp>::value;
211 template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
212 = is_lvalue_reference<_Tp>::value;
214 template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
215 = is_rvalue_reference<_Tp>::value;
217 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
218 = is_member_object_pointer<_Tp>::value;
220 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
221 = is_member_function_pointer<_Tp>::value;
223 template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
224 = is_enum<_Tp>::value;
226 template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
227 = is_union<_Tp>::value;
229 template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
230 = is_class<_Tp>::value;
232 template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
233 = is_function<_Tp>::value;
235 // C++14 20.10.4.2, composite type categories
237 template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
238 = is_reference<_Tp>::value;
240 template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
241 = is_arithmetic<_Tp>::value;
243 template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
244 = is_fundamental<_Tp>::value;
246 template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
247 = is_object<_Tp>::value;
249 template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
250 = is_scalar<_Tp>::value;
252 template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
253 = is_compound<_Tp>::value;
255 template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
256 = is_member_pointer<_Tp>::value;
258 // C++14 20.10.4.3, type properties
260 template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
261 = is_const<_Tp>::value;
263 template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
264 = is_volatile<_Tp>::value;
266 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
267 = is_trivial<_Tp>::value;
269 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
270 = is_trivially_copyable<_Tp>::value;
272 template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
273 = is_standard_layout<_Tp>::value;
275 template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
276 = is_pod<_Tp>::value;
278 template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
279 = is_literal_type<_Tp>::value;
281 template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
282 = is_empty<_Tp>::value;
284 template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
285 = is_polymorphic<_Tp>::value;
287 template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
288 = is_abstract<_Tp>::value;
290 template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
291 = is_final<_Tp>::value;
293 template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
294 = is_signed<_Tp>::value;
296 template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
297 = is_unsigned<_Tp>::value;
299 template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_constructible_v
300 = is_constructible<_Tp, _Ts...>::value;
302 template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
303 = is_default_constructible<_Tp>::value;
305 template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
306 = is_copy_constructible<_Tp>::value;
308 template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
309 = is_move_constructible<_Tp>::value;
311 template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_assignable_v
312 = is_assignable<_Tp, _Up>::value;
314 template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
315 = is_copy_assignable<_Tp>::value;
317 template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
318 = is_move_assignable<_Tp>::value;
320 template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
321 = is_destructible<_Tp>::value;
323 template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
324 = is_trivially_constructible<_Tp, _Ts...>::value;
326 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
327 = is_trivially_default_constructible<_Tp>::value;
329 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
330 = is_trivially_copy_constructible<_Tp>::value;
332 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
333 = is_trivially_move_constructible<_Tp>::value;
335 template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
336 = is_trivially_assignable<_Tp, _Up>::value;
338 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
339 = is_trivially_copy_assignable<_Tp>::value;
341 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
342 = is_trivially_move_assignable<_Tp>::value;
344 template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
345 = is_trivially_destructible<_Tp>::value;
347 template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
348 = is_nothrow_constructible<_Tp, _Ts...>::value;
350 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
351 = is_nothrow_default_constructible<_Tp>::value;
353 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
354 = is_nothrow_copy_constructible<_Tp>::value;
356 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
357 = is_nothrow_move_constructible<_Tp>::value;
359 template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
360 = is_nothrow_assignable<_Tp, _Up>::value;
362 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
363 = is_nothrow_copy_assignable<_Tp>::value;
365 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
366 = is_nothrow_move_assignable<_Tp>::value;
368 template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
369 = is_nothrow_destructible<_Tp>::value;
371 template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
372 = has_virtual_destructor<_Tp>::value;
374 // C++14 20.10.5, type properties queries
376 template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
377 = alignment_of<_Tp>::value;
379 template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
382 template <class _Tp, unsigned _Id = 0> _LIBCPP_CONSTEXPR size_t extent_v
383 = extent<_Tp, _Id>::value;
385 // C++14 20.10.6, type relations
387 template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
388 = is_same<_Tp, _Up>::value;
390 template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_base_of_v
391 = is_base_of<_Tp, _Up>::value;
393 template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v
394 = is_convertible<_Tp, _Up>::value;
396 #endif /* __has_feature(cxx_variable_templates) */
398 // 3.3.2, Other type transformations
401 class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type;
403 template <class _Fn, class ..._Args>
404 class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type<_Fn(_Args...)>;
407 class _LIBCPP_TYPE_VIS_ONLY invokation_type;
409 template <class _Fn, class ..._Args>
410 class _LIBCPP_TYPE_VIS_ONLY invokation_type<_Fn(_Args...)>;
413 using invokation_type_t = typename invokation_type<_Tp>::type;
416 using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
419 _LIBCPP_END_NAMESPACE_LFTS
421 #endif /* _LIBCPP_STD_VER > 11 */
423 #endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */