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