]>
Commit | Line | Data |
---|---|---|
c0ffa2ba | 1 | // C++11 <type_traits> -*- C++ -*- |
af13a7a6 | 2 | |
a5544970 | 3 | // Copyright (C) 2007-2019 Free Software Foundation, Inc. |
af13a7a6 BK |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
af13a7a6 BK |
9 | // any later version. |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
748086b7 JJ |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the Free Software Foundation. | |
19 | ||
20 | // You should have received a copy of the GNU General Public License and | |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
af13a7a6 BK |
24 | |
25 | /** @file include/type_traits | |
26 | * This is a Standard C++ Library header. | |
27 | */ | |
28 | ||
4514bed6 BK |
29 | #ifndef _GLIBCXX_TYPE_TRAITS |
30 | #define _GLIBCXX_TYPE_TRAITS 1 | |
af13a7a6 BK |
31 | |
32 | #pragma GCC system_header | |
33 | ||
734f5023 | 34 | #if __cplusplus < 201103L |
ab65a4c7 | 35 | # include <bits/c++0x_warning.h> |
57317d2a | 36 | #else |
af13a7a6 | 37 | |
8fc81078 | 38 | #include <bits/c++config.h> |
e133ace8 | 39 | |
21e2806a JW |
40 | namespace std _GLIBCXX_VISIBILITY(default) |
41 | { | |
42 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
43 | ||
8e32aa11 | 44 | /** |
c0ffa2ba | 45 | * @defgroup metaprogramming Metaprogramming |
13901e4b JW |
46 | * @ingroup utilities |
47 | * | |
48 | * Template utilities for compile-time introspection and modification, | |
49 | * including type classification traits, type property inspection traits | |
50 | * and type transformation traits. | |
51 | * | |
5b9daa7e BK |
52 | * @{ |
53 | */ | |
ac65b7d2 DK |
54 | |
55 | /// integral_constant | |
56 | template<typename _Tp, _Tp __v> | |
57 | struct integral_constant | |
58 | { | |
59 | static constexpr _Tp value = __v; | |
60 | typedef _Tp value_type; | |
61 | typedef integral_constant<_Tp, __v> type; | |
352111c5 | 62 | constexpr operator value_type() const noexcept { return value; } |
db113eda | 63 | #if __cplusplus > 201103L |
a15f7cb8 ESR |
64 | |
65 | #define __cpp_lib_integral_constant_callable 201304 | |
66 | ||
352111c5 | 67 | constexpr value_type operator()() const noexcept { return value; } |
db113eda | 68 | #endif |
ac65b7d2 | 69 | }; |
33ac58d5 | 70 | |
c0ffa2ba BK |
71 | template<typename _Tp, _Tp __v> |
72 | constexpr _Tp integral_constant<_Tp, __v>::value; | |
73 | ||
13901e4b | 74 | /// The type used as a compile-time boolean with true value. |
ac65b7d2 DK |
75 | typedef integral_constant<bool, true> true_type; |
76 | ||
13901e4b | 77 | /// The type used as a compile-time boolean with false value. |
ac65b7d2 DK |
78 | typedef integral_constant<bool, false> false_type; |
79 | ||
f6b640be JW |
80 | template<bool __v> |
81 | using __bool_constant = integral_constant<bool, __v>; | |
82 | ||
46ba1281 | 83 | #if __cplusplus > 201402L |
f9badf71 | 84 | # define __cpp_lib_bool_constant 201505 |
46ba1281 JW |
85 | template<bool __v> |
86 | using bool_constant = integral_constant<bool, __v>; | |
87 | #endif | |
88 | ||
123c516a | 89 | // Meta programming helper types. |
53dc5044 | 90 | |
123c516a PC |
91 | template<bool, typename, typename> |
92 | struct conditional; | |
53dc5044 | 93 | |
608a080c | 94 | template <typename _Type> |
0d67cd38 JW |
95 | struct __type_identity |
96 | { using type = _Type; }; | |
97 | ||
98 | template<typename _Tp> | |
99 | using __type_identity_t = typename __type_identity<_Tp>::type; | |
608a080c | 100 | |
dd7b175e | 101 | template<typename...> |
123c516a PC |
102 | struct __or_; |
103 | ||
ac65b7d2 DK |
104 | template<> |
105 | struct __or_<> | |
106 | : public false_type | |
107 | { }; | |
108 | ||
dd7b175e PC |
109 | template<typename _B1> |
110 | struct __or_<_B1> | |
111 | : public _B1 | |
112 | { }; | |
113 | ||
123c516a PC |
114 | template<typename _B1, typename _B2> |
115 | struct __or_<_B1, _B2> | |
116 | : public conditional<_B1::value, _B1, _B2>::type | |
117 | { }; | |
118 | ||
119 | template<typename _B1, typename _B2, typename _B3, typename... _Bn> | |
120 | struct __or_<_B1, _B2, _B3, _Bn...> | |
121 | : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type | |
122 | { }; | |
53dc5044 | 123 | |
dd7b175e | 124 | template<typename...> |
123c516a | 125 | struct __and_; |
53dc5044 | 126 | |
ac65b7d2 DK |
127 | template<> |
128 | struct __and_<> | |
129 | : public true_type | |
130 | { }; | |
131 | ||
dd7b175e PC |
132 | template<typename _B1> |
133 | struct __and_<_B1> | |
134 | : public _B1 | |
135 | { }; | |
136 | ||
123c516a PC |
137 | template<typename _B1, typename _B2> |
138 | struct __and_<_B1, _B2> | |
139 | : public conditional<_B1::value, _B2, _B1>::type | |
140 | { }; | |
141 | ||
142 | template<typename _B1, typename _B2, typename _B3, typename... _Bn> | |
143 | struct __and_<_B1, _B2, _B3, _Bn...> | |
144 | : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type | |
145 | { }; | |
146 | ||
147 | template<typename _Pp> | |
148 | struct __not_ | |
4b9840f2 | 149 | : public __bool_constant<!bool(_Pp::value)> |
123c516a PC |
150 | { }; |
151 | ||
4b9840f2 | 152 | #if __cplusplus >= 201703L |
c3a6648b | 153 | |
b655b8fc JW |
154 | template<typename... _Bn> |
155 | inline constexpr bool __or_v = __or_<_Bn...>::value; | |
156 | template<typename... _Bn> | |
157 | inline constexpr bool __and_v = __and_<_Bn...>::value; | |
158 | ||
068c8ac1 | 159 | #define __cpp_lib_logical_traits 201510 |
c3a6648b VV |
160 | |
161 | template<typename... _Bn> | |
162 | struct conjunction | |
163 | : __and_<_Bn...> | |
164 | { }; | |
165 | ||
166 | template<typename... _Bn> | |
167 | struct disjunction | |
168 | : __or_<_Bn...> | |
169 | { }; | |
170 | ||
171 | template<typename _Pp> | |
172 | struct negation | |
173 | : __not_<_Pp> | |
174 | { }; | |
137422c8 VV |
175 | |
176 | template<typename... _Bn> | |
4b9840f2 | 177 | inline constexpr bool conjunction_v = conjunction<_Bn...>::value; |
42183d03 | 178 | |
137422c8 | 179 | template<typename... _Bn> |
4b9840f2 | 180 | inline constexpr bool disjunction_v = disjunction<_Bn...>::value; |
42183d03 | 181 | |
137422c8 | 182 | template<typename _Pp> |
4b9840f2 | 183 | inline constexpr bool negation_v = negation<_Pp>::value; |
137422c8 | 184 | |
4b9840f2 | 185 | #endif // C++17 |
c3a6648b | 186 | |
608a080c AP |
187 | // Forward declarations |
188 | template<typename> | |
189 | struct is_reference; | |
190 | template<typename> | |
191 | struct is_function; | |
192 | template<typename> | |
193 | struct is_void; | |
194 | template<typename> | |
195 | struct __is_array_unknown_bounds; | |
196 | ||
197 | // Helper functions that return false_type for incomplete classes, | |
198 | // incomplete unions and arrays of known bound from those. | |
199 | ||
200 | template <typename _T, size_t = sizeof(_T)> | |
201 | constexpr true_type __is_complete_or_unbounded(__type_identity<_T>) | |
202 | { return {}; } | |
203 | ||
204 | template <typename _TypeIdentity, | |
205 | typename _NestedType = typename _TypeIdentity::type> | |
206 | constexpr typename __or_< | |
207 | is_reference<_NestedType>, | |
208 | is_function<_NestedType>, | |
209 | is_void<_NestedType>, | |
210 | __is_array_unknown_bounds<_NestedType> | |
211 | >::type __is_complete_or_unbounded(_TypeIdentity) | |
212 | { return {}; } | |
213 | ||
b3618b71 DK |
214 | // For several sfinae-friendly trait implementations we transport both the |
215 | // result information (as the member type) and the failure information (no | |
216 | // member type). This is very similar to std::enable_if, but we cannot use | |
217 | // them, because we need to derive from them as an implementation detail. | |
218 | ||
219 | template<typename _Tp> | |
220 | struct __success_type | |
221 | { typedef _Tp type; }; | |
222 | ||
223 | struct __failure_type | |
224 | { }; | |
225 | ||
c0ffa2ba | 226 | // Primary type categories. |
123c516a | 227 | |
53dc5044 PC |
228 | template<typename> |
229 | struct remove_cv; | |
230 | ||
231 | template<typename> | |
232 | struct __is_void_helper | |
233 | : public false_type { }; | |
53dc5044 | 234 | |
123c516a PC |
235 | template<> |
236 | struct __is_void_helper<void> | |
237 | : public true_type { }; | |
53dc5044 PC |
238 | |
239 | /// is_void | |
240 | template<typename _Tp> | |
241 | struct is_void | |
82b12c4b | 242 | : public __is_void_helper<typename remove_cv<_Tp>::type>::type |
53dc5044 PC |
243 | { }; |
244 | ||
245 | template<typename> | |
246 | struct __is_integral_helper | |
247 | : public false_type { }; | |
123c516a PC |
248 | |
249 | template<> | |
250 | struct __is_integral_helper<bool> | |
251 | : public true_type { }; | |
33ac58d5 | 252 | |
123c516a PC |
253 | template<> |
254 | struct __is_integral_helper<char> | |
255 | : public true_type { }; | |
256 | ||
257 | template<> | |
258 | struct __is_integral_helper<signed char> | |
259 | : public true_type { }; | |
260 | ||
261 | template<> | |
262 | struct __is_integral_helper<unsigned char> | |
263 | : public true_type { }; | |
264 | ||
53dc5044 | 265 | #ifdef _GLIBCXX_USE_WCHAR_T |
123c516a PC |
266 | template<> |
267 | struct __is_integral_helper<wchar_t> | |
268 | : public true_type { }; | |
53dc5044 | 269 | #endif |
123c516a | 270 | |
c124af93 TH |
271 | #ifdef _GLIBCXX_USE_CHAR8_T |
272 | template<> | |
273 | struct __is_integral_helper<char8_t> | |
274 | : public true_type { }; | |
275 | #endif | |
276 | ||
123c516a PC |
277 | template<> |
278 | struct __is_integral_helper<char16_t> | |
279 | : public true_type { }; | |
280 | ||
281 | template<> | |
282 | struct __is_integral_helper<char32_t> | |
283 | : public true_type { }; | |
284 | ||
285 | template<> | |
286 | struct __is_integral_helper<short> | |
287 | : public true_type { }; | |
288 | ||
289 | template<> | |
290 | struct __is_integral_helper<unsigned short> | |
291 | : public true_type { }; | |
292 | ||
293 | template<> | |
294 | struct __is_integral_helper<int> | |
295 | : public true_type { }; | |
296 | ||
297 | template<> | |
298 | struct __is_integral_helper<unsigned int> | |
299 | : public true_type { }; | |
300 | ||
301 | template<> | |
302 | struct __is_integral_helper<long> | |
303 | : public true_type { }; | |
304 | ||
305 | template<> | |
306 | struct __is_integral_helper<unsigned long> | |
307 | : public true_type { }; | |
308 | ||
309 | template<> | |
310 | struct __is_integral_helper<long long> | |
311 | : public true_type { }; | |
312 | ||
313 | template<> | |
314 | struct __is_integral_helper<unsigned long long> | |
315 | : public true_type { }; | |
53dc5044 | 316 | |
78a7c317 DD |
317 | // Conditionalizing on __STRICT_ANSI__ here will break any port that |
318 | // uses one of these types for size_t. | |
319 | #if defined(__GLIBCXX_TYPE_INT_N_0) | |
6d585f01 | 320 | template<> |
78a7c317 | 321 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0> |
6d585f01 PC |
322 | : public true_type { }; |
323 | ||
324 | template<> | |
78a7c317 DD |
325 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0> |
326 | : public true_type { }; | |
327 | #endif | |
328 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
329 | template<> | |
330 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1> | |
331 | : public true_type { }; | |
332 | ||
333 | template<> | |
334 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1> | |
335 | : public true_type { }; | |
336 | #endif | |
337 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
338 | template<> | |
339 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2> | |
340 | : public true_type { }; | |
341 | ||
342 | template<> | |
343 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2> | |
344 | : public true_type { }; | |
345 | #endif | |
346 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
347 | template<> | |
348 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3> | |
349 | : public true_type { }; | |
350 | ||
351 | template<> | |
352 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3> | |
6d585f01 PC |
353 | : public true_type { }; |
354 | #endif | |
355 | ||
53dc5044 PC |
356 | /// is_integral |
357 | template<typename _Tp> | |
358 | struct is_integral | |
82b12c4b | 359 | : public __is_integral_helper<typename remove_cv<_Tp>::type>::type |
53dc5044 PC |
360 | { }; |
361 | ||
362 | template<typename> | |
363 | struct __is_floating_point_helper | |
364 | : public false_type { }; | |
123c516a PC |
365 | |
366 | template<> | |
367 | struct __is_floating_point_helper<float> | |
368 | : public true_type { }; | |
369 | ||
370 | template<> | |
371 | struct __is_floating_point_helper<double> | |
372 | : public true_type { }; | |
373 | ||
374 | template<> | |
375 | struct __is_floating_point_helper<long double> | |
376 | : public true_type { }; | |
53dc5044 | 377 | |
6d585f01 PC |
378 | #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) |
379 | template<> | |
380 | struct __is_floating_point_helper<__float128> | |
381 | : public true_type { }; | |
382 | #endif | |
383 | ||
53dc5044 PC |
384 | /// is_floating_point |
385 | template<typename _Tp> | |
386 | struct is_floating_point | |
82b12c4b | 387 | : public __is_floating_point_helper<typename remove_cv<_Tp>::type>::type |
53dc5044 PC |
388 | { }; |
389 | ||
390 | /// is_array | |
391 | template<typename> | |
392 | struct is_array | |
393 | : public false_type { }; | |
394 | ||
395 | template<typename _Tp, std::size_t _Size> | |
396 | struct is_array<_Tp[_Size]> | |
397 | : public true_type { }; | |
398 | ||
399 | template<typename _Tp> | |
400 | struct is_array<_Tp[]> | |
401 | : public true_type { }; | |
402 | ||
403 | template<typename> | |
404 | struct __is_pointer_helper | |
405 | : public false_type { }; | |
123c516a PC |
406 | |
407 | template<typename _Tp> | |
408 | struct __is_pointer_helper<_Tp*> | |
409 | : public true_type { }; | |
53dc5044 PC |
410 | |
411 | /// is_pointer | |
412 | template<typename _Tp> | |
413 | struct is_pointer | |
82b12c4b | 414 | : public __is_pointer_helper<typename remove_cv<_Tp>::type>::type |
53dc5044 PC |
415 | { }; |
416 | ||
123c516a PC |
417 | /// is_lvalue_reference |
418 | template<typename> | |
419 | struct is_lvalue_reference | |
420 | : public false_type { }; | |
421 | ||
53dc5044 | 422 | template<typename _Tp> |
123c516a PC |
423 | struct is_lvalue_reference<_Tp&> |
424 | : public true_type { }; | |
425 | ||
426 | /// is_rvalue_reference | |
427 | template<typename> | |
428 | struct is_rvalue_reference | |
429 | : public false_type { }; | |
53dc5044 | 430 | |
53dc5044 | 431 | template<typename _Tp> |
123c516a PC |
432 | struct is_rvalue_reference<_Tp&&> |
433 | : public true_type { }; | |
434 | ||
53dc5044 PC |
435 | template<typename> |
436 | struct __is_member_object_pointer_helper | |
437 | : public false_type { }; | |
123c516a PC |
438 | |
439 | template<typename _Tp, typename _Cp> | |
440 | struct __is_member_object_pointer_helper<_Tp _Cp::*> | |
c01f9216 | 441 | : public __not_<is_function<_Tp>>::type { }; |
53dc5044 PC |
442 | |
443 | /// is_member_object_pointer | |
444 | template<typename _Tp> | |
445 | struct is_member_object_pointer | |
82b12c4b FD |
446 | : public __is_member_object_pointer_helper< |
447 | typename remove_cv<_Tp>::type>::type | |
53dc5044 PC |
448 | { }; |
449 | ||
450 | template<typename> | |
451 | struct __is_member_function_pointer_helper | |
452 | : public false_type { }; | |
123c516a PC |
453 | |
454 | template<typename _Tp, typename _Cp> | |
455 | struct __is_member_function_pointer_helper<_Tp _Cp::*> | |
c01f9216 | 456 | : public is_function<_Tp>::type { }; |
53dc5044 PC |
457 | |
458 | /// is_member_function_pointer | |
459 | template<typename _Tp> | |
460 | struct is_member_function_pointer | |
82b12c4b FD |
461 | : public __is_member_function_pointer_helper< |
462 | typename remove_cv<_Tp>::type>::type | |
53dc5044 PC |
463 | { }; |
464 | ||
465 | /// is_enum | |
466 | template<typename _Tp> | |
467 | struct is_enum | |
468 | : public integral_constant<bool, __is_enum(_Tp)> | |
469 | { }; | |
470 | ||
471 | /// is_union | |
472 | template<typename _Tp> | |
473 | struct is_union | |
474 | : public integral_constant<bool, __is_union(_Tp)> | |
475 | { }; | |
476 | ||
477 | /// is_class | |
478 | template<typename _Tp> | |
479 | struct is_class | |
480 | : public integral_constant<bool, __is_class(_Tp)> | |
481 | { }; | |
482 | ||
483 | /// is_function | |
484 | template<typename> | |
485 | struct is_function | |
486 | : public false_type { }; | |
123c516a | 487 | |
51dc6603 JM |
488 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
489 | struct is_function<_Res(_ArgTypes...) _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 490 | : public true_type { }; |
123c516a | 491 | |
51dc6603 JM |
492 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
493 | struct is_function<_Res(_ArgTypes...) & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
494 | : public true_type { }; |
495 | ||
51dc6603 JM |
496 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
497 | struct is_function<_Res(_ArgTypes...) && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
498 | : public true_type { }; |
499 | ||
51dc6603 JM |
500 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
501 | struct is_function<_Res(_ArgTypes......) _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 502 | : public true_type { }; |
123c516a | 503 | |
51dc6603 JM |
504 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
505 | struct is_function<_Res(_ArgTypes......) & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
506 | : public true_type { }; |
507 | ||
51dc6603 JM |
508 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
509 | struct is_function<_Res(_ArgTypes......) && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
510 | : public true_type { }; |
511 | ||
51dc6603 JM |
512 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
513 | struct is_function<_Res(_ArgTypes...) const _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 514 | : public true_type { }; |
123c516a | 515 | |
51dc6603 JM |
516 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
517 | struct is_function<_Res(_ArgTypes...) const & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
518 | : public true_type { }; |
519 | ||
51dc6603 JM |
520 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
521 | struct is_function<_Res(_ArgTypes...) const && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
522 | : public true_type { }; |
523 | ||
51dc6603 JM |
524 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
525 | struct is_function<_Res(_ArgTypes......) const _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 526 | : public true_type { }; |
123c516a | 527 | |
51dc6603 JM |
528 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
529 | struct is_function<_Res(_ArgTypes......) const & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
530 | : public true_type { }; |
531 | ||
51dc6603 JM |
532 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
533 | struct is_function<_Res(_ArgTypes......) const && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
534 | : public true_type { }; |
535 | ||
51dc6603 JM |
536 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
537 | struct is_function<_Res(_ArgTypes...) volatile _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 538 | : public true_type { }; |
123c516a | 539 | |
51dc6603 JM |
540 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
541 | struct is_function<_Res(_ArgTypes...) volatile & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
542 | : public true_type { }; |
543 | ||
51dc6603 JM |
544 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
545 | struct is_function<_Res(_ArgTypes...) volatile && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
546 | : public true_type { }; |
547 | ||
51dc6603 JM |
548 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
549 | struct is_function<_Res(_ArgTypes......) volatile _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 550 | : public true_type { }; |
123c516a | 551 | |
51dc6603 JM |
552 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
553 | struct is_function<_Res(_ArgTypes......) volatile & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
554 | : public true_type { }; |
555 | ||
51dc6603 JM |
556 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
557 | struct is_function<_Res(_ArgTypes......) volatile && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
558 | : public true_type { }; |
559 | ||
51dc6603 JM |
560 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
561 | struct is_function<_Res(_ArgTypes...) const volatile _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 | 562 | : public true_type { }; |
123c516a | 563 | |
51dc6603 JM |
564 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
565 | struct is_function<_Res(_ArgTypes...) const volatile & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
566 | : public true_type { }; |
567 | ||
51dc6603 JM |
568 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
569 | struct is_function<_Res(_ArgTypes...) const volatile && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
570 | : public true_type { }; |
571 | ||
51dc6603 JM |
572 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
573 | struct is_function<_Res(_ArgTypes......) const volatile _GLIBCXX_NOEXCEPT_QUAL> | |
53dc5044 PC |
574 | : public true_type { }; |
575 | ||
51dc6603 JM |
576 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
577 | struct is_function<_Res(_ArgTypes......) const volatile & _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
578 | : public true_type { }; |
579 | ||
51dc6603 JM |
580 | template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> |
581 | struct is_function<_Res(_ArgTypes......) const volatile && _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
582 | : public true_type { }; |
583 | ||
a15f7cb8 ESR |
584 | #define __cpp_lib_is_null_pointer 201309 |
585 | ||
1e673415 | 586 | template<typename> |
aa940ab5 | 587 | struct __is_null_pointer_helper |
1e673415 | 588 | : public false_type { }; |
123c516a PC |
589 | |
590 | template<> | |
aa940ab5 | 591 | struct __is_null_pointer_helper<std::nullptr_t> |
123c516a | 592 | : public true_type { }; |
1e673415 | 593 | |
aa940ab5 PC |
594 | /// is_null_pointer (LWG 2247). |
595 | template<typename _Tp> | |
596 | struct is_null_pointer | |
597 | : public __is_null_pointer_helper<typename remove_cv<_Tp>::type>::type | |
598 | { }; | |
599 | ||
07fd852f | 600 | /// __is_nullptr_t (deprecated extension). |
1e673415 PC |
601 | template<typename _Tp> |
602 | struct __is_nullptr_t | |
aa940ab5 | 603 | : public is_null_pointer<_Tp> |
07fd852f | 604 | { } _GLIBCXX_DEPRECATED; |
1e673415 | 605 | |
c0ffa2ba | 606 | // Composite type categories. |
123c516a PC |
607 | |
608 | /// is_reference | |
609 | template<typename _Tp> | |
610 | struct is_reference | |
611 | : public __or_<is_lvalue_reference<_Tp>, | |
612 | is_rvalue_reference<_Tp>>::type | |
613 | { }; | |
614 | ||
53dc5044 PC |
615 | /// is_arithmetic |
616 | template<typename _Tp> | |
617 | struct is_arithmetic | |
123c516a | 618 | : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type |
53dc5044 PC |
619 | { }; |
620 | ||
621 | /// is_fundamental | |
622 | template<typename _Tp> | |
623 | struct is_fundamental | |
aa940ab5 PC |
624 | : public __or_<is_arithmetic<_Tp>, is_void<_Tp>, |
625 | is_null_pointer<_Tp>>::type | |
53dc5044 PC |
626 | { }; |
627 | ||
628 | /// is_object | |
629 | template<typename _Tp> | |
630 | struct is_object | |
123c516a PC |
631 | : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>, |
632 | is_void<_Tp>>>::type | |
53dc5044 PC |
633 | { }; |
634 | ||
123c516a | 635 | template<typename> |
53dc5044 PC |
636 | struct is_member_pointer; |
637 | ||
638 | /// is_scalar | |
639 | template<typename _Tp> | |
640 | struct is_scalar | |
123c516a | 641 | : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>, |
aa940ab5 | 642 | is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type |
53dc5044 PC |
643 | { }; |
644 | ||
645 | /// is_compound | |
646 | template<typename _Tp> | |
647 | struct is_compound | |
c01f9216 | 648 | : public __not_<is_fundamental<_Tp>>::type { }; |
53dc5044 | 649 | |
53dc5044 PC |
650 | template<typename _Tp> |
651 | struct __is_member_pointer_helper | |
652 | : public false_type { }; | |
123c516a PC |
653 | |
654 | template<typename _Tp, typename _Cp> | |
655 | struct __is_member_pointer_helper<_Tp _Cp::*> | |
656 | : public true_type { }; | |
53dc5044 | 657 | |
13901e4b | 658 | /// is_member_pointer |
53dc5044 | 659 | template<typename _Tp> |
123c516a | 660 | struct is_member_pointer |
82b12c4b | 661 | : public __is_member_pointer_helper<typename remove_cv<_Tp>::type>::type |
53dc5044 PC |
662 | { }; |
663 | ||
47f79054 JW |
664 | template<typename, typename> |
665 | struct is_same; | |
666 | ||
667 | template<typename _Tp, typename... _Types> | |
668 | using __is_one_of = __or_<is_same<_Tp, _Types>...>; | |
669 | ||
670 | // Check if a type is one of the signed integer types. | |
671 | template<typename _Tp> | |
672 | using __is_signed_integer = __is_one_of<typename remove_cv<_Tp>::type, | |
673 | signed char, signed short, signed int, signed long, | |
674 | signed long long | |
675 | #if defined(__GLIBCXX_TYPE_INT_N_0) | |
676 | , signed __GLIBCXX_TYPE_INT_N_0 | |
677 | #endif | |
678 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
679 | , signed __GLIBCXX_TYPE_INT_N_1 | |
680 | #endif | |
681 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
682 | , signed __GLIBCXX_TYPE_INT_N_2 | |
683 | #endif | |
684 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
685 | , signed __GLIBCXX_TYPE_INT_N_3 | |
686 | #endif | |
687 | >; | |
688 | ||
689 | // Check if a type is one of the unsigned integer types. | |
690 | template<typename _Tp> | |
691 | using __is_unsigned_integer = __is_one_of<typename remove_cv<_Tp>::type, | |
692 | unsigned char, unsigned short, unsigned int, unsigned long, | |
693 | unsigned long long | |
694 | #if defined(__GLIBCXX_TYPE_INT_N_0) | |
695 | , unsigned __GLIBCXX_TYPE_INT_N_0 | |
696 | #endif | |
697 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
698 | , unsigned __GLIBCXX_TYPE_INT_N_1 | |
699 | #endif | |
700 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
701 | , unsigned __GLIBCXX_TYPE_INT_N_2 | |
702 | #endif | |
703 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
704 | , unsigned __GLIBCXX_TYPE_INT_N_3 | |
705 | #endif | |
706 | >; | |
707 | ||
708 | ||
89898034 DK |
709 | // Utility to detect referenceable types ([defns.referenceable]). |
710 | ||
711 | template<typename _Tp> | |
712 | struct __is_referenceable | |
713 | : public __or_<is_object<_Tp>, is_reference<_Tp>>::type | |
714 | { }; | |
715 | ||
c6ab9061 JW |
716 | template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM> |
717 | struct __is_referenceable<_Res(_Args...) _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
718 | : public true_type |
719 | { }; | |
720 | ||
c6ab9061 JW |
721 | template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM> |
722 | struct __is_referenceable<_Res(_Args......) _GLIBCXX_NOEXCEPT_QUAL> | |
89898034 DK |
723 | : public true_type |
724 | { }; | |
725 | ||
c0ffa2ba | 726 | // Type properties. |
123c516a | 727 | |
53dc5044 PC |
728 | /// is_const |
729 | template<typename> | |
730 | struct is_const | |
731 | : public false_type { }; | |
732 | ||
733 | template<typename _Tp> | |
734 | struct is_const<_Tp const> | |
735 | : public true_type { }; | |
33ac58d5 | 736 | |
53dc5044 PC |
737 | /// is_volatile |
738 | template<typename> | |
739 | struct is_volatile | |
740 | : public false_type { }; | |
741 | ||
742 | template<typename _Tp> | |
743 | struct is_volatile<_Tp volatile> | |
744 | : public true_type { }; | |
745 | ||
123c516a PC |
746 | /// is_trivial |
747 | template<typename _Tp> | |
748 | struct is_trivial | |
749 | : public integral_constant<bool, __is_trivial(_Tp)> | |
608a080c AP |
750 | { |
751 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
752 | "template argument must be a complete class or an unbounded array"); | |
753 | }; | |
123c516a | 754 | |
f5e523b7 VV |
755 | // is_trivially_copyable |
756 | template<typename _Tp> | |
757 | struct is_trivially_copyable | |
758 | : public integral_constant<bool, __is_trivially_copyable(_Tp)> | |
608a080c AP |
759 | { |
760 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
761 | "template argument must be a complete class or an unbounded array"); | |
762 | }; | |
123c516a PC |
763 | |
764 | /// is_standard_layout | |
765 | template<typename _Tp> | |
766 | struct is_standard_layout | |
767 | : public integral_constant<bool, __is_standard_layout(_Tp)> | |
608a080c AP |
768 | { |
769 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
770 | "template argument must be a complete class or an unbounded array"); | |
771 | }; | |
123c516a PC |
772 | |
773 | /// is_pod | |
774 | // Could use is_standard_layout && is_trivial instead of the builtin. | |
775 | template<typename _Tp> | |
776 | struct is_pod | |
777 | : public integral_constant<bool, __is_pod(_Tp)> | |
608a080c AP |
778 | { |
779 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
780 | "template argument must be a complete class or an unbounded array"); | |
781 | }; | |
123c516a PC |
782 | |
783 | /// is_literal_type | |
784 | template<typename _Tp> | |
785 | struct is_literal_type | |
786 | : public integral_constant<bool, __is_literal_type(_Tp)> | |
608a080c AP |
787 | { |
788 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
789 | "template argument must be a complete class or an unbounded array"); | |
790 | }; | |
123c516a | 791 | |
53dc5044 PC |
792 | /// is_empty |
793 | template<typename _Tp> | |
794 | struct is_empty | |
795 | : public integral_constant<bool, __is_empty(_Tp)> | |
209ee624 | 796 | { }; |
53dc5044 PC |
797 | |
798 | /// is_polymorphic | |
799 | template<typename _Tp> | |
800 | struct is_polymorphic | |
801 | : public integral_constant<bool, __is_polymorphic(_Tp)> | |
209ee624 | 802 | { }; |
53dc5044 | 803 | |
4db7fcb9 ESR |
804 | #if __cplusplus >= 201402L |
805 | #define __cpp_lib_is_final 201402L | |
806 | /// is_final | |
807 | template<typename _Tp> | |
808 | struct is_final | |
809 | : public integral_constant<bool, __is_final(_Tp)> | |
209ee624 | 810 | { }; |
4db7fcb9 ESR |
811 | #endif |
812 | ||
53dc5044 PC |
813 | /// is_abstract |
814 | template<typename _Tp> | |
815 | struct is_abstract | |
816 | : public integral_constant<bool, __is_abstract(_Tp)> | |
209ee624 | 817 | { }; |
53dc5044 | 818 | |
123c516a | 819 | template<typename _Tp, |
6a4b1a00 | 820 | bool = is_arithmetic<_Tp>::value> |
123c516a PC |
821 | struct __is_signed_helper |
822 | : public false_type { }; | |
823 | ||
53dc5044 | 824 | template<typename _Tp> |
6a4b1a00 PC |
825 | struct __is_signed_helper<_Tp, true> |
826 | : public integral_constant<bool, _Tp(-1) < _Tp(0)> | |
53dc5044 PC |
827 | { }; |
828 | ||
123c516a | 829 | /// is_signed |
53dc5044 | 830 | template<typename _Tp> |
123c516a | 831 | struct is_signed |
82b12c4b | 832 | : public __is_signed_helper<_Tp>::type |
123c516a PC |
833 | { }; |
834 | ||
835 | /// is_unsigned | |
836 | template<typename _Tp> | |
837 | struct is_unsigned | |
f7632193 | 838 | : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>> |
123c516a PC |
839 | { }; |
840 | ||
841 | ||
c0ffa2ba | 842 | // Destructible and constructible type properties. |
123c516a | 843 | |
13901e4b JW |
844 | /** |
845 | * @brief Utility to simplify expressions used in unevaluated operands | |
846 | * @ingroup utilities | |
847 | */ | |
ec26ff5a JW |
848 | |
849 | template<typename _Tp, typename _Up = _Tp&&> | |
850 | _Up | |
851 | __declval(int); | |
852 | ||
853 | template<typename _Tp> | |
854 | _Tp | |
855 | __declval(long); | |
856 | ||
53dc5044 | 857 | template<typename _Tp> |
ec26ff5a | 858 | auto declval() noexcept -> decltype(__declval<_Tp>(0)); |
53dc5044 | 859 | |
123c516a PC |
860 | template<typename, unsigned = 0> |
861 | struct extent; | |
862 | ||
863 | template<typename> | |
864 | struct remove_all_extents; | |
865 | ||
866 | template<typename _Tp> | |
867 | struct __is_array_known_bounds | |
868 | : public integral_constant<bool, (extent<_Tp>::value > 0)> | |
53dc5044 PC |
869 | { }; |
870 | ||
123c516a PC |
871 | template<typename _Tp> |
872 | struct __is_array_unknown_bounds | |
f7632193 | 873 | : public __and_<is_array<_Tp>, __not_<extent<_Tp>>> |
53dc5044 | 874 | { }; |
33ac58d5 | 875 | |
62fa805f | 876 | // In N3290 is_destructible does not say anything about function |
2c7a09d7 | 877 | // types and abstract types, see LWG 2049. This implementation |
62fa805f DK |
878 | // describes function types as non-destructible and all complete |
879 | // object types as destructible, iff the explicit destructor | |
2c7a09d7 | 880 | // call expression is wellformed. |
62fa805f | 881 | struct __do_is_destructible_impl |
123c516a | 882 | { |
62fa805f | 883 | template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())> |
123c516a PC |
884 | static true_type __test(int); |
885 | ||
886 | template<typename> | |
887 | static false_type __test(...); | |
888 | }; | |
53dc5044 PC |
889 | |
890 | template<typename _Tp> | |
62fa805f DK |
891 | struct __is_destructible_impl |
892 | : public __do_is_destructible_impl | |
123c516a PC |
893 | { |
894 | typedef decltype(__test<_Tp>(0)) type; | |
895 | }; | |
53dc5044 | 896 | |
62fa805f DK |
897 | template<typename _Tp, |
898 | bool = __or_<is_void<_Tp>, | |
899 | __is_array_unknown_bounds<_Tp>, | |
900 | is_function<_Tp>>::value, | |
901 | bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> | |
902 | struct __is_destructible_safe; | |
903 | ||
904 | template<typename _Tp> | |
905 | struct __is_destructible_safe<_Tp, false, false> | |
906 | : public __is_destructible_impl<typename | |
907 | remove_all_extents<_Tp>::type>::type | |
908 | { }; | |
909 | ||
910 | template<typename _Tp> | |
911 | struct __is_destructible_safe<_Tp, true, false> | |
912 | : public false_type { }; | |
913 | ||
914 | template<typename _Tp> | |
915 | struct __is_destructible_safe<_Tp, false, true> | |
916 | : public true_type { }; | |
917 | ||
918 | /// is_destructible | |
919 | template<typename _Tp> | |
920 | struct is_destructible | |
82b12c4b | 921 | : public __is_destructible_safe<_Tp>::type |
608a080c AP |
922 | { |
923 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
924 | "template argument must be a complete class or an unbounded array"); | |
925 | }; | |
62fa805f DK |
926 | |
927 | // is_nothrow_destructible requires that is_destructible is | |
928 | // satisfied as well. We realize that by mimicing the | |
929 | // implementation of is_destructible but refer to noexcept(expr) | |
930 | // instead of decltype(expr). | |
931 | struct __do_is_nt_destructible_impl | |
123c516a | 932 | { |
62fa805f | 933 | template<typename _Tp> |
c01f9216 JW |
934 | static __bool_constant<noexcept(declval<_Tp&>().~_Tp())> |
935 | __test(int); | |
123c516a PC |
936 | |
937 | template<typename> | |
938 | static false_type __test(...); | |
939 | }; | |
53dc5044 | 940 | |
53dc5044 | 941 | template<typename _Tp> |
62fa805f DK |
942 | struct __is_nt_destructible_impl |
943 | : public __do_is_nt_destructible_impl | |
123c516a PC |
944 | { |
945 | typedef decltype(__test<_Tp>(0)) type; | |
946 | }; | |
947 | ||
948 | template<typename _Tp, | |
949 | bool = __or_<is_void<_Tp>, | |
62fa805f DK |
950 | __is_array_unknown_bounds<_Tp>, |
951 | is_function<_Tp>>::value, | |
952 | bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> | |
953 | struct __is_nt_destructible_safe; | |
53dc5044 PC |
954 | |
955 | template<typename _Tp> | |
62fa805f DK |
956 | struct __is_nt_destructible_safe<_Tp, false, false> |
957 | : public __is_nt_destructible_impl<typename | |
958 | remove_all_extents<_Tp>::type>::type | |
123c516a PC |
959 | { }; |
960 | ||
53dc5044 | 961 | template<typename _Tp> |
62fa805f | 962 | struct __is_nt_destructible_safe<_Tp, true, false> |
123c516a | 963 | : public false_type { }; |
53dc5044 PC |
964 | |
965 | template<typename _Tp> | |
62fa805f | 966 | struct __is_nt_destructible_safe<_Tp, false, true> |
123c516a PC |
967 | : public true_type { }; |
968 | ||
62fa805f | 969 | /// is_nothrow_destructible |
53dc5044 | 970 | template<typename _Tp> |
62fa805f | 971 | struct is_nothrow_destructible |
82b12c4b | 972 | : public __is_nt_destructible_safe<_Tp>::type |
608a080c AP |
973 | { |
974 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
975 | "template argument must be a complete class or an unbounded array"); | |
976 | }; | |
977 | ||
978 | template<typename _Tp, typename... _Args> | |
979 | struct __is_constructible_impl | |
980 | : public __bool_constant<__is_constructible(_Tp, _Args...)> | |
123c516a PC |
981 | { }; |
982 | ||
58487c21 JW |
983 | /// is_constructible |
984 | template<typename _Tp, typename... _Args> | |
985 | struct is_constructible | |
608a080c AP |
986 | : public __is_constructible_impl<_Tp, _Args...> |
987 | { | |
988 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
989 | "template argument must be a complete class or an unbounded array"); | |
990 | }; | |
4a27a739 | 991 | |
123c516a | 992 | /// is_default_constructible |
4a27a739 | 993 | template<typename _Tp> |
123c516a | 994 | struct is_default_constructible |
608a080c AP |
995 | : public __is_constructible_impl<_Tp>::type |
996 | { | |
997 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
998 | "template argument must be a complete class or an unbounded array"); | |
999 | }; | |
c32097d8 | 1000 | |
89898034 | 1001 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
65cee9bd | 1002 | struct __is_copy_constructible_impl; |
123c516a | 1003 | |
65cee9bd | 1004 | template<typename _Tp> |
89898034 | 1005 | struct __is_copy_constructible_impl<_Tp, false> |
65cee9bd PC |
1006 | : public false_type { }; |
1007 | ||
1008 | template<typename _Tp> | |
89898034 | 1009 | struct __is_copy_constructible_impl<_Tp, true> |
608a080c | 1010 | : public __is_constructible_impl<_Tp, const _Tp&> |
65cee9bd PC |
1011 | { }; |
1012 | ||
1013 | /// is_copy_constructible | |
1014 | template<typename _Tp> | |
1015 | struct is_copy_constructible | |
1016 | : public __is_copy_constructible_impl<_Tp> | |
608a080c AP |
1017 | { |
1018 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1019 | "template argument must be a complete class or an unbounded array"); | |
1020 | }; | |
65cee9bd | 1021 | |
89898034 | 1022 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
65cee9bd PC |
1023 | struct __is_move_constructible_impl; |
1024 | ||
1025 | template<typename _Tp> | |
89898034 | 1026 | struct __is_move_constructible_impl<_Tp, false> |
65cee9bd PC |
1027 | : public false_type { }; |
1028 | ||
1029 | template<typename _Tp> | |
89898034 | 1030 | struct __is_move_constructible_impl<_Tp, true> |
608a080c | 1031 | : public __is_constructible_impl<_Tp, _Tp&&> |
65cee9bd PC |
1032 | { }; |
1033 | ||
1034 | /// is_move_constructible | |
1035 | template<typename _Tp> | |
1036 | struct is_move_constructible | |
1037 | : public __is_move_constructible_impl<_Tp> | |
608a080c AP |
1038 | { |
1039 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1040 | "template argument must be a complete class or an unbounded array"); | |
1041 | }; | |
65cee9bd PC |
1042 | |
1043 | template<typename _Tp> | |
1044 | struct __is_nt_default_constructible_atom | |
1045 | : public integral_constant<bool, noexcept(_Tp())> | |
1046 | { }; | |
1047 | ||
1048 | template<typename _Tp, bool = is_array<_Tp>::value> | |
1049 | struct __is_nt_default_constructible_impl; | |
1050 | ||
1051 | template<typename _Tp> | |
1052 | struct __is_nt_default_constructible_impl<_Tp, true> | |
1053 | : public __and_<__is_array_known_bounds<_Tp>, | |
1054 | __is_nt_default_constructible_atom<typename | |
f7632193 | 1055 | remove_all_extents<_Tp>::type>> |
65cee9bd PC |
1056 | { }; |
1057 | ||
1058 | template<typename _Tp> | |
1059 | struct __is_nt_default_constructible_impl<_Tp, false> | |
1060 | : public __is_nt_default_constructible_atom<_Tp> | |
1061 | { }; | |
1062 | ||
608a080c AP |
1063 | template<typename _Tp> |
1064 | using __is_nothrow_default_constructible_impl | |
1065 | = __and_<__is_constructible_impl<_Tp>, | |
1066 | __is_nt_default_constructible_impl<_Tp>>; | |
1067 | ||
65cee9bd PC |
1068 | /// is_nothrow_default_constructible |
1069 | template<typename _Tp> | |
1070 | struct is_nothrow_default_constructible | |
608a080c AP |
1071 | : public __is_nothrow_default_constructible_impl<_Tp>::type |
1072 | { | |
1073 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1074 | "template argument must be a complete class or an unbounded array"); | |
1075 | }; | |
e4f32cb0 PC |
1076 | |
1077 | template<typename _Tp, typename... _Args> | |
65cee9bd PC |
1078 | struct __is_nt_constructible_impl |
1079 | : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> | |
1080 | { }; | |
e4f32cb0 PC |
1081 | |
1082 | template<typename _Tp, typename _Arg> | |
65cee9bd PC |
1083 | struct __is_nt_constructible_impl<_Tp, _Arg> |
1084 | : public integral_constant<bool, | |
1085 | noexcept(static_cast<_Tp>(declval<_Arg>()))> | |
1086 | { }; | |
1087 | ||
1088 | template<typename _Tp> | |
1089 | struct __is_nt_constructible_impl<_Tp> | |
608a080c | 1090 | : public __is_nothrow_default_constructible_impl<_Tp> |
65cee9bd | 1091 | { }; |
e4f32cb0 | 1092 | |
e4f32cb0 | 1093 | template<typename _Tp, typename... _Args> |
608a080c AP |
1094 | struct __is_nothrow_constructible_impl |
1095 | : public __and_<__is_constructible_impl<_Tp, _Args...>, | |
f7632193 | 1096 | __is_nt_constructible_impl<_Tp, _Args...>> |
65cee9bd PC |
1097 | { }; |
1098 | ||
608a080c AP |
1099 | /// is_nothrow_constructible |
1100 | template<typename _Tp, typename... _Args> | |
1101 | struct is_nothrow_constructible | |
1102 | : public __is_nothrow_constructible_impl<_Tp, _Args...>::type | |
1103 | { | |
1104 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1105 | "template argument must be a complete class or an unbounded array"); | |
1106 | }; | |
1107 | ||
89898034 | 1108 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
65cee9bd PC |
1109 | struct __is_nothrow_copy_constructible_impl; |
1110 | ||
1111 | template<typename _Tp> | |
89898034 | 1112 | struct __is_nothrow_copy_constructible_impl<_Tp, false> |
65cee9bd PC |
1113 | : public false_type { }; |
1114 | ||
1115 | template<typename _Tp> | |
89898034 | 1116 | struct __is_nothrow_copy_constructible_impl<_Tp, true> |
608a080c | 1117 | : public __is_nothrow_constructible_impl<_Tp, const _Tp&> |
65cee9bd PC |
1118 | { }; |
1119 | ||
1120 | /// is_nothrow_copy_constructible | |
1121 | template<typename _Tp> | |
1122 | struct is_nothrow_copy_constructible | |
608a080c AP |
1123 | : public __is_nothrow_copy_constructible_impl<_Tp>::type |
1124 | { | |
1125 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1126 | "template argument must be a complete class or an unbounded array"); | |
1127 | }; | |
65cee9bd | 1128 | |
89898034 | 1129 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
65cee9bd PC |
1130 | struct __is_nothrow_move_constructible_impl; |
1131 | ||
1132 | template<typename _Tp> | |
89898034 | 1133 | struct __is_nothrow_move_constructible_impl<_Tp, false> |
65cee9bd PC |
1134 | : public false_type { }; |
1135 | ||
1136 | template<typename _Tp> | |
89898034 | 1137 | struct __is_nothrow_move_constructible_impl<_Tp, true> |
608a080c | 1138 | : public __is_nothrow_constructible_impl<_Tp, _Tp&&> |
65cee9bd PC |
1139 | { }; |
1140 | ||
1141 | /// is_nothrow_move_constructible | |
1142 | template<typename _Tp> | |
1143 | struct is_nothrow_move_constructible | |
608a080c AP |
1144 | : public __is_nothrow_move_constructible_impl<_Tp>::type |
1145 | { | |
1146 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1147 | "template argument must be a complete class or an unbounded array"); | |
1148 | }; | |
65cee9bd | 1149 | |
f263981a PC |
1150 | /// is_assignable |
1151 | template<typename _Tp, typename _Up> | |
1152 | struct is_assignable | |
608a080c AP |
1153 | : public __bool_constant<__is_assignable(_Tp, _Up)> |
1154 | { | |
1155 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1156 | "template argument must be a complete class or an unbounded array"); | |
1157 | }; | |
f263981a | 1158 | |
89898034 | 1159 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
f263981a PC |
1160 | struct __is_copy_assignable_impl; |
1161 | ||
1162 | template<typename _Tp> | |
89898034 | 1163 | struct __is_copy_assignable_impl<_Tp, false> |
f263981a PC |
1164 | : public false_type { }; |
1165 | ||
1166 | template<typename _Tp> | |
89898034 | 1167 | struct __is_copy_assignable_impl<_Tp, true> |
608a080c | 1168 | : public __bool_constant<__is_assignable(_Tp&, const _Tp&)> |
f263981a PC |
1169 | { }; |
1170 | ||
1171 | /// is_copy_assignable | |
1172 | template<typename _Tp> | |
1173 | struct is_copy_assignable | |
608a080c AP |
1174 | : public __is_copy_assignable_impl<_Tp>::type |
1175 | { | |
1176 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1177 | "template argument must be a complete class or an unbounded array"); | |
1178 | }; | |
f263981a | 1179 | |
89898034 | 1180 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
f263981a PC |
1181 | struct __is_move_assignable_impl; |
1182 | ||
1183 | template<typename _Tp> | |
89898034 | 1184 | struct __is_move_assignable_impl<_Tp, false> |
f263981a PC |
1185 | : public false_type { }; |
1186 | ||
1187 | template<typename _Tp> | |
89898034 | 1188 | struct __is_move_assignable_impl<_Tp, true> |
608a080c | 1189 | : public __bool_constant<__is_assignable(_Tp&, _Tp&&)> |
f263981a PC |
1190 | { }; |
1191 | ||
1192 | /// is_move_assignable | |
1193 | template<typename _Tp> | |
1194 | struct is_move_assignable | |
608a080c AP |
1195 | : public __is_move_assignable_impl<_Tp>::type |
1196 | { | |
1197 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1198 | "template argument must be a complete class or an unbounded array"); | |
1199 | }; | |
f263981a PC |
1200 | |
1201 | template<typename _Tp, typename _Up> | |
1202 | struct __is_nt_assignable_impl | |
1203 | : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())> | |
1204 | { }; | |
1205 | ||
f263981a | 1206 | template<typename _Tp, typename _Up> |
608a080c AP |
1207 | struct __is_nothrow_assignable_impl |
1208 | : public __and_<__bool_constant<__is_assignable(_Tp, _Up)>, | |
f7632193 | 1209 | __is_nt_assignable_impl<_Tp, _Up>> |
f263981a PC |
1210 | { }; |
1211 | ||
608a080c AP |
1212 | /// is_nothrow_assignable |
1213 | template<typename _Tp, typename _Up> | |
1214 | struct is_nothrow_assignable | |
1215 | : public __is_nothrow_assignable_impl<_Tp, _Up> | |
1216 | { | |
1217 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1218 | "template argument must be a complete class or an unbounded array"); | |
1219 | }; | |
1220 | ||
89898034 | 1221 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
f263981a PC |
1222 | struct __is_nt_copy_assignable_impl; |
1223 | ||
1224 | template<typename _Tp> | |
89898034 | 1225 | struct __is_nt_copy_assignable_impl<_Tp, false> |
f263981a PC |
1226 | : public false_type { }; |
1227 | ||
1228 | template<typename _Tp> | |
89898034 | 1229 | struct __is_nt_copy_assignable_impl<_Tp, true> |
608a080c | 1230 | : public __is_nothrow_assignable_impl<_Tp&, const _Tp&> |
f263981a PC |
1231 | { }; |
1232 | ||
1233 | /// is_nothrow_copy_assignable | |
1234 | template<typename _Tp> | |
1235 | struct is_nothrow_copy_assignable | |
1236 | : public __is_nt_copy_assignable_impl<_Tp> | |
608a080c AP |
1237 | { |
1238 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1239 | "template argument must be a complete class or an unbounded array"); | |
1240 | }; | |
f263981a | 1241 | |
89898034 | 1242 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
f263981a PC |
1243 | struct __is_nt_move_assignable_impl; |
1244 | ||
1245 | template<typename _Tp> | |
89898034 | 1246 | struct __is_nt_move_assignable_impl<_Tp, false> |
f263981a PC |
1247 | : public false_type { }; |
1248 | ||
1249 | template<typename _Tp> | |
89898034 | 1250 | struct __is_nt_move_assignable_impl<_Tp, true> |
608a080c | 1251 | : public __is_nothrow_assignable_impl<_Tp&, _Tp&&> |
f263981a PC |
1252 | { }; |
1253 | ||
1254 | /// is_nothrow_move_assignable | |
65cee9bd | 1255 | template<typename _Tp> |
f263981a PC |
1256 | struct is_nothrow_move_assignable |
1257 | : public __is_nt_move_assignable_impl<_Tp> | |
608a080c AP |
1258 | { |
1259 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1260 | "template argument must be a complete class or an unbounded array"); | |
1261 | }; | |
e4f32cb0 | 1262 | |
f5e523b7 VV |
1263 | /// is_trivially_constructible |
1264 | template<typename _Tp, typename... _Args> | |
1265 | struct is_trivially_constructible | |
c01f9216 | 1266 | : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)> |
608a080c AP |
1267 | { |
1268 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1269 | "template argument must be a complete class or an unbounded array"); | |
1270 | }; | |
33ac58d5 | 1271 | |
f5e523b7 VV |
1272 | /// is_trivially_default_constructible |
1273 | template<typename _Tp> | |
1274 | struct is_trivially_default_constructible | |
608a080c AP |
1275 | : public __bool_constant<__is_trivially_constructible(_Tp)> |
1276 | { | |
1277 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1278 | "template argument must be a complete class or an unbounded array"); | |
1279 | }; | |
6a9ecd34 | 1280 | |
f7632193 VV |
1281 | struct __do_is_implicitly_default_constructible_impl |
1282 | { | |
1283 | template <typename _Tp> | |
1284 | static void __helper(const _Tp&); | |
1285 | ||
1286 | template <typename _Tp> | |
1287 | static true_type __test(const _Tp&, | |
1288 | decltype(__helper<const _Tp&>({}))* = 0); | |
1289 | ||
1290 | static false_type __test(...); | |
1291 | }; | |
1292 | ||
1293 | template<typename _Tp> | |
1294 | struct __is_implicitly_default_constructible_impl | |
e9029d55 JW |
1295 | : public __do_is_implicitly_default_constructible_impl |
1296 | { | |
1297 | typedef decltype(__test(declval<_Tp>())) type; | |
1298 | }; | |
f7632193 VV |
1299 | |
1300 | template<typename _Tp> | |
1301 | struct __is_implicitly_default_constructible_safe | |
e9029d55 JW |
1302 | : public __is_implicitly_default_constructible_impl<_Tp>::type |
1303 | { }; | |
f7632193 VV |
1304 | |
1305 | template <typename _Tp> | |
1306 | struct __is_implicitly_default_constructible | |
608a080c | 1307 | : public __and_<__is_constructible_impl<_Tp>, |
e9029d55 JW |
1308 | __is_implicitly_default_constructible_safe<_Tp>> |
1309 | { }; | |
f7632193 | 1310 | |
b42cc3ca VV |
1311 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
1312 | struct __is_trivially_copy_constructible_impl; | |
1313 | ||
f5e523b7 | 1314 | template<typename _Tp> |
b42cc3ca VV |
1315 | struct __is_trivially_copy_constructible_impl<_Tp, false> |
1316 | : public false_type { }; | |
1317 | ||
1318 | template<typename _Tp> | |
1319 | struct __is_trivially_copy_constructible_impl<_Tp, true> | |
608a080c | 1320 | : public __and_<__is_copy_constructible_impl<_Tp>, |
f5e523b7 | 1321 | integral_constant<bool, |
f7632193 | 1322 | __is_trivially_constructible(_Tp, const _Tp&)>> |
f5e523b7 | 1323 | { }; |
33ac58d5 | 1324 | |
608a080c | 1325 | /// is_trivially_copy_constructible |
b42cc3ca VV |
1326 | template<typename _Tp> |
1327 | struct is_trivially_copy_constructible | |
1328 | : public __is_trivially_copy_constructible_impl<_Tp> | |
608a080c AP |
1329 | { |
1330 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1331 | "template argument must be a complete class or an unbounded array"); | |
1332 | }; | |
b42cc3ca VV |
1333 | |
1334 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> | |
1335 | struct __is_trivially_move_constructible_impl; | |
1336 | ||
f5e523b7 | 1337 | template<typename _Tp> |
b42cc3ca VV |
1338 | struct __is_trivially_move_constructible_impl<_Tp, false> |
1339 | : public false_type { }; | |
1340 | ||
1341 | template<typename _Tp> | |
1342 | struct __is_trivially_move_constructible_impl<_Tp, true> | |
608a080c | 1343 | : public __and_<__is_move_constructible_impl<_Tp>, |
f5e523b7 | 1344 | integral_constant<bool, |
f7632193 | 1345 | __is_trivially_constructible(_Tp, _Tp&&)>> |
f5e523b7 | 1346 | { }; |
6a9ecd34 | 1347 | |
608a080c | 1348 | /// is_trivially_move_constructible |
b42cc3ca VV |
1349 | template<typename _Tp> |
1350 | struct is_trivially_move_constructible | |
1351 | : public __is_trivially_move_constructible_impl<_Tp> | |
608a080c AP |
1352 | { |
1353 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1354 | "template argument must be a complete class or an unbounded array"); | |
1355 | }; | |
b42cc3ca | 1356 | |
f5e523b7 VV |
1357 | /// is_trivially_assignable |
1358 | template<typename _Tp, typename _Up> | |
1359 | struct is_trivially_assignable | |
b42cc3ca | 1360 | : public __bool_constant<__is_trivially_assignable(_Tp, _Up)> |
608a080c AP |
1361 | { |
1362 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1363 | "template argument must be a complete class or an unbounded array"); | |
1364 | }; | |
b42cc3ca VV |
1365 | |
1366 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> | |
1367 | struct __is_trivially_copy_assignable_impl; | |
1368 | ||
f5e523b7 | 1369 | template<typename _Tp> |
b42cc3ca VV |
1370 | struct __is_trivially_copy_assignable_impl<_Tp, false> |
1371 | : public false_type { }; | |
1372 | ||
1373 | template<typename _Tp> | |
1374 | struct __is_trivially_copy_assignable_impl<_Tp, true> | |
c01f9216 | 1375 | : public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)> |
f5e523b7 | 1376 | { }; |
6a9ecd34 | 1377 | |
608a080c | 1378 | /// is_trivially_copy_assignable |
b42cc3ca VV |
1379 | template<typename _Tp> |
1380 | struct is_trivially_copy_assignable | |
1381 | : public __is_trivially_copy_assignable_impl<_Tp> | |
608a080c AP |
1382 | { |
1383 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1384 | "template argument must be a complete class or an unbounded array"); | |
1385 | }; | |
b42cc3ca VV |
1386 | |
1387 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> | |
1388 | struct __is_trivially_move_assignable_impl; | |
1389 | ||
f5e523b7 | 1390 | template<typename _Tp> |
b42cc3ca VV |
1391 | struct __is_trivially_move_assignable_impl<_Tp, false> |
1392 | : public false_type { }; | |
1393 | ||
1394 | template<typename _Tp> | |
1395 | struct __is_trivially_move_assignable_impl<_Tp, true> | |
c01f9216 | 1396 | : public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)> |
f5e523b7 | 1397 | { }; |
6a9ecd34 | 1398 | |
608a080c | 1399 | /// is_trivially_move_assignable |
b42cc3ca VV |
1400 | template<typename _Tp> |
1401 | struct is_trivially_move_assignable | |
1402 | : public __is_trivially_move_assignable_impl<_Tp> | |
608a080c AP |
1403 | { |
1404 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1405 | "template argument must be a complete class or an unbounded array"); | |
1406 | }; | |
b42cc3ca | 1407 | |
6a9ecd34 PC |
1408 | /// is_trivially_destructible |
1409 | template<typename _Tp> | |
1410 | struct is_trivially_destructible | |
608a080c | 1411 | : public __and_<__is_destructible_safe<_Tp>, |
c01f9216 | 1412 | __bool_constant<__has_trivial_destructor(_Tp)>> |
608a080c AP |
1413 | { |
1414 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1415 | "template argument must be a complete class or an unbounded array"); | |
1416 | }; | |
6a9ecd34 | 1417 | |
e133ace8 | 1418 | |
123c516a PC |
1419 | /// has_virtual_destructor |
1420 | template<typename _Tp> | |
1421 | struct has_virtual_destructor | |
1422 | : public integral_constant<bool, __has_virtual_destructor(_Tp)> | |
608a080c AP |
1423 | { |
1424 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1425 | "template argument must be a complete class or an unbounded array"); | |
1426 | }; | |
123c516a | 1427 | |
33ac58d5 | 1428 | |
123c516a PC |
1429 | // type property queries. |
1430 | ||
1431 | /// alignment_of | |
1432 | template<typename _Tp> | |
1433 | struct alignment_of | |
608a080c AP |
1434 | : public integral_constant<std::size_t, alignof(_Tp)> |
1435 | { | |
1436 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
1437 | "template argument must be a complete class or an unbounded array"); | |
1438 | }; | |
33ac58d5 | 1439 | |
123c516a PC |
1440 | /// rank |
1441 | template<typename> | |
1442 | struct rank | |
1443 | : public integral_constant<std::size_t, 0> { }; | |
33ac58d5 | 1444 | |
123c516a PC |
1445 | template<typename _Tp, std::size_t _Size> |
1446 | struct rank<_Tp[_Size]> | |
1447 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | |
1448 | ||
1449 | template<typename _Tp> | |
1450 | struct rank<_Tp[]> | |
1451 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | |
1452 | ||
1453 | /// extent | |
1454 | template<typename, unsigned _Uint> | |
1455 | struct extent | |
1456 | : public integral_constant<std::size_t, 0> { }; | |
33ac58d5 | 1457 | |
123c516a PC |
1458 | template<typename _Tp, unsigned _Uint, std::size_t _Size> |
1459 | struct extent<_Tp[_Size], _Uint> | |
1460 | : public integral_constant<std::size_t, | |
1461 | _Uint == 0 ? _Size : extent<_Tp, | |
1462 | _Uint - 1>::value> | |
1463 | { }; | |
1464 | ||
1465 | template<typename _Tp, unsigned _Uint> | |
1466 | struct extent<_Tp[], _Uint> | |
1467 | : public integral_constant<std::size_t, | |
1468 | _Uint == 0 ? 0 : extent<_Tp, | |
1469 | _Uint - 1>::value> | |
1470 | { }; | |
1471 | ||
1472 | ||
c0ffa2ba | 1473 | // Type relations. |
123c516a PC |
1474 | |
1475 | /// is_same | |
1476 | template<typename, typename> | |
1477 | struct is_same | |
1478 | : public false_type { }; | |
1479 | ||
1480 | template<typename _Tp> | |
1481 | struct is_same<_Tp, _Tp> | |
1482 | : public true_type { }; | |
b0302c68 | 1483 | |
939759fc | 1484 | /// is_base_of |
e133ace8 PC |
1485 | template<typename _Base, typename _Derived> |
1486 | struct is_base_of | |
1487 | : public integral_constant<bool, __is_base_of(_Base, _Derived)> | |
1488 | { }; | |
1489 | ||
297f34d7 | 1490 | template<typename _From, typename _To, |
123c516a PC |
1491 | bool = __or_<is_void<_From>, is_function<_To>, |
1492 | is_array<_To>>::value> | |
297f34d7 | 1493 | struct __is_convertible_helper |
8df27fcb JW |
1494 | { |
1495 | typedef typename is_void<_To>::type type; | |
8df27fcb | 1496 | }; |
297f34d7 | 1497 | |
cc28d234 JW |
1498 | #pragma GCC diagnostic push |
1499 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | |
e133ace8 | 1500 | template<typename _From, typename _To> |
b0302c68 | 1501 | class __is_convertible_helper<_From, _To, false> |
e133ace8 | 1502 | { |
8df27fcb JW |
1503 | template<typename _To1> |
1504 | static void __test_aux(_To1) noexcept; | |
8e7d962a | 1505 | |
82b12c4b FD |
1506 | template<typename _From1, typename _To1, |
1507 | typename = decltype(__test_aux<_To1>(std::declval<_From1>()))> | |
1508 | static true_type | |
8e7d962a PC |
1509 | __test(int); |
1510 | ||
1511 | template<typename, typename> | |
82b12c4b FD |
1512 | static false_type |
1513 | __test(...); | |
297f34d7 | 1514 | |
e133ace8 | 1515 | public: |
82b12c4b | 1516 | typedef decltype(__test<_From, _To>(0)) type; |
e133ace8 | 1517 | }; |
cc28d234 | 1518 | #pragma GCC diagnostic pop |
82b12c4b | 1519 | |
b0302c68 | 1520 | /// is_convertible |
e133ace8 PC |
1521 | template<typename _From, typename _To> |
1522 | struct is_convertible | |
82b12c4b | 1523 | : public __is_convertible_helper<_From, _To>::type |
e133ace8 PC |
1524 | { }; |
1525 | ||
608a080c | 1526 | template<typename _From, typename _To, |
ed99e818 JW |
1527 | bool = __or_<is_void<_From>, is_function<_To>, |
1528 | is_array<_To>>::value> | |
1529 | struct __is_nt_convertible_helper | |
1530 | : is_void<_To> | |
1531 | { }; | |
1532 | ||
cc28d234 JW |
1533 | #pragma GCC diagnostic push |
1534 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | |
ed99e818 JW |
1535 | template<typename _From, typename _To> |
1536 | class __is_nt_convertible_helper<_From, _To, false> | |
1537 | { | |
1538 | template<typename _To1> | |
1539 | static void __test_aux(_To1) noexcept; | |
1540 | ||
1541 | template<typename _From1, typename _To1> | |
ce9f305e JW |
1542 | static |
1543 | __bool_constant<noexcept(__test_aux<_To1>(std::declval<_From1>()))> | |
ed99e818 JW |
1544 | __test(int); |
1545 | ||
1546 | template<typename, typename> | |
1547 | static false_type | |
1548 | __test(...); | |
1549 | ||
1550 | public: | |
1551 | using type = decltype(__test<_From, _To>(0)); | |
1552 | }; | |
cc28d234 | 1553 | #pragma GCC diagnostic pop |
ed99e818 | 1554 | |
ce9f305e JW |
1555 | // is_nothrow_convertible for C++11 |
1556 | template<typename _From, typename _To> | |
1557 | struct __is_nothrow_convertible | |
1558 | : public __is_nt_convertible_helper<_From, _To>::type | |
1559 | { }; | |
1560 | ||
1561 | #if __cplusplus > 201703L | |
8df27fcb JW |
1562 | /// is_nothrow_convertible |
1563 | template<typename _From, typename _To> | |
1564 | struct is_nothrow_convertible | |
ed99e818 | 1565 | : public __is_nt_convertible_helper<_From, _To>::type |
8df27fcb JW |
1566 | { }; |
1567 | ||
1568 | /// is_nothrow_convertible_v | |
1569 | template<typename _From, typename _To> | |
1570 | inline constexpr bool is_nothrow_convertible_v | |
1571 | = is_nothrow_convertible<_From, _To>::value; | |
1572 | #endif // C++2a | |
fd735b6a | 1573 | |
c0ffa2ba | 1574 | // Const-volatile modifications. |
7b50cdef | 1575 | |
123c516a | 1576 | /// remove_const |
7b50cdef | 1577 | template<typename _Tp> |
123c516a PC |
1578 | struct remove_const |
1579 | { typedef _Tp type; }; | |
7b50cdef | 1580 | |
123c516a PC |
1581 | template<typename _Tp> |
1582 | struct remove_const<_Tp const> | |
1583 | { typedef _Tp type; }; | |
33ac58d5 | 1584 | |
123c516a PC |
1585 | /// remove_volatile |
1586 | template<typename _Tp> | |
1587 | struct remove_volatile | |
1588 | { typedef _Tp type; }; | |
7b50cdef | 1589 | |
123c516a PC |
1590 | template<typename _Tp> |
1591 | struct remove_volatile<_Tp volatile> | |
1592 | { typedef _Tp type; }; | |
33ac58d5 | 1593 | |
123c516a PC |
1594 | /// remove_cv |
1595 | template<typename _Tp> | |
1596 | struct remove_cv | |
1597 | { | |
1598 | typedef typename | |
1599 | remove_const<typename remove_volatile<_Tp>::type>::type type; | |
1600 | }; | |
33ac58d5 | 1601 | |
123c516a PC |
1602 | /// add_const |
1603 | template<typename _Tp> | |
1604 | struct add_const | |
1605 | { typedef _Tp const type; }; | |
33ac58d5 | 1606 | |
123c516a PC |
1607 | /// add_volatile |
1608 | template<typename _Tp> | |
1609 | struct add_volatile | |
1610 | { typedef _Tp volatile type; }; | |
33ac58d5 | 1611 | |
123c516a PC |
1612 | /// add_cv |
1613 | template<typename _Tp> | |
1614 | struct add_cv | |
1615 | { | |
1616 | typedef typename | |
1617 | add_const<typename add_volatile<_Tp>::type>::type type; | |
1618 | }; | |
7b50cdef | 1619 | |
4457e88c | 1620 | #if __cplusplus > 201103L |
a15f7cb8 ESR |
1621 | |
1622 | #define __cpp_lib_transformation_trait_aliases 201304 | |
1623 | ||
4457e88c JW |
1624 | /// Alias template for remove_const |
1625 | template<typename _Tp> | |
1626 | using remove_const_t = typename remove_const<_Tp>::type; | |
1627 | ||
1628 | /// Alias template for remove_volatile | |
1629 | template<typename _Tp> | |
1630 | using remove_volatile_t = typename remove_volatile<_Tp>::type; | |
1631 | ||
1632 | /// Alias template for remove_cv | |
1633 | template<typename _Tp> | |
1634 | using remove_cv_t = typename remove_cv<_Tp>::type; | |
1635 | ||
1636 | /// Alias template for add_const | |
1637 | template<typename _Tp> | |
1638 | using add_const_t = typename add_const<_Tp>::type; | |
1639 | ||
1640 | /// Alias template for add_volatile | |
1641 | template<typename _Tp> | |
1642 | using add_volatile_t = typename add_volatile<_Tp>::type; | |
1643 | ||
1644 | /// Alias template for add_cv | |
1645 | template<typename _Tp> | |
1646 | using add_cv_t = typename add_cv<_Tp>::type; | |
1647 | #endif | |
7b50cdef | 1648 | |
123c516a | 1649 | // Reference transformations. |
7b50cdef | 1650 | |
123c516a PC |
1651 | /// remove_reference |
1652 | template<typename _Tp> | |
1653 | struct remove_reference | |
1654 | { typedef _Tp type; }; | |
7b50cdef | 1655 | |
123c516a PC |
1656 | template<typename _Tp> |
1657 | struct remove_reference<_Tp&> | |
1658 | { typedef _Tp type; }; | |
7b50cdef | 1659 | |
123c516a PC |
1660 | template<typename _Tp> |
1661 | struct remove_reference<_Tp&&> | |
1662 | { typedef _Tp type; }; | |
1663 | ||
89898034 | 1664 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
123c516a PC |
1665 | struct __add_lvalue_reference_helper |
1666 | { typedef _Tp type; }; | |
7b50cdef | 1667 | |
5e108459 | 1668 | template<typename _Tp> |
89898034 | 1669 | struct __add_lvalue_reference_helper<_Tp, true> |
123c516a | 1670 | { typedef _Tp& type; }; |
5e108459 | 1671 | |
123c516a | 1672 | /// add_lvalue_reference |
5e108459 | 1673 | template<typename _Tp> |
123c516a PC |
1674 | struct add_lvalue_reference |
1675 | : public __add_lvalue_reference_helper<_Tp> | |
1676 | { }; | |
1677 | ||
89898034 | 1678 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
123c516a PC |
1679 | struct __add_rvalue_reference_helper |
1680 | { typedef _Tp type; }; | |
5e108459 PC |
1681 | |
1682 | template<typename _Tp> | |
123c516a PC |
1683 | struct __add_rvalue_reference_helper<_Tp, true> |
1684 | { typedef _Tp&& type; }; | |
5e108459 | 1685 | |
123c516a | 1686 | /// add_rvalue_reference |
5e108459 | 1687 | template<typename _Tp> |
123c516a PC |
1688 | struct add_rvalue_reference |
1689 | : public __add_rvalue_reference_helper<_Tp> | |
1690 | { }; | |
5e108459 | 1691 | |
4457e88c JW |
1692 | #if __cplusplus > 201103L |
1693 | /// Alias template for remove_reference | |
1694 | template<typename _Tp> | |
1695 | using remove_reference_t = typename remove_reference<_Tp>::type; | |
1696 | ||
1697 | /// Alias template for add_lvalue_reference | |
1698 | template<typename _Tp> | |
1699 | using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; | |
1700 | ||
1701 | /// Alias template for add_rvalue_reference | |
1702 | template<typename _Tp> | |
1703 | using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; | |
1704 | #endif | |
7b50cdef | 1705 | |
c0ffa2ba | 1706 | // Sign modifications. |
123c516a | 1707 | |
7b50cdef BK |
1708 | // Utility for constructing identically cv-qualified types. |
1709 | template<typename _Unqualified, bool _IsConst, bool _IsVol> | |
1710 | struct __cv_selector; | |
1711 | ||
1712 | template<typename _Unqualified> | |
1713 | struct __cv_selector<_Unqualified, false, false> | |
1714 | { typedef _Unqualified __type; }; | |
1715 | ||
1716 | template<typename _Unqualified> | |
1717 | struct __cv_selector<_Unqualified, false, true> | |
1718 | { typedef volatile _Unqualified __type; }; | |
1719 | ||
1720 | template<typename _Unqualified> | |
1721 | struct __cv_selector<_Unqualified, true, false> | |
1722 | { typedef const _Unqualified __type; }; | |
1723 | ||
1724 | template<typename _Unqualified> | |
1725 | struct __cv_selector<_Unqualified, true, true> | |
1726 | { typedef const volatile _Unqualified __type; }; | |
1727 | ||
1728 | template<typename _Qualified, typename _Unqualified, | |
1729 | bool _IsConst = is_const<_Qualified>::value, | |
1730 | bool _IsVol = is_volatile<_Qualified>::value> | |
b0302c68 | 1731 | class __match_cv_qualifiers |
7b50cdef | 1732 | { |
7b50cdef BK |
1733 | typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; |
1734 | ||
1735 | public: | |
33ac58d5 | 1736 | typedef typename __match::__type __type; |
7b50cdef BK |
1737 | }; |
1738 | ||
7b50cdef BK |
1739 | // Utility for finding the unsigned versions of signed integral types. |
1740 | template<typename _Tp> | |
e133ace8 PC |
1741 | struct __make_unsigned |
1742 | { typedef _Tp __type; }; | |
7b50cdef BK |
1743 | |
1744 | template<> | |
1745 | struct __make_unsigned<char> | |
1746 | { typedef unsigned char __type; }; | |
1747 | ||
1748 | template<> | |
1749 | struct __make_unsigned<signed char> | |
1750 | { typedef unsigned char __type; }; | |
1751 | ||
7b50cdef BK |
1752 | template<> |
1753 | struct __make_unsigned<short> | |
1754 | { typedef unsigned short __type; }; | |
1755 | ||
1756 | template<> | |
1757 | struct __make_unsigned<int> | |
1758 | { typedef unsigned int __type; }; | |
1759 | ||
1760 | template<> | |
1761 | struct __make_unsigned<long> | |
1762 | { typedef unsigned long __type; }; | |
1763 | ||
1764 | template<> | |
1765 | struct __make_unsigned<long long> | |
1766 | { typedef unsigned long long __type; }; | |
1767 | ||
78a7c317 DD |
1768 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
1769 | template<> | |
1770 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0> | |
1771 | { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; }; | |
1772 | #endif | |
1773 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
1774 | template<> | |
1775 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1> | |
1776 | { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; }; | |
1777 | #endif | |
1778 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
6d585f01 | 1779 | template<> |
78a7c317 DD |
1780 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2> |
1781 | { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; }; | |
1782 | #endif | |
1783 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
1784 | template<> | |
1785 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3> | |
1786 | { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; }; | |
6d585f01 PC |
1787 | #endif |
1788 | ||
7b50cdef | 1789 | // Select between integral and enum: not possible to be both. |
33ac58d5 | 1790 | template<typename _Tp, |
7b50cdef | 1791 | bool _IsInt = is_integral<_Tp>::value, |
7b50cdef | 1792 | bool _IsEnum = is_enum<_Tp>::value> |
b0302c68 PC |
1793 | class __make_unsigned_selector; |
1794 | ||
7b50cdef | 1795 | template<typename _Tp> |
b0302c68 | 1796 | class __make_unsigned_selector<_Tp, true, false> |
7b50cdef | 1797 | { |
22f1f4c7 JW |
1798 | using __unsigned_type |
1799 | = typename __make_unsigned<typename remove_cv<_Tp>::type>::__type; | |
7b50cdef BK |
1800 | |
1801 | public: | |
22f1f4c7 JW |
1802 | using __type |
1803 | = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; | |
7b50cdef BK |
1804 | }; |
1805 | ||
22f1f4c7 JW |
1806 | class __make_unsigned_selector_base |
1807 | { | |
1808 | protected: | |
1809 | template<typename...> struct _List { }; | |
1810 | ||
1811 | template<typename _Tp, typename... _Up> | |
1812 | struct _List<_Tp, _Up...> : _List<_Up...> | |
1813 | { static constexpr size_t __size = sizeof(_Tp); }; | |
1814 | ||
1815 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | |
1816 | struct __select; | |
1817 | ||
1818 | template<size_t _Sz, typename _Uint, typename... _UInts> | |
1819 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | |
1820 | { using __type = _Uint; }; | |
1821 | ||
1822 | template<size_t _Sz, typename _Uint, typename... _UInts> | |
1823 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | |
1824 | : __select<_Sz, _List<_UInts...>> | |
1825 | { }; | |
1826 | }; | |
1827 | ||
1828 | // Choose unsigned integer type with the smallest rank and same size as _Tp | |
7b50cdef | 1829 | template<typename _Tp> |
b0302c68 | 1830 | class __make_unsigned_selector<_Tp, false, true> |
22f1f4c7 | 1831 | : __make_unsigned_selector_base |
7b50cdef | 1832 | { |
a0230468 | 1833 | // With -fshort-enums, an enum may be as small as a char. |
22f1f4c7 JW |
1834 | using _UInts = _List<unsigned char, unsigned short, unsigned int, |
1835 | unsigned long, unsigned long long>; | |
1836 | ||
1837 | using __unsigned_type = typename __select<sizeof(_Tp), _UInts>::__type; | |
73d81d3a | 1838 | |
7b50cdef | 1839 | public: |
22f1f4c7 JW |
1840 | using __type |
1841 | = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; | |
1842 | }; | |
1843 | ||
c124af93 TH |
1844 | // wchar_t, char8_t, char16_t and char32_t are integral types but are |
1845 | // neither signed integer types nor unsigned integer types, so must be | |
22f1f4c7 JW |
1846 | // transformed to the unsigned integer type with the smallest rank. |
1847 | // Use the partial specialization for enumeration types to do that. | |
1848 | #if defined(_GLIBCXX_USE_WCHAR_T) | |
1849 | template<> | |
1850 | struct __make_unsigned<wchar_t> | |
1851 | { | |
1852 | using __type | |
1853 | = typename __make_unsigned_selector<wchar_t, false, true>::__type; | |
1854 | }; | |
1855 | #endif | |
1856 | ||
c124af93 TH |
1857 | #ifdef _GLIBCXX_USE_CHAR8_T |
1858 | template<> | |
1859 | struct __make_unsigned<char8_t> | |
1860 | { | |
1861 | using __type | |
1862 | = typename __make_unsigned_selector<char8_t, false, true>::__type; | |
1863 | }; | |
1864 | #endif | |
1865 | ||
22f1f4c7 JW |
1866 | template<> |
1867 | struct __make_unsigned<char16_t> | |
1868 | { | |
1869 | using __type | |
1870 | = typename __make_unsigned_selector<char16_t, false, true>::__type; | |
1871 | }; | |
1872 | ||
1873 | template<> | |
1874 | struct __make_unsigned<char32_t> | |
1875 | { | |
1876 | using __type | |
1877 | = typename __make_unsigned_selector<char32_t, false, true>::__type; | |
7b50cdef BK |
1878 | }; |
1879 | ||
7b50cdef BK |
1880 | // Given an integral/enum type, return the corresponding unsigned |
1881 | // integer type. | |
5b9daa7e BK |
1882 | // Primary template. |
1883 | /// make_unsigned | |
7b50cdef | 1884 | template<typename _Tp> |
33ac58d5 | 1885 | struct make_unsigned |
7b50cdef BK |
1886 | { typedef typename __make_unsigned_selector<_Tp>::__type type; }; |
1887 | ||
1888 | // Integral, but don't define. | |
1889 | template<> | |
1890 | struct make_unsigned<bool>; | |
1891 | ||
1892 | ||
1893 | // Utility for finding the signed versions of unsigned integral types. | |
1894 | template<typename _Tp> | |
e133ace8 PC |
1895 | struct __make_signed |
1896 | { typedef _Tp __type; }; | |
7b50cdef BK |
1897 | |
1898 | template<> | |
1899 | struct __make_signed<char> | |
1900 | { typedef signed char __type; }; | |
1901 | ||
1902 | template<> | |
1903 | struct __make_signed<unsigned char> | |
1904 | { typedef signed char __type; }; | |
1905 | ||
7b50cdef BK |
1906 | template<> |
1907 | struct __make_signed<unsigned short> | |
1908 | { typedef signed short __type; }; | |
1909 | ||
1910 | template<> | |
1911 | struct __make_signed<unsigned int> | |
1912 | { typedef signed int __type; }; | |
1913 | ||
1914 | template<> | |
1915 | struct __make_signed<unsigned long> | |
1916 | { typedef signed long __type; }; | |
1917 | ||
1918 | template<> | |
1919 | struct __make_signed<unsigned long long> | |
1920 | { typedef signed long long __type; }; | |
1921 | ||
78a7c317 DD |
1922 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
1923 | template<> | |
1924 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0> | |
1925 | { typedef __GLIBCXX_TYPE_INT_N_0 __type; }; | |
1926 | #endif | |
1927 | #if defined(__GLIBCXX_TYPE_INT_N_1) | |
1928 | template<> | |
1929 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1> | |
1930 | { typedef __GLIBCXX_TYPE_INT_N_1 __type; }; | |
1931 | #endif | |
1932 | #if defined(__GLIBCXX_TYPE_INT_N_2) | |
1933 | template<> | |
1934 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2> | |
1935 | { typedef __GLIBCXX_TYPE_INT_N_2 __type; }; | |
1936 | #endif | |
1937 | #if defined(__GLIBCXX_TYPE_INT_N_3) | |
6d585f01 | 1938 | template<> |
78a7c317 DD |
1939 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3> |
1940 | { typedef __GLIBCXX_TYPE_INT_N_3 __type; }; | |
6d585f01 PC |
1941 | #endif |
1942 | ||
fb8ffd10 | 1943 | // Select between integral and enum: not possible to be both. |
33ac58d5 | 1944 | template<typename _Tp, |
7b50cdef | 1945 | bool _IsInt = is_integral<_Tp>::value, |
7b50cdef | 1946 | bool _IsEnum = is_enum<_Tp>::value> |
b0302c68 PC |
1947 | class __make_signed_selector; |
1948 | ||
7b50cdef | 1949 | template<typename _Tp> |
b0302c68 | 1950 | class __make_signed_selector<_Tp, true, false> |
7b50cdef | 1951 | { |
22f1f4c7 JW |
1952 | using __signed_type |
1953 | = typename __make_signed<typename remove_cv<_Tp>::type>::__type; | |
7b50cdef BK |
1954 | |
1955 | public: | |
22f1f4c7 JW |
1956 | using __type |
1957 | = typename __match_cv_qualifiers<_Tp, __signed_type>::__type; | |
7b50cdef BK |
1958 | }; |
1959 | ||
22f1f4c7 | 1960 | // Choose signed integer type with the smallest rank and same size as _Tp |
7b50cdef | 1961 | template<typename _Tp> |
b0302c68 | 1962 | class __make_signed_selector<_Tp, false, true> |
7b50cdef | 1963 | { |
73d81d3a | 1964 | typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type; |
7b50cdef BK |
1965 | |
1966 | public: | |
73d81d3a | 1967 | typedef typename __make_signed_selector<__unsigned_type>::__type __type; |
7b50cdef BK |
1968 | }; |
1969 | ||
22f1f4c7 | 1970 | // wchar_t, char16_t and char32_t are integral types but are neither |
d4b695e4 | 1971 | // signed integer types nor unsigned integer types, so must be |
22f1f4c7 JW |
1972 | // transformed to the signed integer type with the smallest rank. |
1973 | // Use the partial specialization for enumeration types to do that. | |
1974 | #if defined(_GLIBCXX_USE_WCHAR_T) | |
1975 | template<> | |
1976 | struct __make_signed<wchar_t> | |
1977 | { | |
1978 | using __type | |
1979 | = typename __make_signed_selector<wchar_t, false, true>::__type; | |
1980 | }; | |
1981 | #endif | |
1982 | ||
c124af93 TH |
1983 | #if defined(_GLIBCXX_USE_CHAR8_T) |
1984 | template<> | |
1985 | struct __make_signed<char8_t> | |
1986 | { | |
1987 | using __type | |
1988 | = typename __make_signed_selector<char8_t, false, true>::__type; | |
1989 | }; | |
1990 | #endif | |
1991 | ||
22f1f4c7 JW |
1992 | template<> |
1993 | struct __make_signed<char16_t> | |
1994 | { | |
1995 | using __type | |
1996 | = typename __make_signed_selector<char16_t, false, true>::__type; | |
1997 | }; | |
1998 | ||
1999 | template<> | |
2000 | struct __make_signed<char32_t> | |
2001 | { | |
2002 | using __type | |
2003 | = typename __make_signed_selector<char32_t, false, true>::__type; | |
2004 | }; | |
2005 | ||
7b50cdef BK |
2006 | // Given an integral/enum type, return the corresponding signed |
2007 | // integer type. | |
5b9daa7e BK |
2008 | // Primary template. |
2009 | /// make_signed | |
7b50cdef | 2010 | template<typename _Tp> |
33ac58d5 | 2011 | struct make_signed |
7b50cdef BK |
2012 | { typedef typename __make_signed_selector<_Tp>::__type type; }; |
2013 | ||
2014 | // Integral, but don't define. | |
2015 | template<> | |
2016 | struct make_signed<bool>; | |
cfa9a96b | 2017 | |
4457e88c JW |
2018 | #if __cplusplus > 201103L |
2019 | /// Alias template for make_signed | |
2020 | template<typename _Tp> | |
2021 | using make_signed_t = typename make_signed<_Tp>::type; | |
2022 | ||
2023 | /// Alias template for make_unsigned | |
2024 | template<typename _Tp> | |
2025 | using make_unsigned_t = typename make_unsigned<_Tp>::type; | |
2026 | #endif | |
123c516a | 2027 | |
c0ffa2ba | 2028 | // Array modifications. |
123c516a PC |
2029 | |
2030 | /// remove_extent | |
2031 | template<typename _Tp> | |
2032 | struct remove_extent | |
2033 | { typedef _Tp type; }; | |
2034 | ||
2035 | template<typename _Tp, std::size_t _Size> | |
2036 | struct remove_extent<_Tp[_Size]> | |
2037 | { typedef _Tp type; }; | |
2038 | ||
2039 | template<typename _Tp> | |
2040 | struct remove_extent<_Tp[]> | |
2041 | { typedef _Tp type; }; | |
2042 | ||
2043 | /// remove_all_extents | |
2044 | template<typename _Tp> | |
2045 | struct remove_all_extents | |
2046 | { typedef _Tp type; }; | |
2047 | ||
2048 | template<typename _Tp, std::size_t _Size> | |
2049 | struct remove_all_extents<_Tp[_Size]> | |
2050 | { typedef typename remove_all_extents<_Tp>::type type; }; | |
2051 | ||
2052 | template<typename _Tp> | |
2053 | struct remove_all_extents<_Tp[]> | |
2054 | { typedef typename remove_all_extents<_Tp>::type type; }; | |
2055 | ||
4457e88c JW |
2056 | #if __cplusplus > 201103L |
2057 | /// Alias template for remove_extent | |
2058 | template<typename _Tp> | |
2059 | using remove_extent_t = typename remove_extent<_Tp>::type; | |
2060 | ||
2061 | /// Alias template for remove_all_extents | |
2062 | template<typename _Tp> | |
2063 | using remove_all_extents_t = typename remove_all_extents<_Tp>::type; | |
2064 | #endif | |
123c516a | 2065 | |
c0ffa2ba | 2066 | // Pointer modifications. |
123c516a PC |
2067 | |
2068 | template<typename _Tp, typename> | |
2069 | struct __remove_pointer_helper | |
2070 | { typedef _Tp type; }; | |
2071 | ||
2072 | template<typename _Tp, typename _Up> | |
2073 | struct __remove_pointer_helper<_Tp, _Up*> | |
2074 | { typedef _Up type; }; | |
2075 | ||
2076 | /// remove_pointer | |
2077 | template<typename _Tp> | |
2078 | struct remove_pointer | |
2079 | : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type> | |
2080 | { }; | |
2081 | ||
2082 | /// add_pointer | |
89898034 DK |
2083 | template<typename _Tp, bool = __or_<__is_referenceable<_Tp>, |
2084 | is_void<_Tp>>::value> | |
2085 | struct __add_pointer_helper | |
2086 | { typedef _Tp type; }; | |
2087 | ||
123c516a | 2088 | template<typename _Tp> |
89898034 | 2089 | struct __add_pointer_helper<_Tp, true> |
123c516a PC |
2090 | { typedef typename remove_reference<_Tp>::type* type; }; |
2091 | ||
89898034 | 2092 | template<typename _Tp> |
33ac58d5 | 2093 | struct add_pointer |
89898034 DK |
2094 | : public __add_pointer_helper<_Tp> |
2095 | { }; | |
2096 | ||
4457e88c JW |
2097 | #if __cplusplus > 201103L |
2098 | /// Alias template for remove_pointer | |
2099 | template<typename _Tp> | |
2100 | using remove_pointer_t = typename remove_pointer<_Tp>::type; | |
2101 | ||
2102 | /// Alias template for add_pointer | |
2103 | template<typename _Tp> | |
2104 | using add_pointer_t = typename add_pointer<_Tp>::type; | |
2105 | #endif | |
123c516a PC |
2106 | |
2107 | template<std::size_t _Len> | |
2108 | struct __aligned_storage_msa | |
33ac58d5 | 2109 | { |
123c516a PC |
2110 | union __type |
2111 | { | |
2112 | unsigned char __data[_Len]; | |
33ac58d5 | 2113 | struct __attribute__((__aligned__)) { } __align; |
123c516a PC |
2114 | }; |
2115 | }; | |
2116 | ||
2117 | /** | |
2118 | * @brief Alignment type. | |
2119 | * | |
2120 | * The value of _Align is a default-alignment which shall be the | |
2121 | * most stringent alignment requirement for any C++ object type | |
2122 | * whose size is no greater than _Len (3.9). The member typedef | |
2123 | * type shall be a POD type suitable for use as uninitialized | |
2124 | * storage for any object whose size is at most _Len and whose | |
2125 | * alignment is a divisor of _Align. | |
2126 | */ | |
2127 | template<std::size_t _Len, std::size_t _Align = | |
2128 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | |
2129 | struct aligned_storage | |
33ac58d5 | 2130 | { |
123c516a PC |
2131 | union type |
2132 | { | |
2133 | unsigned char __data[_Len]; | |
33ac58d5 | 2134 | struct __attribute__((__aligned__((_Align)))) { } __align; |
123c516a PC |
2135 | }; |
2136 | }; | |
2137 | ||
d3718027 RS |
2138 | template <typename... _Types> |
2139 | struct __strictest_alignment | |
2140 | { | |
2141 | static const size_t _S_alignment = 0; | |
2142 | static const size_t _S_size = 0; | |
2143 | }; | |
2144 | ||
2145 | template <typename _Tp, typename... _Types> | |
2146 | struct __strictest_alignment<_Tp, _Types...> | |
2147 | { | |
2148 | static const size_t _S_alignment = | |
2149 | alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment | |
2150 | ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment; | |
2151 | static const size_t _S_size = | |
2152 | sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size | |
2153 | ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size; | |
2154 | }; | |
2155 | ||
2156 | /** | |
2157 | * @brief Provide aligned storage for types. | |
2158 | * | |
2159 | * [meta.trans.other] | |
2160 | * | |
2161 | * Provides aligned storage for any of the provided types of at | |
2162 | * least size _Len. | |
2163 | * | |
2164 | * @see aligned_storage | |
2165 | */ | |
2166 | template <size_t _Len, typename... _Types> | |
2167 | struct aligned_union | |
2168 | { | |
2169 | private: | |
2170 | static_assert(sizeof...(_Types) != 0, "At least one type is required"); | |
2171 | ||
2172 | using __strictest = __strictest_alignment<_Types...>; | |
2173 | static const size_t _S_len = _Len > __strictest::_S_size | |
2174 | ? _Len : __strictest::_S_size; | |
2175 | public: | |
2176 | /// The value of the strictest alignment of _Types. | |
2177 | static const size_t alignment_value = __strictest::_S_alignment; | |
2178 | /// The storage. | |
2179 | typedef typename aligned_storage<_S_len, alignment_value>::type type; | |
2180 | }; | |
2181 | ||
2182 | template <size_t _Len, typename... _Types> | |
2183 | const size_t aligned_union<_Len, _Types...>::alignment_value; | |
123c516a PC |
2184 | |
2185 | // Decay trait for arrays and functions, used for perfect forwarding | |
2186 | // in make_pair, make_tuple, etc. | |
33ac58d5 | 2187 | template<typename _Up, |
123c516a | 2188 | bool _IsArray = is_array<_Up>::value, |
33ac58d5 | 2189 | bool _IsFunction = is_function<_Up>::value> |
123c516a PC |
2190 | struct __decay_selector; |
2191 | ||
2192 | // NB: DR 705. | |
33ac58d5 | 2193 | template<typename _Up> |
123c516a PC |
2194 | struct __decay_selector<_Up, false, false> |
2195 | { typedef typename remove_cv<_Up>::type __type; }; | |
2196 | ||
33ac58d5 | 2197 | template<typename _Up> |
123c516a PC |
2198 | struct __decay_selector<_Up, true, false> |
2199 | { typedef typename remove_extent<_Up>::type* __type; }; | |
2200 | ||
33ac58d5 | 2201 | template<typename _Up> |
123c516a PC |
2202 | struct __decay_selector<_Up, false, true> |
2203 | { typedef typename add_pointer<_Up>::type __type; }; | |
2204 | ||
2205 | /// decay | |
33ac58d5 JW |
2206 | template<typename _Tp> |
2207 | class decay | |
2208 | { | |
123c516a PC |
2209 | typedef typename remove_reference<_Tp>::type __remove_type; |
2210 | ||
2211 | public: | |
2212 | typedef typename __decay_selector<__remove_type>::__type type; | |
2213 | }; | |
2214 | ||
2215 | template<typename _Tp> | |
2216 | class reference_wrapper; | |
2217 | ||
2218 | // Helper which adds a reference to a type when given a reference_wrapper | |
2219 | template<typename _Tp> | |
2220 | struct __strip_reference_wrapper | |
2221 | { | |
2222 | typedef _Tp __type; | |
2223 | }; | |
2224 | ||
2225 | template<typename _Tp> | |
2226 | struct __strip_reference_wrapper<reference_wrapper<_Tp> > | |
2227 | { | |
2228 | typedef _Tp& __type; | |
2229 | }; | |
2230 | ||
123c516a PC |
2231 | template<typename _Tp> |
2232 | struct __decay_and_strip | |
2233 | { | |
2234 | typedef typename __strip_reference_wrapper< | |
2235 | typename decay<_Tp>::type>::__type __type; | |
2236 | }; | |
2237 | ||
2238 | ||
123c516a | 2239 | // Primary template. |
13901e4b | 2240 | /// Define a member typedef @c type only if a boolean constant is true. |
123c516a | 2241 | template<bool, typename _Tp = void> |
33ac58d5 | 2242 | struct enable_if |
123c516a PC |
2243 | { }; |
2244 | ||
2245 | // Partial specialization for true. | |
2246 | template<typename _Tp> | |
2247 | struct enable_if<true, _Tp> | |
2248 | { typedef _Tp type; }; | |
2249 | ||
23df8534 JW |
2250 | template<typename... _Cond> |
2251 | using _Require = typename enable_if<__and_<_Cond...>::value>::type; | |
123c516a | 2252 | |
123c516a | 2253 | // Primary template. |
13901e4b | 2254 | /// Define a member typedef @c type to one of two argument types. |
123c516a PC |
2255 | template<bool _Cond, typename _Iftrue, typename _Iffalse> |
2256 | struct conditional | |
2257 | { typedef _Iftrue type; }; | |
2258 | ||
2259 | // Partial specialization for false. | |
2260 | template<typename _Iftrue, typename _Iffalse> | |
2261 | struct conditional<false, _Iftrue, _Iffalse> | |
2262 | { typedef _Iffalse type; }; | |
2263 | ||
f61a12b3 JW |
2264 | // __void_t (std::void_t for C++11) |
2265 | template<typename...> using __void_t = void; | |
2266 | ||
5b9daa7e | 2267 | /// common_type |
cfa9a96b CF |
2268 | template<typename... _Tp> |
2269 | struct common_type; | |
2270 | ||
c0ffa2ba | 2271 | // Sfinae-friendly common_type implementation: |
b3618b71 DK |
2272 | |
2273 | struct __do_common_type_impl | |
2274 | { | |
2275 | template<typename _Tp, typename _Up> | |
f61a12b3 JW |
2276 | using __cond_t |
2277 | = decltype(true ? std::declval<_Tp>() : std::declval<_Up>()); | |
2278 | ||
2279 | template<typename _Tp, typename _Up> | |
2280 | static __success_type<typename decay<__cond_t<_Tp, _Up>>::type> | |
2281 | _S_test(int); | |
b3618b71 DK |
2282 | |
2283 | template<typename, typename> | |
f61a12b3 JW |
2284 | static __failure_type |
2285 | _S_test(...); | |
b3618b71 DK |
2286 | }; |
2287 | ||
f61a12b3 JW |
2288 | // If sizeof...(T) is zero, there shall be no member type. |
2289 | template<> | |
2290 | struct common_type<> | |
2291 | { }; | |
b3618b71 | 2292 | |
f61a12b3 JW |
2293 | // If sizeof...(T) is one, the same type, if any, as common_type_t<T0, T0>. |
2294 | template<typename _Tp0> | |
2295 | struct common_type<_Tp0> | |
2296 | : public common_type<_Tp0, _Tp0> | |
2297 | { }; | |
b3618b71 | 2298 | |
f61a12b3 JW |
2299 | // If sizeof...(T) is two, ... |
2300 | template<typename _Tp1, typename _Tp2, | |
2301 | typename _Dp1 = typename decay<_Tp1>::type, | |
2302 | typename _Dp2 = typename decay<_Tp2>::type> | |
2303 | struct __common_type_impl | |
b3618b71 | 2304 | { |
f61a12b3 JW |
2305 | // If is_same_v<T1, D1> is false or is_same_v<T2, D2> is false, |
2306 | // let C denote the same type, if any, as common_type_t<D1, D2>. | |
2307 | using type = common_type<_Dp1, _Dp2>; | |
b3618b71 DK |
2308 | }; |
2309 | ||
f61a12b3 JW |
2310 | template<typename _Tp1, typename _Tp2> |
2311 | struct __common_type_impl<_Tp1, _Tp2, _Tp1, _Tp2> | |
2312 | : private __do_common_type_impl | |
b3618b71 | 2313 | { |
f61a12b3 JW |
2314 | // Otherwise, if decay_t<decltype(false ? declval<D1>() : declval<D2>())> |
2315 | // denotes a valid type, let C denote that type. | |
2316 | using type = decltype(_S_test<_Tp1, _Tp2>(0)); | |
b3618b71 DK |
2317 | }; |
2318 | ||
f61a12b3 JW |
2319 | // If sizeof...(T) is two, ... |
2320 | template<typename _Tp1, typename _Tp2> | |
2321 | struct common_type<_Tp1, _Tp2> | |
2322 | : public __common_type_impl<_Tp1, _Tp2>::type | |
2323 | { }; | |
b3618b71 | 2324 | |
f61a12b3 JW |
2325 | template<typename...> |
2326 | struct __common_type_pack | |
373c726e JW |
2327 | { }; |
2328 | ||
f61a12b3 JW |
2329 | template<typename, typename, typename = void> |
2330 | struct __common_type_fold; | |
2331 | ||
2332 | // If sizeof...(T) is greater than two, ... | |
2333 | template<typename _Tp1, typename _Tp2, typename... _Rp> | |
2334 | struct common_type<_Tp1, _Tp2, _Rp...> | |
2335 | : public __common_type_fold<common_type<_Tp1, _Tp2>, | |
2336 | __common_type_pack<_Rp...>> | |
373c726e | 2337 | { }; |
cfa9a96b | 2338 | |
f61a12b3 JW |
2339 | // Let C denote the same type, if any, as common_type_t<T1, T2>. |
2340 | // If there is such a type C, type shall denote the same type, if any, | |
2341 | // as common_type_t<C, R...>. | |
2342 | template<typename _CTp, typename... _Rp> | |
2343 | struct __common_type_fold<_CTp, __common_type_pack<_Rp...>, | |
2344 | __void_t<typename _CTp::type>> | |
2345 | : public common_type<typename _CTp::type, _Rp...> | |
b3618b71 | 2346 | { }; |
cfa9a96b | 2347 | |
f61a12b3 JW |
2348 | // Otherwise, there shall be no member type. |
2349 | template<typename _CTp, typename _Rp> | |
2350 | struct __common_type_fold<_CTp, _Rp, void> | |
b3618b71 | 2351 | { }; |
7274deff | 2352 | |
3c26b759 JW |
2353 | template<typename _Tp, bool = is_enum<_Tp>::value> |
2354 | struct __underlying_type_impl | |
2355 | { | |
2356 | using type = __underlying_type(_Tp); | |
2357 | }; | |
2358 | ||
2359 | template<typename _Tp> | |
2360 | struct __underlying_type_impl<_Tp, false> | |
2361 | { }; | |
2362 | ||
13901e4b | 2363 | /// The underlying type of an enum. |
a47407f6 PC |
2364 | template<typename _Tp> |
2365 | struct underlying_type | |
3c26b759 JW |
2366 | : public __underlying_type_impl<_Tp> |
2367 | { }; | |
123c516a | 2368 | |
7274deff PC |
2369 | template<typename _Tp> |
2370 | struct __declval_protector | |
2371 | { | |
2372 | static const bool __stop = false; | |
7274deff PC |
2373 | }; |
2374 | ||
2375 | template<typename _Tp> | |
ec26ff5a | 2376 | auto declval() noexcept -> decltype(__declval<_Tp>(0)) |
7274deff PC |
2377 | { |
2378 | static_assert(__declval_protector<_Tp>::__stop, | |
2379 | "declval() must not be used!"); | |
ec26ff5a | 2380 | return __declval<_Tp>(0); |
7274deff | 2381 | } |
1041daba | 2382 | |
6791489e JW |
2383 | // __remove_cvref_t (std::remove_cvref_t for C++11). |
2384 | template<typename _Tp> | |
2385 | using __remove_cvref_t | |
2386 | = typename remove_cv<typename remove_reference<_Tp>::type>::type; | |
2387 | ||
be7f7822 JW |
2388 | /// result_of |
2389 | template<typename _Signature> | |
2390 | class result_of; | |
2391 | ||
c0ffa2ba | 2392 | // Sfinae-friendly result_of implementation: |
83ddb39f | 2393 | |
a15f7cb8 ESR |
2394 | #define __cpp_lib_result_of_sfinae 201210 |
2395 | ||
93e95400 JW |
2396 | struct __invoke_memfun_ref { }; |
2397 | struct __invoke_memfun_deref { }; | |
2398 | struct __invoke_memobj_ref { }; | |
2399 | struct __invoke_memobj_deref { }; | |
2400 | struct __invoke_other { }; | |
2401 | ||
2402 | // Associate a tag type with a specialization of __success_type. | |
2403 | template<typename _Tp, typename _Tag> | |
2404 | struct __result_of_success : __success_type<_Tp> | |
2405 | { using __invoke_type = _Tag; }; | |
2406 | ||
83ddb39f DK |
2407 | // [func.require] paragraph 1 bullet 1: |
2408 | struct __result_of_memfun_ref_impl | |
2409 | { | |
2410 | template<typename _Fp, typename _Tp1, typename... _Args> | |
93e95400 | 2411 | static __result_of_success<decltype( |
83ddb39f | 2412 | (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...) |
93e95400 | 2413 | ), __invoke_memfun_ref> _S_test(int); |
83ddb39f DK |
2414 | |
2415 | template<typename...> | |
2416 | static __failure_type _S_test(...); | |
2417 | }; | |
2418 | ||
2419 | template<typename _MemPtr, typename _Arg, typename... _Args> | |
2420 | struct __result_of_memfun_ref | |
2421 | : private __result_of_memfun_ref_impl | |
2422 | { | |
2423 | typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; | |
2424 | }; | |
2425 | ||
2426 | // [func.require] paragraph 1 bullet 2: | |
2427 | struct __result_of_memfun_deref_impl | |
2428 | { | |
2429 | template<typename _Fp, typename _Tp1, typename... _Args> | |
93e95400 | 2430 | static __result_of_success<decltype( |
83ddb39f | 2431 | ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...) |
93e95400 | 2432 | ), __invoke_memfun_deref> _S_test(int); |
83ddb39f DK |
2433 | |
2434 | template<typename...> | |
2435 | static __failure_type _S_test(...); | |
2436 | }; | |
2437 | ||
2438 | template<typename _MemPtr, typename _Arg, typename... _Args> | |
2439 | struct __result_of_memfun_deref | |
2440 | : private __result_of_memfun_deref_impl | |
2441 | { | |
2442 | typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; | |
2443 | }; | |
2444 | ||
2445 | // [func.require] paragraph 1 bullet 3: | |
2446 | struct __result_of_memobj_ref_impl | |
2447 | { | |
2448 | template<typename _Fp, typename _Tp1> | |
93e95400 | 2449 | static __result_of_success<decltype( |
83ddb39f | 2450 | std::declval<_Tp1>().*std::declval<_Fp>() |
93e95400 | 2451 | ), __invoke_memobj_ref> _S_test(int); |
83ddb39f DK |
2452 | |
2453 | template<typename, typename> | |
2454 | static __failure_type _S_test(...); | |
2455 | }; | |
2456 | ||
2457 | template<typename _MemPtr, typename _Arg> | |
2458 | struct __result_of_memobj_ref | |
2459 | : private __result_of_memobj_ref_impl | |
2460 | { | |
2461 | typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; | |
2462 | }; | |
2463 | ||
2464 | // [func.require] paragraph 1 bullet 4: | |
2465 | struct __result_of_memobj_deref_impl | |
2466 | { | |
2467 | template<typename _Fp, typename _Tp1> | |
93e95400 | 2468 | static __result_of_success<decltype( |
83ddb39f | 2469 | (*std::declval<_Tp1>()).*std::declval<_Fp>() |
93e95400 | 2470 | ), __invoke_memobj_deref> _S_test(int); |
83ddb39f DK |
2471 | |
2472 | template<typename, typename> | |
2473 | static __failure_type _S_test(...); | |
2474 | }; | |
2475 | ||
be7f7822 | 2476 | template<typename _MemPtr, typename _Arg> |
83ddb39f DK |
2477 | struct __result_of_memobj_deref |
2478 | : private __result_of_memobj_deref_impl | |
2479 | { | |
2480 | typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; | |
2481 | }; | |
2482 | ||
2483 | template<typename _MemPtr, typename _Arg> | |
2484 | struct __result_of_memobj; | |
be7f7822 JW |
2485 | |
2486 | template<typename _Res, typename _Class, typename _Arg> | |
83ddb39f | 2487 | struct __result_of_memobj<_Res _Class::*, _Arg> |
be7f7822 | 2488 | { |
6791489e | 2489 | typedef __remove_cvref_t<_Arg> _Argval; |
83ddb39f DK |
2490 | typedef _Res _Class::* _MemPtr; |
2491 | typedef typename conditional<__or_<is_same<_Argval, _Class>, | |
2492 | is_base_of<_Class, _Argval>>::value, | |
2493 | __result_of_memobj_ref<_MemPtr, _Arg>, | |
2494 | __result_of_memobj_deref<_MemPtr, _Arg> | |
2495 | >::type::type type; | |
be7f7822 JW |
2496 | }; |
2497 | ||
83ddb39f DK |
2498 | template<typename _MemPtr, typename _Arg, typename... _Args> |
2499 | struct __result_of_memfun; | |
be7f7822 JW |
2500 | |
2501 | template<typename _Res, typename _Class, typename _Arg, typename... _Args> | |
83ddb39f | 2502 | struct __result_of_memfun<_Res _Class::*, _Arg, _Args...> |
be7f7822 | 2503 | { |
81c7cf71 | 2504 | typedef typename remove_reference<_Arg>::type _Argval; |
83ddb39f | 2505 | typedef _Res _Class::* _MemPtr; |
81c7cf71 | 2506 | typedef typename conditional<is_base_of<_Class, _Argval>::value, |
83ddb39f DK |
2507 | __result_of_memfun_ref<_MemPtr, _Arg, _Args...>, |
2508 | __result_of_memfun_deref<_MemPtr, _Arg, _Args...> | |
2509 | >::type::type type; | |
be7f7822 JW |
2510 | }; |
2511 | ||
93e95400 JW |
2512 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
2513 | // 2219. INVOKE-ing a pointer to member with a reference_wrapper | |
2514 | // as the object expression | |
93e95400 | 2515 | |
7dcc645c | 2516 | // Used by result_of, invoke etc. to unwrap a reference_wrapper. |
81c7cf71 | 2517 | template<typename _Tp, typename _Up = __remove_cvref_t<_Tp>> |
7dcc645c JW |
2518 | struct __inv_unwrap |
2519 | { | |
2520 | using type = _Tp; | |
2521 | }; | |
f3d7dd52 | 2522 | |
7dcc645c JW |
2523 | template<typename _Tp, typename _Up> |
2524 | struct __inv_unwrap<_Tp, reference_wrapper<_Up>> | |
2525 | { | |
2526 | using type = _Up&; | |
2527 | }; | |
93e95400 | 2528 | |
be7f7822 | 2529 | template<bool, bool, typename _Functor, typename... _ArgTypes> |
83ddb39f | 2530 | struct __result_of_impl |
be7f7822 | 2531 | { |
83ddb39f | 2532 | typedef __failure_type type; |
be7f7822 JW |
2533 | }; |
2534 | ||
2535 | template<typename _MemPtr, typename _Arg> | |
83ddb39f | 2536 | struct __result_of_impl<true, false, _MemPtr, _Arg> |
7dcc645c JW |
2537 | : public __result_of_memobj<typename decay<_MemPtr>::type, |
2538 | typename __inv_unwrap<_Arg>::type> | |
c4db9a77 | 2539 | { }; |
be7f7822 | 2540 | |
83ddb39f DK |
2541 | template<typename _MemPtr, typename _Arg, typename... _Args> |
2542 | struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...> | |
7dcc645c JW |
2543 | : public __result_of_memfun<typename decay<_MemPtr>::type, |
2544 | typename __inv_unwrap<_Arg>::type, _Args...> | |
c4db9a77 | 2545 | { }; |
be7f7822 | 2546 | |
83ddb39f DK |
2547 | // [func.require] paragraph 1 bullet 5: |
2548 | struct __result_of_other_impl | |
2549 | { | |
2550 | template<typename _Fn, typename... _Args> | |
93e95400 | 2551 | static __result_of_success<decltype( |
83ddb39f | 2552 | std::declval<_Fn>()(std::declval<_Args>()...) |
93e95400 | 2553 | ), __invoke_other> _S_test(int); |
83ddb39f DK |
2554 | |
2555 | template<typename...> | |
2556 | static __failure_type _S_test(...); | |
2557 | }; | |
2558 | ||
be7f7822 | 2559 | template<typename _Functor, typename... _ArgTypes> |
83ddb39f DK |
2560 | struct __result_of_impl<false, false, _Functor, _ArgTypes...> |
2561 | : private __result_of_other_impl | |
be7f7822 | 2562 | { |
83ddb39f | 2563 | typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type; |
be7f7822 JW |
2564 | }; |
2565 | ||
7dcc645c | 2566 | // __invoke_result (std::invoke_result for C++11) |
83ddb39f | 2567 | template<typename _Functor, typename... _ArgTypes> |
7dcc645c | 2568 | struct __invoke_result |
83ddb39f DK |
2569 | : public __result_of_impl< |
2570 | is_member_object_pointer< | |
2571 | typename remove_reference<_Functor>::type | |
2572 | >::value, | |
2573 | is_member_function_pointer< | |
2574 | typename remove_reference<_Functor>::type | |
2575 | >::value, | |
7dcc645c | 2576 | _Functor, _ArgTypes... |
83ddb39f DK |
2577 | >::type |
2578 | { }; | |
c0ffa2ba | 2579 | |
7dcc645c JW |
2580 | template<typename _Functor, typename... _ArgTypes> |
2581 | struct result_of<_Functor(_ArgTypes...)> | |
2582 | : public __invoke_result<_Functor, _ArgTypes...> | |
2583 | { }; | |
2584 | ||
e112d53a | 2585 | #if __cplusplus >= 201402L |
4457e88c JW |
2586 | /// Alias template for aligned_storage |
2587 | template<size_t _Len, size_t _Align = | |
2588 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | |
2589 | using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; | |
2590 | ||
d3718027 RS |
2591 | template <size_t _Len, typename... _Types> |
2592 | using aligned_union_t = typename aligned_union<_Len, _Types...>::type; | |
2593 | ||
4457e88c JW |
2594 | /// Alias template for decay |
2595 | template<typename _Tp> | |
2596 | using decay_t = typename decay<_Tp>::type; | |
2597 | ||
2598 | /// Alias template for enable_if | |
2599 | template<bool _Cond, typename _Tp = void> | |
2600 | using enable_if_t = typename enable_if<_Cond, _Tp>::type; | |
2601 | ||
2602 | /// Alias template for conditional | |
2603 | template<bool _Cond, typename _Iftrue, typename _Iffalse> | |
2604 | using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type; | |
2605 | ||
2606 | /// Alias template for common_type | |
2607 | template<typename... _Tp> | |
2608 | using common_type_t = typename common_type<_Tp...>::type; | |
2609 | ||
2610 | /// Alias template for underlying_type | |
2611 | template<typename _Tp> | |
2612 | using underlying_type_t = typename underlying_type<_Tp>::type; | |
2613 | ||
2614 | /// Alias template for result_of | |
2615 | template<typename _Tp> | |
2616 | using result_of_t = typename result_of<_Tp>::type; | |
e112d53a JW |
2617 | #endif // C++14 |
2618 | ||
2619 | // __enable_if_t (std::enable_if_t for C++11) | |
2620 | template<bool _Cond, typename _Tp = void> | |
2621 | using __enable_if_t = typename enable_if<_Cond, _Tp>::type; | |
4457e88c | 2622 | |
e112d53a | 2623 | #if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++11 |
bd1eb5e0 JW |
2624 | #define __cpp_lib_void_t 201411 |
2625 | /// A metafunction that always yields void, used for detecting valid types. | |
2626 | template<typename...> using void_t = void; | |
2627 | #endif | |
2628 | ||
6af6bef4 JW |
2629 | /// Implementation of the detection idiom (negative case). |
2630 | template<typename _Default, typename _AlwaysVoid, | |
2631 | template<typename...> class _Op, typename... _Args> | |
2632 | struct __detector | |
2633 | { | |
2634 | using value_t = false_type; | |
2635 | using type = _Default; | |
2636 | }; | |
2637 | ||
2638 | /// Implementation of the detection idiom (positive case). | |
2639 | template<typename _Default, template<typename...> class _Op, | |
2640 | typename... _Args> | |
2641 | struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...> | |
2642 | { | |
2643 | using value_t = true_type; | |
2644 | using type = _Op<_Args...>; | |
2645 | }; | |
2646 | ||
2647 | // Detect whether _Op<_Args...> is a valid type, use _Default if not. | |
2648 | template<typename _Default, template<typename...> class _Op, | |
2649 | typename... _Args> | |
2650 | using __detected_or = __detector<_Default, void, _Op, _Args...>; | |
2651 | ||
2652 | // _Op<_Args...> if that is a valid type, otherwise _Default. | |
2653 | template<typename _Default, template<typename...> class _Op, | |
2654 | typename... _Args> | |
2655 | using __detected_or_t | |
2656 | = typename __detected_or<_Default, _Op, _Args...>::type; | |
2657 | ||
c0ffa2ba | 2658 | /// @} group metaprogramming |
847e9cf8 | 2659 | |
033b71ce PC |
2660 | /** |
2661 | * Use SFINAE to determine if the type _Tp has a publicly-accessible | |
2662 | * member type _NTYPE. | |
2663 | */ | |
82b12c4b | 2664 | #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \ |
847e9cf8 | 2665 | template<typename _Tp, typename = __void_t<>> \ |
82b12c4b | 2666 | struct __has_##_NTYPE \ |
847e9cf8 JW |
2667 | : false_type \ |
2668 | { }; \ | |
2669 | template<typename _Tp> \ | |
2670 | struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \ | |
2671 | : true_type \ | |
033b71ce PC |
2672 | { }; |
2673 | ||
26b5ace7 DK |
2674 | template <typename _Tp> |
2675 | struct __is_swappable; | |
ddb63209 | 2676 | |
26b5ace7 DK |
2677 | template <typename _Tp> |
2678 | struct __is_nothrow_swappable; | |
ddb63209 | 2679 | |
a2863bde VV |
2680 | template<typename... _Elements> |
2681 | class tuple; | |
2682 | ||
2683 | template<typename> | |
2684 | struct __is_tuple_like_impl : false_type | |
2685 | { }; | |
2686 | ||
2687 | template<typename... _Tps> | |
2688 | struct __is_tuple_like_impl<tuple<_Tps...>> : true_type | |
2689 | { }; | |
2690 | ||
2691 | // Internal type trait that allows us to sfinae-protect tuple_cat. | |
2692 | template<typename _Tp> | |
2693 | struct __is_tuple_like | |
6791489e | 2694 | : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type |
a2863bde VV |
2695 | { }; |
2696 | ||
ddb63209 | 2697 | template<typename _Tp> |
7a91c710 | 2698 | _GLIBCXX20_CONSTEXPR |
ddb63209 | 2699 | inline |
a2863bde VV |
2700 | typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>, |
2701 | is_move_constructible<_Tp>, | |
ddb63209 VV |
2702 | is_move_assignable<_Tp>>::value>::type |
2703 | swap(_Tp&, _Tp&) | |
2704 | noexcept(__and_<is_nothrow_move_constructible<_Tp>, | |
2705 | is_nothrow_move_assignable<_Tp>>::value); | |
2706 | ||
2707 | template<typename _Tp, size_t _Nm> | |
7a91c710 | 2708 | _GLIBCXX20_CONSTEXPR |
ddb63209 | 2709 | inline |
26b5ace7 | 2710 | typename enable_if<__is_swappable<_Tp>::value>::type |
ddb63209 | 2711 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) |
26b5ace7 | 2712 | noexcept(__is_nothrow_swappable<_Tp>::value); |
ddb63209 | 2713 | |
26b5ace7 | 2714 | namespace __swappable_details { |
ddb63209 VV |
2715 | using std::swap; |
2716 | ||
26b5ace7 DK |
2717 | struct __do_is_swappable_impl |
2718 | { | |
2719 | template<typename _Tp, typename | |
2720 | = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))> | |
2721 | static true_type __test(int); | |
2722 | ||
2723 | template<typename> | |
2724 | static false_type __test(...); | |
2725 | }; | |
2726 | ||
2727 | struct __do_is_nothrow_swappable_impl | |
2728 | { | |
2729 | template<typename _Tp> | |
2730 | static __bool_constant< | |
2731 | noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())) | |
2732 | > __test(int); | |
2733 | ||
2734 | template<typename> | |
2735 | static false_type __test(...); | |
2736 | }; | |
2737 | ||
6b9539e2 | 2738 | } // namespace __swappable_details |
ddb63209 | 2739 | |
26b5ace7 DK |
2740 | template<typename _Tp> |
2741 | struct __is_swappable_impl | |
2742 | : public __swappable_details::__do_is_swappable_impl | |
2743 | { | |
2744 | typedef decltype(__test<_Tp>(0)) type; | |
2745 | }; | |
2746 | ||
2747 | template<typename _Tp> | |
ddb63209 | 2748 | struct __is_nothrow_swappable_impl |
26b5ace7 DK |
2749 | : public __swappable_details::__do_is_nothrow_swappable_impl |
2750 | { | |
2751 | typedef decltype(__test<_Tp>(0)) type; | |
2752 | }; | |
ddb63209 | 2753 | |
26b5ace7 DK |
2754 | template<typename _Tp> |
2755 | struct __is_swappable | |
2756 | : public __is_swappable_impl<_Tp>::type | |
ddb63209 VV |
2757 | { }; |
2758 | ||
26b5ace7 | 2759 | template<typename _Tp> |
ddb63209 | 2760 | struct __is_nothrow_swappable |
26b5ace7 | 2761 | : public __is_nothrow_swappable_impl<_Tp>::type |
ddb63209 VV |
2762 | { }; |
2763 | ||
6b9539e2 DK |
2764 | #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 |
2765 | #define __cpp_lib_is_swappable 201603 | |
2766 | /// Metafunctions used for detecting swappable types: p0185r1 | |
2767 | ||
2768 | /// is_swappable | |
2769 | template<typename _Tp> | |
2770 | struct is_swappable | |
2771 | : public __is_swappable_impl<_Tp>::type | |
608a080c AP |
2772 | { |
2773 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
2774 | "template argument must be a complete class or an unbounded array"); | |
2775 | }; | |
6b9539e2 DK |
2776 | |
2777 | /// is_nothrow_swappable | |
2778 | template<typename _Tp> | |
2779 | struct is_nothrow_swappable | |
2780 | : public __is_nothrow_swappable_impl<_Tp>::type | |
608a080c AP |
2781 | { |
2782 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
2783 | "template argument must be a complete class or an unbounded array"); | |
2784 | }; | |
6b9539e2 DK |
2785 | |
2786 | #if __cplusplus >= 201402L | |
2787 | /// is_swappable_v | |
2788 | template<typename _Tp> | |
288695f7 DK |
2789 | _GLIBCXX17_INLINE constexpr bool is_swappable_v = |
2790 | is_swappable<_Tp>::value; | |
6b9539e2 DK |
2791 | |
2792 | /// is_nothrow_swappable_v | |
2793 | template<typename _Tp> | |
288695f7 DK |
2794 | _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v = |
2795 | is_nothrow_swappable<_Tp>::value; | |
6b9539e2 DK |
2796 | #endif // __cplusplus >= 201402L |
2797 | ||
2798 | namespace __swappable_with_details { | |
2799 | using std::swap; | |
2800 | ||
2801 | struct __do_is_swappable_with_impl | |
2802 | { | |
2803 | template<typename _Tp, typename _Up, typename | |
2804 | = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())), | |
2805 | typename | |
2806 | = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> | |
2807 | static true_type __test(int); | |
2808 | ||
2809 | template<typename, typename> | |
2810 | static false_type __test(...); | |
2811 | }; | |
2812 | ||
2813 | struct __do_is_nothrow_swappable_with_impl | |
2814 | { | |
2815 | template<typename _Tp, typename _Up> | |
2816 | static __bool_constant< | |
2817 | noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) | |
2818 | && | |
2819 | noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())) | |
2820 | > __test(int); | |
2821 | ||
2822 | template<typename, typename> | |
2823 | static false_type __test(...); | |
2824 | }; | |
2825 | ||
2826 | } // namespace __swappable_with_details | |
2827 | ||
2828 | template<typename _Tp, typename _Up> | |
2829 | struct __is_swappable_with_impl | |
2830 | : public __swappable_with_details::__do_is_swappable_with_impl | |
2831 | { | |
2832 | typedef decltype(__test<_Tp, _Up>(0)) type; | |
2833 | }; | |
2834 | ||
2835 | // Optimization for the homogenous lvalue case, not required: | |
2836 | template<typename _Tp> | |
2837 | struct __is_swappable_with_impl<_Tp&, _Tp&> | |
2838 | : public __swappable_details::__do_is_swappable_impl | |
2839 | { | |
2840 | typedef decltype(__test<_Tp&>(0)) type; | |
2841 | }; | |
2842 | ||
2843 | template<typename _Tp, typename _Up> | |
2844 | struct __is_nothrow_swappable_with_impl | |
2845 | : public __swappable_with_details::__do_is_nothrow_swappable_with_impl | |
2846 | { | |
2847 | typedef decltype(__test<_Tp, _Up>(0)) type; | |
2848 | }; | |
2849 | ||
2850 | // Optimization for the homogenous lvalue case, not required: | |
2851 | template<typename _Tp> | |
2852 | struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&> | |
2853 | : public __swappable_details::__do_is_nothrow_swappable_impl | |
2854 | { | |
2855 | typedef decltype(__test<_Tp&>(0)) type; | |
2856 | }; | |
2857 | ||
2858 | /// is_swappable_with | |
2859 | template<typename _Tp, typename _Up> | |
2860 | struct is_swappable_with | |
2861 | : public __is_swappable_with_impl<_Tp, _Up>::type | |
2862 | { }; | |
2863 | ||
2864 | /// is_nothrow_swappable_with | |
2865 | template<typename _Tp, typename _Up> | |
2866 | struct is_nothrow_swappable_with | |
2867 | : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type | |
2868 | { }; | |
2869 | ||
2870 | #if __cplusplus >= 201402L | |
2871 | /// is_swappable_with_v | |
2872 | template<typename _Tp, typename _Up> | |
288695f7 DK |
2873 | _GLIBCXX17_INLINE constexpr bool is_swappable_with_v = |
2874 | is_swappable_with<_Tp, _Up>::value; | |
6b9539e2 DK |
2875 | |
2876 | /// is_nothrow_swappable_with_v | |
2877 | template<typename _Tp, typename _Up> | |
288695f7 | 2878 | _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v = |
6b9539e2 DK |
2879 | is_nothrow_swappable_with<_Tp, _Up>::value; |
2880 | #endif // __cplusplus >= 201402L | |
137422c8 | 2881 | |
42183d03 JW |
2882 | #endif// c++1z or gnu++11 |
2883 | ||
7dcc645c | 2884 | // __is_invocable (std::is_invocable for C++11) |
42183d03 | 2885 | |
7dcc645c JW |
2886 | template<typename _Result, typename _Ret, typename = void> |
2887 | struct __is_invocable_impl : false_type { }; | |
42183d03 JW |
2888 | |
2889 | template<typename _Result, typename _Ret> | |
7dcc645c | 2890 | struct __is_invocable_impl<_Result, _Ret, __void_t<typename _Result::type>> |
91d01b33 | 2891 | : __or_<is_void<_Ret>, is_convertible<typename _Result::type, _Ret>>::type |
42183d03 JW |
2892 | { }; |
2893 | ||
7dcc645c JW |
2894 | template<typename _Fn, typename... _ArgTypes> |
2895 | struct __is_invocable | |
2896 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type | |
42183d03 JW |
2897 | { }; |
2898 | ||
42183d03 JW |
2899 | template<typename _Fn, typename _Tp, typename... _Args> |
2900 | constexpr bool __call_is_nt(__invoke_memfun_ref) | |
2901 | { | |
2902 | using _Up = typename __inv_unwrap<_Tp>::type; | |
2903 | return noexcept((std::declval<_Up>().*std::declval<_Fn>())( | |
2904 | std::declval<_Args>()...)); | |
2905 | } | |
2906 | ||
2907 | template<typename _Fn, typename _Tp, typename... _Args> | |
2908 | constexpr bool __call_is_nt(__invoke_memfun_deref) | |
2909 | { | |
2910 | return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())( | |
2911 | std::declval<_Args>()...)); | |
2912 | } | |
2913 | ||
2914 | template<typename _Fn, typename _Tp> | |
2915 | constexpr bool __call_is_nt(__invoke_memobj_ref) | |
2916 | { | |
2917 | using _Up = typename __inv_unwrap<_Tp>::type; | |
2918 | return noexcept(std::declval<_Up>().*std::declval<_Fn>()); | |
2919 | } | |
2920 | ||
2921 | template<typename _Fn, typename _Tp> | |
2922 | constexpr bool __call_is_nt(__invoke_memobj_deref) | |
2923 | { | |
2924 | return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>()); | |
2925 | } | |
2926 | ||
2927 | template<typename _Fn, typename... _Args> | |
2928 | constexpr bool __call_is_nt(__invoke_other) | |
2929 | { | |
2930 | return noexcept(std::declval<_Fn>()(std::declval<_Args>()...)); | |
2931 | } | |
2932 | ||
7dcc645c | 2933 | template<typename _Result, typename _Fn, typename... _Args> |
42183d03 JW |
2934 | struct __call_is_nothrow |
2935 | : __bool_constant< | |
7dcc645c JW |
2936 | std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{}) |
2937 | > | |
42183d03 JW |
2938 | { }; |
2939 | ||
7dcc645c JW |
2940 | template<typename _Fn, typename... _Args> |
2941 | using __call_is_nothrow_ | |
2942 | = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>; | |
42183d03 | 2943 | |
7dcc645c JW |
2944 | // __is_nothrow_invocable (std::is_nothrow_invocable for C++11) |
2945 | template<typename _Fn, typename... _Args> | |
2946 | struct __is_nothrow_invocable | |
2947 | : __and_<__is_invocable<_Fn, _Args...>, | |
2948 | __call_is_nothrow_<_Fn, _Args...>>::type | |
42183d03 JW |
2949 | { }; |
2950 | ||
cc28d234 JW |
2951 | #pragma GCC diagnostic push |
2952 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | |
a73d2fa8 NDR |
2953 | struct __nonesuchbase {}; |
2954 | struct __nonesuch : private __nonesuchbase { | |
f524d5b3 VV |
2955 | ~__nonesuch() = delete; |
2956 | __nonesuch(__nonesuch const&) = delete; | |
2957 | void operator=(__nonesuch const&) = delete; | |
2958 | }; | |
cc28d234 | 2959 | #pragma GCC diagnostic pop |
f524d5b3 | 2960 | |
e641ee43 | 2961 | #if __cplusplus >= 201703L |
7dcc645c JW |
2962 | # define __cpp_lib_is_invocable 201703 |
2963 | ||
2964 | /// std::invoke_result | |
2965 | template<typename _Functor, typename... _ArgTypes> | |
2966 | struct invoke_result | |
2967 | : public __invoke_result<_Functor, _ArgTypes...> | |
2968 | { }; | |
2969 | ||
2970 | /// std::invoke_result_t | |
2971 | template<typename _Fn, typename... _Args> | |
2972 | using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; | |
42183d03 | 2973 | |
7dcc645c JW |
2974 | /// std::is_invocable |
2975 | template<typename _Fn, typename... _ArgTypes> | |
2976 | struct is_invocable | |
2977 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type | |
608a080c AP |
2978 | { |
2979 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), | |
2980 | "_Fn must be a complete class or an unbounded array"); | |
2981 | }; | |
42183d03 | 2982 | |
7dcc645c JW |
2983 | /// std::is_invocable_r |
2984 | template<typename _Ret, typename _Fn, typename... _ArgTypes> | |
2985 | struct is_invocable_r | |
2986 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type | |
608a080c AP |
2987 | { |
2988 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), | |
2989 | "_Fn must be a complete class or an unbounded array"); | |
2990 | }; | |
42183d03 | 2991 | |
7dcc645c JW |
2992 | /// std::is_nothrow_invocable |
2993 | template<typename _Fn, typename... _ArgTypes> | |
2994 | struct is_nothrow_invocable | |
2995 | : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>, | |
608a080c AP |
2996 | __call_is_nothrow_<_Fn, _ArgTypes...>>::type |
2997 | { | |
2998 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), | |
2999 | "_Fn must be a complete class or an unbounded array"); | |
3000 | }; | |
42183d03 | 3001 | |
c4b06e7f JW |
3002 | template<typename _Result, typename _Ret, typename = void> |
3003 | struct __is_nt_invocable_impl : false_type { }; | |
3004 | ||
3005 | template<typename _Result, typename _Ret> | |
3006 | struct __is_nt_invocable_impl<_Result, _Ret, | |
3007 | __void_t<typename _Result::type>> | |
91d01b33 | 3008 | : __or_<is_void<_Ret>, |
ce9f305e | 3009 | __is_nothrow_convertible<typename _Result::type, _Ret>> |
c4b06e7f JW |
3010 | { }; |
3011 | ||
7dcc645c JW |
3012 | /// std::is_nothrow_invocable_r |
3013 | template<typename _Ret, typename _Fn, typename... _ArgTypes> | |
3014 | struct is_nothrow_invocable_r | |
c4b06e7f | 3015 | : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>, |
7dcc645c | 3016 | __call_is_nothrow_<_Fn, _ArgTypes...>>::type |
42183d03 JW |
3017 | { }; |
3018 | ||
7dcc645c JW |
3019 | /// std::is_invocable_v |
3020 | template<typename _Fn, typename... _Args> | |
3021 | inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; | |
42183d03 | 3022 | |
7dcc645c JW |
3023 | /// std::is_nothrow_invocable_v |
3024 | template<typename _Fn, typename... _Args> | |
3025 | inline constexpr bool is_nothrow_invocable_v | |
3026 | = is_nothrow_invocable<_Fn, _Args...>::value; | |
42183d03 | 3027 | |
7dcc645c | 3028 | /// std::is_invocable_r_v |
ce9f305e | 3029 | template<typename _Ret, typename _Fn, typename... _Args> |
7dcc645c | 3030 | inline constexpr bool is_invocable_r_v |
ce9f305e | 3031 | = is_invocable_r<_Ret, _Fn, _Args...>::value; |
7dcc645c JW |
3032 | |
3033 | /// std::is_nothrow_invocable_r_v | |
ce9f305e | 3034 | template<typename _Ret, typename _Fn, typename... _Args> |
7dcc645c | 3035 | inline constexpr bool is_nothrow_invocable_r_v |
ce9f305e | 3036 | = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; |
7dcc645c | 3037 | #endif // C++17 |
42183d03 | 3038 | |
e641ee43 | 3039 | #if __cplusplus >= 201703L |
068c8ac1 | 3040 | # define __cpp_lib_type_trait_variable_templates 201510L |
137422c8 | 3041 | template <typename _Tp> |
288695f7 | 3042 | inline constexpr bool is_void_v = is_void<_Tp>::value; |
137422c8 | 3043 | template <typename _Tp> |
288695f7 | 3044 | inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; |
137422c8 | 3045 | template <typename _Tp> |
288695f7 | 3046 | inline constexpr bool is_integral_v = is_integral<_Tp>::value; |
137422c8 | 3047 | template <typename _Tp> |
288695f7 | 3048 | inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; |
137422c8 | 3049 | template <typename _Tp> |
288695f7 | 3050 | inline constexpr bool is_array_v = is_array<_Tp>::value; |
137422c8 | 3051 | template <typename _Tp> |
288695f7 | 3052 | inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; |
137422c8 | 3053 | template <typename _Tp> |
288695f7 DK |
3054 | inline constexpr bool is_lvalue_reference_v = |
3055 | is_lvalue_reference<_Tp>::value; | |
137422c8 | 3056 | template <typename _Tp> |
288695f7 DK |
3057 | inline constexpr bool is_rvalue_reference_v = |
3058 | is_rvalue_reference<_Tp>::value; | |
137422c8 | 3059 | template <typename _Tp> |
288695f7 | 3060 | inline constexpr bool is_member_object_pointer_v = |
137422c8 VV |
3061 | is_member_object_pointer<_Tp>::value; |
3062 | template <typename _Tp> | |
288695f7 | 3063 | inline constexpr bool is_member_function_pointer_v = |
137422c8 VV |
3064 | is_member_function_pointer<_Tp>::value; |
3065 | template <typename _Tp> | |
288695f7 | 3066 | inline constexpr bool is_enum_v = is_enum<_Tp>::value; |
137422c8 | 3067 | template <typename _Tp> |
288695f7 | 3068 | inline constexpr bool is_union_v = is_union<_Tp>::value; |
137422c8 | 3069 | template <typename _Tp> |
288695f7 | 3070 | inline constexpr bool is_class_v = is_class<_Tp>::value; |
137422c8 | 3071 | template <typename _Tp> |
288695f7 | 3072 | inline constexpr bool is_function_v = is_function<_Tp>::value; |
137422c8 | 3073 | template <typename _Tp> |
288695f7 | 3074 | inline constexpr bool is_reference_v = is_reference<_Tp>::value; |
137422c8 | 3075 | template <typename _Tp> |
288695f7 | 3076 | inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; |
137422c8 | 3077 | template <typename _Tp> |
288695f7 | 3078 | inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; |
137422c8 | 3079 | template <typename _Tp> |
288695f7 | 3080 | inline constexpr bool is_object_v = is_object<_Tp>::value; |
137422c8 | 3081 | template <typename _Tp> |
288695f7 | 3082 | inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; |
137422c8 | 3083 | template <typename _Tp> |
288695f7 | 3084 | inline constexpr bool is_compound_v = is_compound<_Tp>::value; |
137422c8 | 3085 | template <typename _Tp> |
288695f7 | 3086 | inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; |
137422c8 | 3087 | template <typename _Tp> |
288695f7 | 3088 | inline constexpr bool is_const_v = is_const<_Tp>::value; |
137422c8 | 3089 | template <typename _Tp> |
288695f7 | 3090 | inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; |
137422c8 | 3091 | template <typename _Tp> |
288695f7 | 3092 | inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; |
137422c8 | 3093 | template <typename _Tp> |
288695f7 DK |
3094 | inline constexpr bool is_trivially_copyable_v = |
3095 | is_trivially_copyable<_Tp>::value; | |
137422c8 | 3096 | template <typename _Tp> |
288695f7 | 3097 | inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; |
137422c8 | 3098 | template <typename _Tp> |
288695f7 | 3099 | inline constexpr bool is_pod_v = is_pod<_Tp>::value; |
137422c8 | 3100 | template <typename _Tp> |
288695f7 | 3101 | inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; |
137422c8 | 3102 | template <typename _Tp> |
288695f7 | 3103 | inline constexpr bool is_empty_v = is_empty<_Tp>::value; |
137422c8 | 3104 | template <typename _Tp> |
288695f7 | 3105 | inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; |
137422c8 | 3106 | template <typename _Tp> |
288695f7 | 3107 | inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; |
137422c8 | 3108 | template <typename _Tp> |
288695f7 | 3109 | inline constexpr bool is_final_v = is_final<_Tp>::value; |
137422c8 | 3110 | template <typename _Tp> |
288695f7 | 3111 | inline constexpr bool is_signed_v = is_signed<_Tp>::value; |
137422c8 | 3112 | template <typename _Tp> |
288695f7 | 3113 | inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; |
137422c8 | 3114 | template <typename _Tp, typename... _Args> |
288695f7 DK |
3115 | inline constexpr bool is_constructible_v = |
3116 | is_constructible<_Tp, _Args...>::value; | |
137422c8 | 3117 | template <typename _Tp> |
288695f7 | 3118 | inline constexpr bool is_default_constructible_v = |
137422c8 VV |
3119 | is_default_constructible<_Tp>::value; |
3120 | template <typename _Tp> | |
288695f7 DK |
3121 | inline constexpr bool is_copy_constructible_v = |
3122 | is_copy_constructible<_Tp>::value; | |
137422c8 | 3123 | template <typename _Tp> |
288695f7 DK |
3124 | inline constexpr bool is_move_constructible_v = |
3125 | is_move_constructible<_Tp>::value; | |
137422c8 | 3126 | template <typename _Tp, typename _Up> |
288695f7 | 3127 | inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; |
137422c8 | 3128 | template <typename _Tp> |
288695f7 | 3129 | inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; |
137422c8 | 3130 | template <typename _Tp> |
288695f7 | 3131 | inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; |
137422c8 | 3132 | template <typename _Tp> |
288695f7 | 3133 | inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; |
137422c8 | 3134 | template <typename _Tp, typename... _Args> |
288695f7 | 3135 | inline constexpr bool is_trivially_constructible_v = |
137422c8 VV |
3136 | is_trivially_constructible<_Tp, _Args...>::value; |
3137 | template <typename _Tp> | |
288695f7 | 3138 | inline constexpr bool is_trivially_default_constructible_v = |
137422c8 VV |
3139 | is_trivially_default_constructible<_Tp>::value; |
3140 | template <typename _Tp> | |
288695f7 | 3141 | inline constexpr bool is_trivially_copy_constructible_v = |
137422c8 VV |
3142 | is_trivially_copy_constructible<_Tp>::value; |
3143 | template <typename _Tp> | |
288695f7 | 3144 | inline constexpr bool is_trivially_move_constructible_v = |
137422c8 VV |
3145 | is_trivially_move_constructible<_Tp>::value; |
3146 | template <typename _Tp, typename _Up> | |
288695f7 | 3147 | inline constexpr bool is_trivially_assignable_v = |
137422c8 VV |
3148 | is_trivially_assignable<_Tp, _Up>::value; |
3149 | template <typename _Tp> | |
288695f7 | 3150 | inline constexpr bool is_trivially_copy_assignable_v = |
137422c8 VV |
3151 | is_trivially_copy_assignable<_Tp>::value; |
3152 | template <typename _Tp> | |
288695f7 | 3153 | inline constexpr bool is_trivially_move_assignable_v = |
137422c8 VV |
3154 | is_trivially_move_assignable<_Tp>::value; |
3155 | template <typename _Tp> | |
288695f7 | 3156 | inline constexpr bool is_trivially_destructible_v = |
137422c8 VV |
3157 | is_trivially_destructible<_Tp>::value; |
3158 | template <typename _Tp, typename... _Args> | |
288695f7 | 3159 | inline constexpr bool is_nothrow_constructible_v = |
137422c8 VV |
3160 | is_nothrow_constructible<_Tp, _Args...>::value; |
3161 | template <typename _Tp> | |
288695f7 | 3162 | inline constexpr bool is_nothrow_default_constructible_v = |
137422c8 VV |
3163 | is_nothrow_default_constructible<_Tp>::value; |
3164 | template <typename _Tp> | |
288695f7 | 3165 | inline constexpr bool is_nothrow_copy_constructible_v = |
137422c8 VV |
3166 | is_nothrow_copy_constructible<_Tp>::value; |
3167 | template <typename _Tp> | |
288695f7 | 3168 | inline constexpr bool is_nothrow_move_constructible_v = |
137422c8 VV |
3169 | is_nothrow_move_constructible<_Tp>::value; |
3170 | template <typename _Tp, typename _Up> | |
288695f7 | 3171 | inline constexpr bool is_nothrow_assignable_v = |
137422c8 VV |
3172 | is_nothrow_assignable<_Tp, _Up>::value; |
3173 | template <typename _Tp> | |
288695f7 | 3174 | inline constexpr bool is_nothrow_copy_assignable_v = |
137422c8 VV |
3175 | is_nothrow_copy_assignable<_Tp>::value; |
3176 | template <typename _Tp> | |
288695f7 | 3177 | inline constexpr bool is_nothrow_move_assignable_v = |
137422c8 VV |
3178 | is_nothrow_move_assignable<_Tp>::value; |
3179 | template <typename _Tp> | |
288695f7 | 3180 | inline constexpr bool is_nothrow_destructible_v = |
137422c8 VV |
3181 | is_nothrow_destructible<_Tp>::value; |
3182 | template <typename _Tp> | |
288695f7 | 3183 | inline constexpr bool has_virtual_destructor_v = |
137422c8 VV |
3184 | has_virtual_destructor<_Tp>::value; |
3185 | template <typename _Tp> | |
288695f7 | 3186 | inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; |
137422c8 | 3187 | template <typename _Tp> |
288695f7 | 3188 | inline constexpr size_t rank_v = rank<_Tp>::value; |
137422c8 | 3189 | template <typename _Tp, unsigned _Idx = 0> |
288695f7 | 3190 | inline constexpr size_t extent_v = extent<_Tp, _Idx>::value; |
137422c8 | 3191 | template <typename _Tp, typename _Up> |
288695f7 | 3192 | inline constexpr bool is_same_v = is_same<_Tp, _Up>::value; |
137422c8 | 3193 | template <typename _Base, typename _Derived> |
288695f7 | 3194 | inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; |
137422c8 | 3195 | template <typename _From, typename _To> |
288695f7 | 3196 | inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; |
873c7d5a | 3197 | |
2d763763 | 3198 | #ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP |
873c7d5a JW |
3199 | # define __cpp_lib_has_unique_object_representations 201606 |
3200 | /// has_unique_object_representations | |
3201 | template<typename _Tp> | |
3202 | struct has_unique_object_representations | |
3203 | : bool_constant<__has_unique_object_representations( | |
3204 | remove_cv_t<remove_all_extents_t<_Tp>> | |
3205 | )> | |
608a080c AP |
3206 | { |
3207 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), | |
3208 | "template argument must be a complete class or an unbounded array"); | |
3209 | }; | |
b0e63d94 JW |
3210 | |
3211 | template<typename _Tp> | |
3212 | inline constexpr bool has_unique_object_representations_v | |
3213 | = has_unique_object_representations<_Tp>::value; | |
1f5700e9 | 3214 | #endif |
e2ac6765 | 3215 | |
afa56c17 | 3216 | #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE |
ff273400 | 3217 | # define __cpp_lib_is_aggregate 201703 |
e2ac6765 VV |
3218 | /// is_aggregate |
3219 | template<typename _Tp> | |
3220 | struct is_aggregate | |
608a080c | 3221 | : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> |
209ee624 | 3222 | { }; |
e2ac6765 VV |
3223 | |
3224 | /// is_aggregate_v | |
3225 | template<typename _Tp> | |
3226 | inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; | |
3227 | #endif | |
137422c8 | 3228 | #endif // C++17 |
6b9539e2 | 3229 | |
e641ee43 | 3230 | #if __cplusplus > 201703L |
6791489e JW |
3231 | /// Remove references and cv-qualifiers. |
3232 | template<typename _Tp> | |
3233 | struct remove_cvref | |
3234 | { | |
3235 | using type = __remove_cvref_t<_Tp>; | |
3236 | }; | |
3237 | ||
3238 | template<typename _Tp> | |
3239 | using remove_cvref_t = __remove_cvref_t<_Tp>; | |
3240 | ||
ee896276 JW |
3241 | /// Identity metafunction. |
3242 | template<typename _Tp> | |
3243 | struct type_identity { using type = _Tp; }; | |
3244 | ||
3245 | template<typename _Tp> | |
3246 | using type_identity_t = typename type_identity<_Tp>::type; | |
3247 | ||
3d18dc9d JW |
3248 | /// Unwrap a reference_wrapper |
3249 | template<typename _Tp> | |
3250 | struct unwrap_reference { using type = _Tp; }; | |
3251 | ||
3252 | template<typename _Tp> | |
3253 | struct unwrap_reference<reference_wrapper<_Tp>> { using type = _Tp&; }; | |
3254 | ||
82e8c3da JW |
3255 | template<typename _Tp> |
3256 | using unwrap_reference_t = typename unwrap_reference<_Tp>::type; | |
3257 | ||
3d18dc9d JW |
3258 | /// Decay type and if it's a reference_wrapper, unwrap it |
3259 | template<typename _Tp> | |
82e8c3da | 3260 | struct unwrap_ref_decay { using type = unwrap_reference_t<decay_t<_Tp>>; }; |
3d18dc9d JW |
3261 | |
3262 | template<typename _Tp> | |
3263 | using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; | |
3264 | ||
46610940 JW |
3265 | #define __cpp_lib_bounded_array_traits 201902L |
3266 | ||
28d85efb JW |
3267 | /// True for a type that is an array of known bound. |
3268 | template<typename _Tp> | |
3269 | struct is_bounded_array | |
3270 | : public __is_array_known_bounds<_Tp> | |
3271 | { }; | |
3272 | ||
3273 | /// True for a type that is an array of unknown bound. | |
3274 | template<typename _Tp> | |
3275 | struct is_unbounded_array | |
3276 | : public __is_array_unknown_bounds<_Tp> | |
3277 | { }; | |
3278 | ||
3279 | template<typename _Tp> | |
3280 | inline constexpr bool is_bounded_array_v | |
3281 | = is_bounded_array<_Tp>::value; | |
3282 | ||
3283 | template<typename _Tp> | |
3284 | inline constexpr bool is_unbounded_array_v | |
3285 | = is_unbounded_array<_Tp>::value; | |
3286 | ||
0d7924f2 | 3287 | #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED |
134a6f7b | 3288 | |
8aa1550e | 3289 | #define __cpp_lib_is_constant_evaluated 201811L |
134a6f7b | 3290 | |
0d7924f2 JJ |
3291 | constexpr inline bool |
3292 | is_constant_evaluated() noexcept | |
3293 | { return __builtin_is_constant_evaluated(); } | |
3294 | #endif | |
3295 | ||
e641ee43 JW |
3296 | #endif // C++2a |
3297 | ||
12ffa228 | 3298 | _GLIBCXX_END_NAMESPACE_VERSION |
c0ffa2ba | 3299 | } // namespace std |
7b50cdef | 3300 | |
734f5023 | 3301 | #endif // C++11 |
57317d2a | 3302 | |
7274deff | 3303 | #endif // _GLIBCXX_TYPE_TRAITS |