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