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