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