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