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