1 // C++11 <type_traits> -*- C++ -*-
3 // Copyright (C) 2007-2017 Free Software Foundation, Inc.
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)
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.
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>
38 #include <bits/c++config.h>
40 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
41 # if defined (__UINT_LEAST16_TYPE__) && defined(__UINT_LEAST32_TYPE__)
44 typedef __UINT_LEAST16_TYPE__ uint_least16_t;
45 typedef __UINT_LEAST32_TYPE__ uint_least32_t;
52 namespace std _GLIBCXX_VISIBILITY(default)
54 _GLIBCXX_BEGIN_NAMESPACE_VERSION
57 * @defgroup metaprogramming Metaprogramming
60 * Template utilities for compile-time introspection and modification,
61 * including type classification traits, type property inspection traits
62 * and type transformation traits.
68 template<typename _Tp, _Tp __v>
69 struct integral_constant
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; }
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;
93 using __bool_constant = integral_constant<bool, __v>;
95 #if __cplusplus > 201402L
96 # define __cpp_lib_bool_constant 201505
98 using bool_constant = integral_constant<bool, __v>;
101 // Meta programming helper types.
103 template<bool, typename, typename>
106 template<typename...>
114 template<typename _B1>
119 template<typename _B1, typename _B2>
120 struct __or_<_B1, _B2>
121 : public conditional<_B1::value, _B1, _B2>::type
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
129 template<typename...>
137 template<typename _B1>
142 template<typename _B1, typename _B2>
143 struct __and_<_B1, _B2>
144 : public conditional<_B1::value, _B2, _B1>::type
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
152 template<typename _Pp>
154 : public integral_constant<bool, !_Pp::value>
157 #if __cplusplus > 201402L
159 #define __cpp_lib_logical_traits 201510
161 template<typename... _Bn>
166 template<typename... _Bn>
171 template<typename _Pp>
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;
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
202 // Primary type categories.
208 struct __is_void_helper
209 : public false_type { };
212 struct __is_void_helper<void>
213 : public true_type { };
216 template<typename _Tp>
218 : public __is_void_helper<typename remove_cv<_Tp>::type>::type
222 struct __is_integral_helper
223 : public false_type { };
226 struct __is_integral_helper<bool>
227 : public true_type { };
230 struct __is_integral_helper<char>
231 : public true_type { };
234 struct __is_integral_helper<signed char>
235 : public true_type { };
238 struct __is_integral_helper<unsigned char>
239 : public true_type { };
241 #ifdef _GLIBCXX_USE_WCHAR_T
243 struct __is_integral_helper<wchar_t>
244 : public true_type { };
248 struct __is_integral_helper<char16_t>
249 : public true_type { };
252 struct __is_integral_helper<char32_t>
253 : public true_type { };
256 struct __is_integral_helper<short>
257 : public true_type { };
260 struct __is_integral_helper<unsigned short>
261 : public true_type { };
264 struct __is_integral_helper<int>
265 : public true_type { };
268 struct __is_integral_helper<unsigned int>
269 : public true_type { };
272 struct __is_integral_helper<long>
273 : public true_type { };
276 struct __is_integral_helper<unsigned long>
277 : public true_type { };
280 struct __is_integral_helper<long long>
281 : public true_type { };
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)
291 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0>
292 : public true_type { };
295 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0>
296 : public true_type { };
298 #if defined(__GLIBCXX_TYPE_INT_N_1)
300 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1>
301 : public true_type { };
304 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1>
305 : public true_type { };
307 #if defined(__GLIBCXX_TYPE_INT_N_2)
309 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2>
310 : public true_type { };
313 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2>
314 : public true_type { };
316 #if defined(__GLIBCXX_TYPE_INT_N_3)
318 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3>
319 : public true_type { };
322 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3>
323 : public true_type { };
327 template<typename _Tp>
329 : public __is_integral_helper<typename remove_cv<_Tp>::type>::type
333 struct __is_floating_point_helper
334 : public false_type { };
337 struct __is_floating_point_helper<float>
338 : public true_type { };
341 struct __is_floating_point_helper<double>
342 : public true_type { };
345 struct __is_floating_point_helper<long double>
346 : public true_type { };
348 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
350 struct __is_floating_point_helper<__float128>
351 : public true_type { };
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
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 { };
374 struct __is_pointer_helper
375 : public false_type { };
377 template<typename _Tp>
378 struct __is_pointer_helper<_Tp*>
379 : public true_type { };
382 template<typename _Tp>
384 : public __is_pointer_helper<typename remove_cv<_Tp>::type>::type
387 /// is_lvalue_reference
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
398 struct is_rvalue_reference
399 : public false_type { };
401 template<typename _Tp>
402 struct is_rvalue_reference<_Tp&&>
403 : public true_type { };
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
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
439 template<typename _Tp>
441 : public integral_constant<bool, __is_enum(_Tp)>
445 template<typename _Tp>
447 : public integral_constant<bool, __is_union(_Tp)>
451 template<typename _Tp>
453 : public integral_constant<bool, __is_class(_Tp)>
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
560 struct __is_null_pointer_helper
561 : public false_type { };
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
573 /// __is_nullptr_t (extension).
574 template<typename _Tp>
575 struct __is_nullptr_t
576 : public is_null_pointer<_Tp>
579 // Composite type categories.
582 template<typename _Tp>
584 : public __or_<is_lvalue_reference<_Tp>,
585 is_rvalue_reference<_Tp>>::type
589 template<typename _Tp>
591 : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type
595 template<typename _Tp>
596 struct is_fundamental
597 : public __or_<is_arithmetic<_Tp>, is_void<_Tp>,
598 is_null_pointer<_Tp>>::type
602 template<typename _Tp>
604 : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
609 struct is_member_pointer;
612 template<typename _Tp>
614 : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
615 is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
619 template<typename _Tp>
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
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
644 template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM>
645 struct __is_referenceable<_Res(_Args...) _GLIBCXX_NOEXCEPT_QUAL>
649 template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM>
650 struct __is_referenceable<_Res(_Args......) _GLIBCXX_NOEXCEPT_QUAL>
659 : public false_type { };
661 template<typename _Tp>
662 struct is_const<_Tp const>
663 : public true_type { };
668 : public false_type { };
670 template<typename _Tp>
671 struct is_volatile<_Tp volatile>
672 : public true_type { };
675 template<typename _Tp>
677 : public integral_constant<bool, __is_trivial(_Tp)>
680 // is_trivially_copyable
681 template<typename _Tp>
682 struct is_trivially_copyable
683 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
686 /// is_standard_layout
687 template<typename _Tp>
688 struct is_standard_layout
689 : public integral_constant<bool, __is_standard_layout(_Tp)>
693 // Could use is_standard_layout && is_trivial instead of the builtin.
694 template<typename _Tp>
696 : public integral_constant<bool, __is_pod(_Tp)>
700 template<typename _Tp>
701 struct is_literal_type
702 : public integral_constant<bool, __is_literal_type(_Tp)>
706 template<typename _Tp>
708 : public integral_constant<bool, __is_empty(_Tp)>
712 template<typename _Tp>
713 struct is_polymorphic
714 : public integral_constant<bool, __is_polymorphic(_Tp)>
717 #if __cplusplus >= 201402L
718 #define __cpp_lib_is_final 201402L
720 template<typename _Tp>
722 : public integral_constant<bool, __is_final(_Tp)>
727 template<typename _Tp>
729 : public integral_constant<bool, __is_abstract(_Tp)>
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)>
743 template<typename _Tp>
745 : public __is_signed_helper<_Tp>::type
749 template<typename _Tp>
751 : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>
755 // Destructible and constructible type properties.
758 struct add_rvalue_reference;
761 * @brief Utility to simplify expressions used in unevaluated operands
764 template<typename _Tp>
765 typename add_rvalue_reference<_Tp>::type declval() noexcept;
767 template<typename, unsigned = 0>
771 struct remove_all_extents;
773 template<typename _Tp>
774 struct __is_array_known_bounds
775 : public integral_constant<bool, (extent<_Tp>::value > 0)>
778 template<typename _Tp>
779 struct __is_array_unknown_bounds
780 : public __and_<is_array<_Tp>, __not_<extent<_Tp>>>
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
790 template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())>
791 static true_type __test(int);
794 static false_type __test(...);
797 template<typename _Tp>
798 struct __is_destructible_impl
799 : public __do_is_destructible_impl
801 typedef decltype(__test<_Tp>(0)) type;
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
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 { };
826 template<typename _Tp>
827 struct is_destructible
828 : public __is_destructible_safe<_Tp>::type
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
837 template<typename _Tp>
838 static integral_constant<bool, noexcept(declval<_Tp&>().~_Tp())>
842 static false_type __test(...);
845 template<typename _Tp>
846 struct __is_nt_destructible_impl
847 : public __do_is_nt_destructible_impl
849 typedef decltype(__test<_Tp>(0)) type;
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
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
879 struct __do_is_default_constructible_impl
881 template<typename _Tp, typename = decltype(_Tp())>
882 static true_type __test(int);
885 static false_type __test(...);
888 template<typename _Tp>
889 struct __is_default_constructible_impl
890 : public __do_is_default_constructible_impl
892 typedef decltype(__test<_Tp>(0)) type;
895 template<typename _Tp>
896 struct __is_default_constructible_atom
897 : public __and_<__not_<is_void<_Tp>>,
898 __is_default_constructible_impl<_Tp>>
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>>
916 template<typename _Tp>
917 struct __is_default_constructible_safe<_Tp, false>
918 : public __is_default_constructible_atom<_Tp>::type
921 /// is_default_constructible
922 template<typename _Tp>
923 struct is_default_constructible
924 : public __is_default_constructible_safe<_Tp>::type
928 template<typename _Tp, typename... _Args>
929 struct is_constructible
930 : public __bool_constant<__is_constructible(_Tp, _Args...)>
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&>
945 /// is_copy_constructible
946 template<typename _Tp>
947 struct is_copy_constructible
948 : public __is_copy_constructible_impl<_Tp>
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&&>
963 /// is_move_constructible
964 template<typename _Tp>
965 struct is_move_constructible
966 : public __is_move_constructible_impl<_Tp>
969 template<typename _Tp>
970 struct __is_nt_default_constructible_atom
971 : public integral_constant<bool, noexcept(_Tp())>
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>>
984 template<typename _Tp>
985 struct __is_nt_default_constructible_impl<_Tp, false>
986 : public __is_nt_default_constructible_atom<_Tp>
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>>
996 template<typename _Tp, typename... _Args>
997 struct __is_nt_constructible_impl
998 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
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>()))>
1007 template<typename _Tp>
1008 struct __is_nt_constructible_impl<_Tp>
1009 : public is_nothrow_default_constructible<_Tp>
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...>>
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&>
1031 /// is_nothrow_copy_constructible
1032 template<typename _Tp>
1033 struct is_nothrow_copy_constructible
1034 : public __is_nothrow_copy_constructible_impl<_Tp>
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&&>
1049 /// is_nothrow_move_constructible
1050 template<typename _Tp>
1051 struct is_nothrow_move_constructible
1052 : public __is_nothrow_move_constructible_impl<_Tp>
1056 template<typename _Tp, typename _Up>
1057 struct is_assignable
1058 : public __bool_constant<__is_assignable(_Tp, _Up)>
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&>
1073 /// is_copy_assignable
1074 template<typename _Tp>
1075 struct is_copy_assignable
1076 : public __is_copy_assignable_impl<_Tp>
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&&>
1091 /// is_move_assignable
1092 template<typename _Tp>
1093 struct is_move_assignable
1094 : public __is_move_assignable_impl<_Tp>
1097 template<typename _Tp, typename _Up>
1098 struct __is_nt_assignable_impl
1099 : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())>
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>>
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&>
1121 /// is_nothrow_copy_assignable
1122 template<typename _Tp>
1123 struct is_nothrow_copy_assignable
1124 : public __is_nt_copy_assignable_impl<_Tp>
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&&>
1139 /// is_nothrow_move_assignable
1140 template<typename _Tp>
1141 struct is_nothrow_move_assignable
1142 : public __is_nt_move_assignable_impl<_Tp>
1145 /// is_trivially_constructible
1146 template<typename _Tp, typename... _Args>
1147 struct is_trivially_constructible
1148 : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)>
1151 /// is_trivially_default_constructible
1152 template<typename _Tp>
1153 struct is_trivially_default_constructible
1154 : public is_trivially_constructible<_Tp>::type
1157 struct __do_is_implicitly_default_constructible_impl
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(...);
1169 template<typename _Tp>
1170 struct __is_implicitly_default_constructible_impl
1171 : public __do_is_implicitly_default_constructible_impl
1173 typedef decltype(__test(declval<_Tp>())) type;
1176 template<typename _Tp>
1177 struct __is_implicitly_default_constructible_safe
1178 : public __is_implicitly_default_constructible_impl<_Tp>::type
1181 template <typename _Tp>
1182 struct __is_implicitly_default_constructible
1183 : public __and_<is_default_constructible<_Tp>,
1184 __is_implicitly_default_constructible_safe<_Tp>>
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&)>>
1203 template<typename _Tp>
1204 struct is_trivially_copy_constructible
1205 : public __is_trivially_copy_constructible_impl<_Tp>
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&&)>>
1224 template<typename _Tp>
1225 struct is_trivially_move_constructible
1226 : public __is_trivially_move_constructible_impl<_Tp>
1229 /// is_trivially_assignable
1230 template<typename _Tp, typename _Up>
1231 struct is_trivially_assignable
1232 : public __bool_constant<__is_trivially_assignable(_Tp, _Up)>
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&)>>
1251 template<typename _Tp>
1252 struct is_trivially_copy_assignable
1253 : public __is_trivially_copy_assignable_impl<_Tp>
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&&)>>
1272 template<typename _Tp>
1273 struct is_trivially_move_assignable
1274 : public __is_trivially_move_assignable_impl<_Tp>
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)>>
1285 /// has_virtual_destructor
1286 template<typename _Tp>
1287 struct has_virtual_destructor
1288 : public integral_constant<bool, __has_virtual_destructor(_Tp)>
1292 // type property queries.
1295 template<typename _Tp>
1297 : public integral_constant<std::size_t, __alignof__(_Tp)> { };
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>
1310 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1313 template<typename, unsigned _Uint>
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,
1324 template<typename _Tp, unsigned _Uint>
1325 struct extent<_Tp[], _Uint>
1326 : public integral_constant<std::size_t,
1327 _Uint == 0 ? 0 : extent<_Tp,
1335 template<typename, typename>
1337 : public false_type { };
1339 template<typename _Tp>
1340 struct is_same<_Tp, _Tp>
1341 : public true_type { };
1344 template<typename _Base, typename _Derived>
1346 : public integral_constant<bool, __is_base_of(_Base, _Derived)>
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>
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>()))>
1366 template<typename, typename>
1371 typedef decltype(__test<_From, _To>(0)) type;
1376 template<typename _From, typename _To>
1377 struct is_convertible
1378 : public __is_convertible_helper<_From, _To>::type
1382 // Const-volatile modifications.
1385 template<typename _Tp>
1387 { typedef _Tp type; };
1389 template<typename _Tp>
1390 struct remove_const<_Tp const>
1391 { typedef _Tp type; };
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; };
1403 template<typename _Tp>
1407 remove_const<typename remove_volatile<_Tp>::type>::type type;
1411 template<typename _Tp>
1413 { typedef _Tp const type; };
1416 template<typename _Tp>
1418 { typedef _Tp volatile type; };
1421 template<typename _Tp>
1425 add_const<typename add_volatile<_Tp>::type>::type type;
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;
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>
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>
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;
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
1541 typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match;
1544 typedef typename __match::__type __type;
1547 // Utility for finding the unsigned versions of signed integral types.
1548 template<typename _Tp>
1549 struct __make_unsigned
1550 { typedef _Tp __type; };
1553 struct __make_unsigned<char>
1554 { typedef unsigned char __type; };
1557 struct __make_unsigned<signed char>
1558 { typedef unsigned char __type; };
1561 struct __make_unsigned<short>
1562 { typedef unsigned short __type; };
1565 struct __make_unsigned<int>
1566 { typedef unsigned int __type; };
1569 struct __make_unsigned<long>
1570 { typedef unsigned long __type; };
1573 struct __make_unsigned<long long>
1574 { typedef unsigned long long __type; };
1576 #if defined(_GLIBCXX_USE_WCHAR_T) && !defined(__WCHAR_UNSIGNED__)
1578 struct __make_unsigned<wchar_t> : __make_unsigned<__WCHAR_TYPE__>
1582 #if defined(__GLIBCXX_TYPE_INT_N_0)
1584 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0>
1585 { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; };
1587 #if defined(__GLIBCXX_TYPE_INT_N_1)
1589 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1>
1590 { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; };
1592 #if defined(__GLIBCXX_TYPE_INT_N_2)
1594 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2>
1595 { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; };
1597 #if defined(__GLIBCXX_TYPE_INT_N_3)
1599 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3>
1600 { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; };
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>
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;
1617 typedef typename __cv_unsigned::__type __type;
1620 template<typename _Tp>
1621 class __make_unsigned_selector<_Tp, false, true>
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
1638 typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
1641 typedef typename __cv_unsigned::__type __type;
1644 // Given an integral/enum type, return the corresponding unsigned
1646 // Primary template.
1648 template<typename _Tp>
1649 struct make_unsigned
1650 { typedef typename __make_unsigned_selector<_Tp>::__type type; };
1652 // Integral, but don't define.
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; };
1663 struct __make_signed<char>
1664 { typedef signed char __type; };
1667 struct __make_signed<unsigned char>
1668 { typedef signed char __type; };
1671 struct __make_signed<unsigned short>
1672 { typedef signed short __type; };
1675 struct __make_signed<unsigned int>
1676 { typedef signed int __type; };
1679 struct __make_signed<unsigned long>
1680 { typedef signed long __type; };
1683 struct __make_signed<unsigned long long>
1684 { typedef signed long long __type; };
1686 #if defined(_GLIBCXX_USE_WCHAR_T) && defined(__WCHAR_UNSIGNED__)
1688 struct __make_signed<wchar_t> : __make_signed<__WCHAR_TYPE__>
1692 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
1694 struct __make_signed<char16_t> : __make_signed<uint_least16_t>
1697 struct __make_signed<char32_t> : __make_signed<uint_least32_t>
1701 #if defined(__GLIBCXX_TYPE_INT_N_0)
1703 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0>
1704 { typedef __GLIBCXX_TYPE_INT_N_0 __type; };
1706 #if defined(__GLIBCXX_TYPE_INT_N_1)
1708 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1>
1709 { typedef __GLIBCXX_TYPE_INT_N_1 __type; };
1711 #if defined(__GLIBCXX_TYPE_INT_N_2)
1713 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2>
1714 { typedef __GLIBCXX_TYPE_INT_N_2 __type; };
1716 #if defined(__GLIBCXX_TYPE_INT_N_3)
1718 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3>
1719 { typedef __GLIBCXX_TYPE_INT_N_3 __type; };
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>
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;
1736 typedef typename __cv_signed::__type __type;
1739 template<typename _Tp>
1740 class __make_signed_selector<_Tp, false, true>
1742 typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type;
1745 typedef typename __make_signed_selector<__unsigned_type>::__type __type;
1748 // Given an integral/enum type, return the corresponding signed
1750 // Primary template.
1752 template<typename _Tp>
1754 { typedef typename __make_signed_selector<_Tp>::__type type; };
1756 // Integral, but don't define.
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;
1770 // Array modifications.
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;
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; };
1819 template<typename _Tp>
1820 struct remove_pointer
1821 : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
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>
1836 : public __add_pointer_helper<_Tp>
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;
1849 template<std::size_t _Len>
1850 struct __aligned_storage_msa
1854 unsigned char __data[_Len];
1855 struct __attribute__((__aligned__)) { } __align;
1860 * @brief Alignment type.
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.
1869 template<std::size_t _Len, std::size_t _Align =
1870 __alignof__(typename __aligned_storage_msa<_Len>::__type)>
1871 struct aligned_storage
1875 unsigned char __data[_Len];
1876 struct __attribute__((__aligned__((_Align)))) { } __align;
1880 template <typename... _Types>
1881 struct __strictest_alignment
1883 static const size_t _S_alignment = 0;
1884 static const size_t _S_size = 0;
1887 template <typename _Tp, typename... _Types>
1888 struct __strictest_alignment<_Tp, _Types...>
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;
1899 * @brief Provide aligned storage for types.
1901 * [meta.trans.other]
1903 * Provides aligned storage for any of the provided types of at
1906 * @see aligned_storage
1908 template <size_t _Len, typename... _Types>
1909 struct aligned_union
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;
1918 /// The value of the strictest alignment of _Types.
1919 static const size_t alignment_value = __strictest::_S_alignment;
1921 typedef typename aligned_storage<_S_len, alignment_value>::type type;
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;
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; };
1948 template<typename _Tp>
1951 typedef typename remove_reference<_Tp>::type __remove_type;
1954 typedef typename __decay_selector<__remove_type>::__type type;
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
1967 template<typename _Tp>
1968 struct __strip_reference_wrapper<reference_wrapper<_Tp> >
1970 typedef _Tp& __type;
1973 template<typename _Tp>
1974 struct __decay_and_strip
1976 typedef typename __strip_reference_wrapper<
1977 typename decay<_Tp>::type>::__type __type;
1981 // Primary template.
1982 /// Define a member typedef @c type only if a boolean constant is true.
1983 template<bool, typename _Tp = void>
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>
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; };
2007 template<typename... _Tp>
2010 // Sfinae-friendly common_type implementation:
2012 struct __do_common_type_impl
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(...);
2023 template<typename _Tp, typename _Up>
2024 struct __common_type_impl
2025 : private __do_common_type_impl
2027 typedef decltype(_S_test<_Tp, _Up>(0)) type;
2030 struct __do_member_type_wrapper
2032 template<typename _Tp>
2033 static __success_type<typename _Tp::type> _S_test(int);
2036 static __failure_type _S_test(...);
2039 template<typename _Tp>
2040 struct __member_type_wrapper
2041 : private __do_member_type_wrapper
2043 typedef decltype(_S_test<_Tp>(0)) type;
2046 template<typename _CTp, typename... _Args>
2047 struct __expanded_common_type_wrapper
2049 typedef common_type<typename _CTp::type, _Args...> type;
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
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
2071 /// The underlying type of an enum.
2072 template<typename _Tp>
2073 struct underlying_type
2075 typedef __underlying_type(_Tp) type;
2078 template<typename _Tp>
2079 struct __declval_protector
2081 static const bool __stop = false;
2082 static typename add_rvalue_reference<_Tp>::type __delegate();
2085 template<typename _Tp>
2086 inline typename add_rvalue_reference<_Tp>::type
2089 static_assert(__declval_protector<_Tp>::__stop,
2090 "declval() must not be used!");
2091 return __declval_protector<_Tp>::__delegate();
2095 template<typename _Signature>
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
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(...);
2125 template<typename _MemPtr, typename _Arg, typename... _Args>
2126 struct __result_of_memfun_ref
2127 : private __result_of_memfun_ref_impl
2129 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2132 // [func.require] paragraph 1 bullet 2:
2133 struct __result_of_memfun_deref_impl
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(...);
2144 template<typename _MemPtr, typename _Arg, typename... _Args>
2145 struct __result_of_memfun_deref
2146 : private __result_of_memfun_deref_impl
2148 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2151 // [func.require] paragraph 1 bullet 3:
2152 struct __result_of_memobj_ref_impl
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(...);
2163 template<typename _MemPtr, typename _Arg>
2164 struct __result_of_memobj_ref
2165 : private __result_of_memobj_ref_impl
2167 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2170 // [func.require] paragraph 1 bullet 4:
2171 struct __result_of_memobj_deref_impl
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(...);
2182 template<typename _MemPtr, typename _Arg>
2183 struct __result_of_memobj_deref
2184 : private __result_of_memobj_deref_impl
2186 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
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>
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>
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...>
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...>
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>
2232 template<typename _Tp, typename _Up>
2233 struct __inv_unwrap<_Tp, reference_wrapper<_Up>>
2238 template<bool, bool, typename _Functor, typename... _ArgTypes>
2239 struct __result_of_impl
2241 typedef __failure_type type;
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>
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...>
2256 // [func.require] paragraph 1 bullet 5:
2257 struct __result_of_other_impl
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(...);
2268 template<typename _Functor, typename... _ArgTypes>
2269 struct __result_of_impl<false, false, _Functor, _ArgTypes...>
2270 : private __result_of_other_impl
2272 typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type;
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
2282 is_member_function_pointer<
2283 typename remove_reference<_Functor>::type
2285 _Functor, _ArgTypes...
2289 template<typename _Functor, typename... _ArgTypes>
2290 struct result_of<_Functor(_ArgTypes...)>
2291 : public __invoke_result<_Functor, _ArgTypes...>
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;
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;
2336 /// Implementation of the detection idiom (negative case).
2337 template<typename _Default, typename _AlwaysVoid,
2338 template<typename...> class _Op, typename... _Args>
2341 using value_t = false_type;
2342 using type = _Default;
2345 /// Implementation of the detection idiom (positive case).
2346 template<typename _Default, template<typename...> class _Op,
2348 struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...>
2350 using value_t = true_type;
2351 using type = _Op<_Args...>;
2354 // Detect whether _Op<_Args...> is a valid type, use _Default if not.
2355 template<typename _Default, template<typename...> class _Op,
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,
2362 using __detected_or_t
2363 = typename __detected_or<_Default, _Op, _Args...>::type;
2365 /// @} group metaprogramming
2368 * Use SFINAE to determine if the type _Tp has a publicly-accessible
2369 * member type _NTYPE.
2371 #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \
2372 template<typename _Tp, typename = __void_t<>> \
2373 struct __has_##_NTYPE \
2376 template<typename _Tp> \
2377 struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \
2381 template <typename _Tp>
2382 struct __is_swappable;
2384 template <typename _Tp>
2385 struct __is_nothrow_swappable;
2387 template<typename... _Elements>
2391 struct __is_tuple_like_impl : false_type
2394 template<typename... _Tps>
2395 struct __is_tuple_like_impl<tuple<_Tps...>> : true_type
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
2405 template<typename _Tp>
2407 typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>,
2408 is_move_constructible<_Tp>,
2409 is_move_assignable<_Tp>>::value>::type
2411 noexcept(__and_<is_nothrow_move_constructible<_Tp>,
2412 is_nothrow_move_assignable<_Tp>>::value);
2414 template<typename _Tp, size_t _Nm>
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 {
2423 struct __do_is_swappable_impl
2425 template<typename _Tp, typename
2426 = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))>
2427 static true_type __test(int);
2430 static false_type __test(...);
2433 struct __do_is_nothrow_swappable_impl
2435 template<typename _Tp>
2436 static __bool_constant<
2437 noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))
2441 static false_type __test(...);
2444 } // namespace __swappable_details
2446 template<typename _Tp>
2447 struct __is_swappable_impl
2448 : public __swappable_details::__do_is_swappable_impl
2450 typedef decltype(__test<_Tp>(0)) type;
2453 template<typename _Tp>
2454 struct __is_nothrow_swappable_impl
2455 : public __swappable_details::__do_is_nothrow_swappable_impl
2457 typedef decltype(__test<_Tp>(0)) type;
2460 template<typename _Tp>
2461 struct __is_swappable
2462 : public __is_swappable_impl<_Tp>::type
2465 template<typename _Tp>
2466 struct __is_nothrow_swappable
2467 : public __is_nothrow_swappable_impl<_Tp>::type
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
2475 template<typename _Tp>
2477 : public __is_swappable_impl<_Tp>::type
2480 /// is_nothrow_swappable
2481 template<typename _Tp>
2482 struct is_nothrow_swappable
2483 : public __is_nothrow_swappable_impl<_Tp>::type
2486 #if __cplusplus >= 201402L
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 {
2501 struct __do_is_swappable_with_impl
2503 template<typename _Tp, typename _Up, typename
2504 = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())),
2506 = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))>
2507 static true_type __test(int);
2509 template<typename, typename>
2510 static false_type __test(...);
2513 struct __do_is_nothrow_swappable_with_impl
2515 template<typename _Tp, typename _Up>
2516 static __bool_constant<
2517 noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))
2519 noexcept(swap(std::declval<_Up>(), std::declval<_Tp>()))
2522 template<typename, typename>
2523 static false_type __test(...);
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
2532 typedef decltype(__test<_Tp, _Up>(0)) type;
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
2540 typedef decltype(__test<_Tp&>(0)) type;
2543 template<typename _Tp, typename _Up>
2544 struct __is_nothrow_swappable_with_impl
2545 : public __swappable_with_details::__do_is_nothrow_swappable_with_impl
2547 typedef decltype(__test<_Tp, _Up>(0)) type;
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
2555 typedef decltype(__test<_Tp&>(0)) type;
2558 /// is_swappable_with
2559 template<typename _Tp, typename _Up>
2560 struct is_swappable_with
2561 : public __is_swappable_with_impl<_Tp, _Up>::type
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
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
2594 template<typename _Fn, typename... _ArgTypes>
2595 struct __is_invocable
2596 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
2599 template<typename _Fn, typename _Tp, typename... _Args>
2600 constexpr bool __call_is_nt(__invoke_memfun_ref)
2602 using _Up = typename __inv_unwrap<_Tp>::type;
2603 return noexcept((std::declval<_Up>().*std::declval<_Fn>())(
2604 std::declval<_Args>()...));
2607 template<typename _Fn, typename _Tp, typename... _Args>
2608 constexpr bool __call_is_nt(__invoke_memfun_deref)
2610 return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())(
2611 std::declval<_Args>()...));
2614 template<typename _Fn, typename _Tp>
2615 constexpr bool __call_is_nt(__invoke_memobj_ref)
2617 using _Up = typename __inv_unwrap<_Tp>::type;
2618 return noexcept(std::declval<_Up>().*std::declval<_Fn>());
2621 template<typename _Fn, typename _Tp>
2622 constexpr bool __call_is_nt(__invoke_memobj_deref)
2624 return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>());
2627 template<typename _Fn, typename... _Args>
2628 constexpr bool __call_is_nt(__invoke_other)
2630 return noexcept(std::declval<_Fn>()(std::declval<_Args>()...));
2633 template<typename _Result, typename _Fn, typename... _Args>
2634 struct __call_is_nothrow
2636 std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{})
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
2652 __nonesuch() = delete;
2653 ~__nonesuch() = delete;
2654 __nonesuch(__nonesuch const&) = delete;
2655 void operator=(__nonesuch const&) = delete;
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...>
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>
2674 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
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
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
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
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;
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;
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
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>>
2895 #undef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
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
2906 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
2907 #define __cpp_lib_is_aggregate 201703
2909 template<typename _Tp>
2911 : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> { };
2914 template<typename _Tp>
2915 inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
2917 #undef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
2921 _GLIBCXX_END_NAMESPACE_VERSION
2926 #endif // _GLIBCXX_TYPE_TRAITS