1 // C++11 <type_traits> -*- C++ -*-
3 // Copyright (C) 2007-2018 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 noexcept { return value; }
75 #if __cplusplus > 201103L
77 #define __cpp_lib_integral_constant_callable 201304
79 constexpr value_type operator()() const noexcept { 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 __bool_constant<!bool(_Pp::value)>
157 #if __cplusplus >= 201703L
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 = conjunction<_Bn...>::value;
179 template<typename... _Bn>
180 inline constexpr bool disjunction_v = disjunction<_Bn...>::value;
182 template<typename _Pp>
183 inline constexpr bool negation_v = negation<_Pp>::value;
187 // For several sfinae-friendly trait implementations we transport both the
188 // result information (as the member type) and the failure information (no
189 // member type). This is very similar to std::enable_if, but we cannot use
190 // them, because we need to derive from them as an implementation detail.
192 template<typename _Tp>
193 struct __success_type
194 { typedef _Tp type; };
196 struct __failure_type
199 // Primary type categories.
205 struct __is_void_helper
206 : public false_type { };
209 struct __is_void_helper<void>
210 : public true_type { };
213 template<typename _Tp>
215 : public __is_void_helper<typename remove_cv<_Tp>::type>::type
219 struct __is_integral_helper
220 : public false_type { };
223 struct __is_integral_helper<bool>
224 : public true_type { };
227 struct __is_integral_helper<char>
228 : public true_type { };
231 struct __is_integral_helper<signed char>
232 : public true_type { };
235 struct __is_integral_helper<unsigned char>
236 : public true_type { };
238 #ifdef _GLIBCXX_USE_WCHAR_T
240 struct __is_integral_helper<wchar_t>
241 : public true_type { };
245 struct __is_integral_helper<char16_t>
246 : public true_type { };
249 struct __is_integral_helper<char32_t>
250 : public true_type { };
253 struct __is_integral_helper<short>
254 : public true_type { };
257 struct __is_integral_helper<unsigned short>
258 : public true_type { };
261 struct __is_integral_helper<int>
262 : public true_type { };
265 struct __is_integral_helper<unsigned int>
266 : public true_type { };
269 struct __is_integral_helper<long>
270 : public true_type { };
273 struct __is_integral_helper<unsigned long>
274 : public true_type { };
277 struct __is_integral_helper<long long>
278 : public true_type { };
281 struct __is_integral_helper<unsigned long long>
282 : public true_type { };
284 // Conditionalizing on __STRICT_ANSI__ here will break any port that
285 // uses one of these types for size_t.
286 #if defined(__GLIBCXX_TYPE_INT_N_0)
288 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0>
289 : public true_type { };
292 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0>
293 : public true_type { };
295 #if defined(__GLIBCXX_TYPE_INT_N_1)
297 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1>
298 : public true_type { };
301 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1>
302 : public true_type { };
304 #if defined(__GLIBCXX_TYPE_INT_N_2)
306 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2>
307 : public true_type { };
310 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2>
311 : public true_type { };
313 #if defined(__GLIBCXX_TYPE_INT_N_3)
315 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3>
316 : public true_type { };
319 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3>
320 : public true_type { };
324 template<typename _Tp>
326 : public __is_integral_helper<typename remove_cv<_Tp>::type>::type
330 struct __is_floating_point_helper
331 : public false_type { };
334 struct __is_floating_point_helper<float>
335 : public true_type { };
338 struct __is_floating_point_helper<double>
339 : public true_type { };
342 struct __is_floating_point_helper<long double>
343 : public true_type { };
345 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
347 struct __is_floating_point_helper<__float128>
348 : public true_type { };
351 /// is_floating_point
352 template<typename _Tp>
353 struct is_floating_point
354 : public __is_floating_point_helper<typename remove_cv<_Tp>::type>::type
360 : public false_type { };
362 template<typename _Tp, std::size_t _Size>
363 struct is_array<_Tp[_Size]>
364 : public true_type { };
366 template<typename _Tp>
367 struct is_array<_Tp[]>
368 : public true_type { };
371 struct __is_pointer_helper
372 : public false_type { };
374 template<typename _Tp>
375 struct __is_pointer_helper<_Tp*>
376 : public true_type { };
379 template<typename _Tp>
381 : public __is_pointer_helper<typename remove_cv<_Tp>::type>::type
384 /// is_lvalue_reference
386 struct is_lvalue_reference
387 : public false_type { };
389 template<typename _Tp>
390 struct is_lvalue_reference<_Tp&>
391 : public true_type { };
393 /// is_rvalue_reference
395 struct is_rvalue_reference
396 : public false_type { };
398 template<typename _Tp>
399 struct is_rvalue_reference<_Tp&&>
400 : public true_type { };
406 struct __is_member_object_pointer_helper
407 : public false_type { };
409 template<typename _Tp, typename _Cp>
410 struct __is_member_object_pointer_helper<_Tp _Cp::*>
411 : public integral_constant<bool, !is_function<_Tp>::value> { };
413 /// is_member_object_pointer
414 template<typename _Tp>
415 struct is_member_object_pointer
416 : public __is_member_object_pointer_helper<
417 typename remove_cv<_Tp>::type>::type
421 struct __is_member_function_pointer_helper
422 : public false_type { };
424 template<typename _Tp, typename _Cp>
425 struct __is_member_function_pointer_helper<_Tp _Cp::*>
426 : public integral_constant<bool, is_function<_Tp>::value> { };
428 /// is_member_function_pointer
429 template<typename _Tp>
430 struct is_member_function_pointer
431 : public __is_member_function_pointer_helper<
432 typename remove_cv<_Tp>::type>::type
436 template<typename _Tp>
438 : public integral_constant<bool, __is_enum(_Tp)>
442 template<typename _Tp>
444 : public integral_constant<bool, __is_union(_Tp)>
448 template<typename _Tp>
450 : public integral_constant<bool, __is_class(_Tp)>
456 : public false_type { };
458 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
459 struct is_function<_Res(_ArgTypes...) _GLIBCXX_NOEXCEPT_QUAL>
460 : public true_type { };
462 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
463 struct is_function<_Res(_ArgTypes...) & _GLIBCXX_NOEXCEPT_QUAL>
464 : public true_type { };
466 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
467 struct is_function<_Res(_ArgTypes...) && _GLIBCXX_NOEXCEPT_QUAL>
468 : public true_type { };
470 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
471 struct is_function<_Res(_ArgTypes......) _GLIBCXX_NOEXCEPT_QUAL>
472 : public true_type { };
474 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
475 struct is_function<_Res(_ArgTypes......) & _GLIBCXX_NOEXCEPT_QUAL>
476 : public true_type { };
478 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
479 struct is_function<_Res(_ArgTypes......) && _GLIBCXX_NOEXCEPT_QUAL>
480 : public true_type { };
482 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
483 struct is_function<_Res(_ArgTypes...) const _GLIBCXX_NOEXCEPT_QUAL>
484 : public true_type { };
486 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
487 struct is_function<_Res(_ArgTypes...) const & _GLIBCXX_NOEXCEPT_QUAL>
488 : public true_type { };
490 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
491 struct is_function<_Res(_ArgTypes...) const && _GLIBCXX_NOEXCEPT_QUAL>
492 : public true_type { };
494 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
495 struct is_function<_Res(_ArgTypes......) const _GLIBCXX_NOEXCEPT_QUAL>
496 : public true_type { };
498 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
499 struct is_function<_Res(_ArgTypes......) const & _GLIBCXX_NOEXCEPT_QUAL>
500 : public true_type { };
502 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
503 struct is_function<_Res(_ArgTypes......) const && _GLIBCXX_NOEXCEPT_QUAL>
504 : public true_type { };
506 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
507 struct is_function<_Res(_ArgTypes...) volatile _GLIBCXX_NOEXCEPT_QUAL>
508 : public true_type { };
510 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
511 struct is_function<_Res(_ArgTypes...) volatile & _GLIBCXX_NOEXCEPT_QUAL>
512 : public true_type { };
514 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
515 struct is_function<_Res(_ArgTypes...) volatile && _GLIBCXX_NOEXCEPT_QUAL>
516 : public true_type { };
518 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
519 struct is_function<_Res(_ArgTypes......) volatile _GLIBCXX_NOEXCEPT_QUAL>
520 : public true_type { };
522 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
523 struct is_function<_Res(_ArgTypes......) volatile & _GLIBCXX_NOEXCEPT_QUAL>
524 : public true_type { };
526 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
527 struct is_function<_Res(_ArgTypes......) volatile && _GLIBCXX_NOEXCEPT_QUAL>
528 : public true_type { };
530 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
531 struct is_function<_Res(_ArgTypes...) const volatile _GLIBCXX_NOEXCEPT_QUAL>
532 : public true_type { };
534 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
535 struct is_function<_Res(_ArgTypes...) const volatile & _GLIBCXX_NOEXCEPT_QUAL>
536 : public true_type { };
538 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
539 struct is_function<_Res(_ArgTypes...) const volatile && _GLIBCXX_NOEXCEPT_QUAL>
540 : public true_type { };
542 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
543 struct is_function<_Res(_ArgTypes......) const volatile _GLIBCXX_NOEXCEPT_QUAL>
544 : public true_type { };
546 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
547 struct is_function<_Res(_ArgTypes......) const volatile & _GLIBCXX_NOEXCEPT_QUAL>
548 : public true_type { };
550 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
551 struct is_function<_Res(_ArgTypes......) const volatile && _GLIBCXX_NOEXCEPT_QUAL>
552 : public true_type { };
554 #define __cpp_lib_is_null_pointer 201309
557 struct __is_null_pointer_helper
558 : public false_type { };
561 struct __is_null_pointer_helper<std::nullptr_t>
562 : public true_type { };
564 /// is_null_pointer (LWG 2247).
565 template<typename _Tp>
566 struct is_null_pointer
567 : public __is_null_pointer_helper<typename remove_cv<_Tp>::type>::type
570 /// __is_nullptr_t (extension).
571 template<typename _Tp>
572 struct __is_nullptr_t
573 : public is_null_pointer<_Tp>
576 // Composite type categories.
579 template<typename _Tp>
581 : public __or_<is_lvalue_reference<_Tp>,
582 is_rvalue_reference<_Tp>>::type
586 template<typename _Tp>
588 : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type
592 template<typename _Tp>
593 struct is_fundamental
594 : public __or_<is_arithmetic<_Tp>, is_void<_Tp>,
595 is_null_pointer<_Tp>>::type
599 template<typename _Tp>
601 : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
606 struct is_member_pointer;
609 template<typename _Tp>
611 : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
612 is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
616 template<typename _Tp>
618 : public integral_constant<bool, !is_fundamental<_Tp>::value> { };
620 template<typename _Tp>
621 struct __is_member_pointer_helper
622 : public false_type { };
624 template<typename _Tp, typename _Cp>
625 struct __is_member_pointer_helper<_Tp _Cp::*>
626 : public true_type { };
628 /// is_member_pointer
629 template<typename _Tp>
630 struct is_member_pointer
631 : public __is_member_pointer_helper<typename remove_cv<_Tp>::type>::type
634 // Utility to detect referenceable types ([defns.referenceable]).
636 template<typename _Tp>
637 struct __is_referenceable
638 : public __or_<is_object<_Tp>, is_reference<_Tp>>::type
641 template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM>
642 struct __is_referenceable<_Res(_Args...) _GLIBCXX_NOEXCEPT_QUAL>
646 template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM>
647 struct __is_referenceable<_Res(_Args......) _GLIBCXX_NOEXCEPT_QUAL>
656 : public false_type { };
658 template<typename _Tp>
659 struct is_const<_Tp const>
660 : public true_type { };
665 : public false_type { };
667 template<typename _Tp>
668 struct is_volatile<_Tp volatile>
669 : public true_type { };
672 template<typename _Tp>
674 : public integral_constant<bool, __is_trivial(_Tp)>
677 // is_trivially_copyable
678 template<typename _Tp>
679 struct is_trivially_copyable
680 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
683 /// is_standard_layout
684 template<typename _Tp>
685 struct is_standard_layout
686 : public integral_constant<bool, __is_standard_layout(_Tp)>
690 // Could use is_standard_layout && is_trivial instead of the builtin.
691 template<typename _Tp>
693 : public integral_constant<bool, __is_pod(_Tp)>
697 template<typename _Tp>
698 struct is_literal_type
699 : public integral_constant<bool, __is_literal_type(_Tp)>
703 template<typename _Tp>
705 : public integral_constant<bool, __is_empty(_Tp)>
709 template<typename _Tp>
710 struct is_polymorphic
711 : public integral_constant<bool, __is_polymorphic(_Tp)>
714 #if __cplusplus >= 201402L
715 #define __cpp_lib_is_final 201402L
717 template<typename _Tp>
719 : public integral_constant<bool, __is_final(_Tp)>
724 template<typename _Tp>
726 : public integral_constant<bool, __is_abstract(_Tp)>
729 template<typename _Tp,
730 bool = is_arithmetic<_Tp>::value>
731 struct __is_signed_helper
732 : public false_type { };
734 template<typename _Tp>
735 struct __is_signed_helper<_Tp, true>
736 : public integral_constant<bool, _Tp(-1) < _Tp(0)>
740 template<typename _Tp>
742 : public __is_signed_helper<_Tp>::type
746 template<typename _Tp>
748 : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>
752 // Destructible and constructible type properties.
755 * @brief Utility to simplify expressions used in unevaluated operands
759 template<typename _Tp, typename _Up = _Tp&&>
763 template<typename _Tp>
767 template<typename _Tp>
768 auto declval() noexcept -> decltype(__declval<_Tp>(0));
770 template<typename, unsigned = 0>
774 struct remove_all_extents;
776 template<typename _Tp>
777 struct __is_array_known_bounds
778 : public integral_constant<bool, (extent<_Tp>::value > 0)>
781 template<typename _Tp>
782 struct __is_array_unknown_bounds
783 : public __and_<is_array<_Tp>, __not_<extent<_Tp>>>
786 // In N3290 is_destructible does not say anything about function
787 // types and abstract types, see LWG 2049. This implementation
788 // describes function types as non-destructible and all complete
789 // object types as destructible, iff the explicit destructor
790 // call expression is wellformed.
791 struct __do_is_destructible_impl
793 template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())>
794 static true_type __test(int);
797 static false_type __test(...);
800 template<typename _Tp>
801 struct __is_destructible_impl
802 : public __do_is_destructible_impl
804 typedef decltype(__test<_Tp>(0)) type;
807 template<typename _Tp,
808 bool = __or_<is_void<_Tp>,
809 __is_array_unknown_bounds<_Tp>,
810 is_function<_Tp>>::value,
811 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
812 struct __is_destructible_safe;
814 template<typename _Tp>
815 struct __is_destructible_safe<_Tp, false, false>
816 : public __is_destructible_impl<typename
817 remove_all_extents<_Tp>::type>::type
820 template<typename _Tp>
821 struct __is_destructible_safe<_Tp, true, false>
822 : public false_type { };
824 template<typename _Tp>
825 struct __is_destructible_safe<_Tp, false, true>
826 : public true_type { };
829 template<typename _Tp>
830 struct is_destructible
831 : public __is_destructible_safe<_Tp>::type
834 // is_nothrow_destructible requires that is_destructible is
835 // satisfied as well. We realize that by mimicing the
836 // implementation of is_destructible but refer to noexcept(expr)
837 // instead of decltype(expr).
838 struct __do_is_nt_destructible_impl
840 template<typename _Tp>
841 static integral_constant<bool, noexcept(declval<_Tp&>().~_Tp())>
845 static false_type __test(...);
848 template<typename _Tp>
849 struct __is_nt_destructible_impl
850 : public __do_is_nt_destructible_impl
852 typedef decltype(__test<_Tp>(0)) type;
855 template<typename _Tp,
856 bool = __or_<is_void<_Tp>,
857 __is_array_unknown_bounds<_Tp>,
858 is_function<_Tp>>::value,
859 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
860 struct __is_nt_destructible_safe;
862 template<typename _Tp>
863 struct __is_nt_destructible_safe<_Tp, false, false>
864 : public __is_nt_destructible_impl<typename
865 remove_all_extents<_Tp>::type>::type
868 template<typename _Tp>
869 struct __is_nt_destructible_safe<_Tp, true, false>
870 : public false_type { };
872 template<typename _Tp>
873 struct __is_nt_destructible_safe<_Tp, false, true>
874 : public true_type { };
876 /// is_nothrow_destructible
877 template<typename _Tp>
878 struct is_nothrow_destructible
879 : public __is_nt_destructible_safe<_Tp>::type
882 struct __do_is_default_constructible_impl
884 template<typename _Tp, typename = decltype(_Tp())>
885 static true_type __test(int);
888 static false_type __test(...);
891 template<typename _Tp>
892 struct __is_default_constructible_impl
893 : public __do_is_default_constructible_impl
895 typedef decltype(__test<_Tp>(0)) type;
898 template<typename _Tp>
899 struct __is_default_constructible_atom
900 : public __and_<__not_<is_void<_Tp>>,
901 __is_default_constructible_impl<_Tp>>
904 template<typename _Tp, bool = is_array<_Tp>::value>
905 struct __is_default_constructible_safe;
907 // The following technique is a workaround for a current core language
908 // restriction, which does not allow for array types to occur in
909 // functional casts of the form T(). Complete arrays can be default-
910 // constructed, if the element type is default-constructible, but
911 // arrays with unknown bounds are not.
912 template<typename _Tp>
913 struct __is_default_constructible_safe<_Tp, true>
914 : public __and_<__is_array_known_bounds<_Tp>,
915 __is_default_constructible_atom<typename
916 remove_all_extents<_Tp>::type>>
919 template<typename _Tp>
920 struct __is_default_constructible_safe<_Tp, false>
921 : public __is_default_constructible_atom<_Tp>::type
924 /// is_default_constructible
925 template<typename _Tp>
926 struct is_default_constructible
927 : public __is_default_constructible_safe<_Tp>::type
931 template<typename _Tp, typename... _Args>
932 struct is_constructible
933 : public __bool_constant<__is_constructible(_Tp, _Args...)>
936 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
937 struct __is_copy_constructible_impl;
939 template<typename _Tp>
940 struct __is_copy_constructible_impl<_Tp, false>
941 : public false_type { };
943 template<typename _Tp>
944 struct __is_copy_constructible_impl<_Tp, true>
945 : public is_constructible<_Tp, const _Tp&>
948 /// is_copy_constructible
949 template<typename _Tp>
950 struct is_copy_constructible
951 : public __is_copy_constructible_impl<_Tp>
954 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
955 struct __is_move_constructible_impl;
957 template<typename _Tp>
958 struct __is_move_constructible_impl<_Tp, false>
959 : public false_type { };
961 template<typename _Tp>
962 struct __is_move_constructible_impl<_Tp, true>
963 : public is_constructible<_Tp, _Tp&&>
966 /// is_move_constructible
967 template<typename _Tp>
968 struct is_move_constructible
969 : public __is_move_constructible_impl<_Tp>
972 template<typename _Tp>
973 struct __is_nt_default_constructible_atom
974 : public integral_constant<bool, noexcept(_Tp())>
977 template<typename _Tp, bool = is_array<_Tp>::value>
978 struct __is_nt_default_constructible_impl;
980 template<typename _Tp>
981 struct __is_nt_default_constructible_impl<_Tp, true>
982 : public __and_<__is_array_known_bounds<_Tp>,
983 __is_nt_default_constructible_atom<typename
984 remove_all_extents<_Tp>::type>>
987 template<typename _Tp>
988 struct __is_nt_default_constructible_impl<_Tp, false>
989 : public __is_nt_default_constructible_atom<_Tp>
992 /// is_nothrow_default_constructible
993 template<typename _Tp>
994 struct is_nothrow_default_constructible
995 : public __and_<is_default_constructible<_Tp>,
996 __is_nt_default_constructible_impl<_Tp>>
999 template<typename _Tp, typename... _Args>
1000 struct __is_nt_constructible_impl
1001 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
1004 template<typename _Tp, typename _Arg>
1005 struct __is_nt_constructible_impl<_Tp, _Arg>
1006 : public integral_constant<bool,
1007 noexcept(static_cast<_Tp>(declval<_Arg>()))>
1010 template<typename _Tp>
1011 struct __is_nt_constructible_impl<_Tp>
1012 : public is_nothrow_default_constructible<_Tp>
1015 /// is_nothrow_constructible
1016 template<typename _Tp, typename... _Args>
1017 struct is_nothrow_constructible
1018 : public __and_<is_constructible<_Tp, _Args...>,
1019 __is_nt_constructible_impl<_Tp, _Args...>>
1022 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1023 struct __is_nothrow_copy_constructible_impl;
1025 template<typename _Tp>
1026 struct __is_nothrow_copy_constructible_impl<_Tp, false>
1027 : public false_type { };
1029 template<typename _Tp>
1030 struct __is_nothrow_copy_constructible_impl<_Tp, true>
1031 : public is_nothrow_constructible<_Tp, const _Tp&>
1034 /// is_nothrow_copy_constructible
1035 template<typename _Tp>
1036 struct is_nothrow_copy_constructible
1037 : public __is_nothrow_copy_constructible_impl<_Tp>
1040 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1041 struct __is_nothrow_move_constructible_impl;
1043 template<typename _Tp>
1044 struct __is_nothrow_move_constructible_impl<_Tp, false>
1045 : public false_type { };
1047 template<typename _Tp>
1048 struct __is_nothrow_move_constructible_impl<_Tp, true>
1049 : public is_nothrow_constructible<_Tp, _Tp&&>
1052 /// is_nothrow_move_constructible
1053 template<typename _Tp>
1054 struct is_nothrow_move_constructible
1055 : public __is_nothrow_move_constructible_impl<_Tp>
1059 template<typename _Tp, typename _Up>
1060 struct is_assignable
1061 : public __bool_constant<__is_assignable(_Tp, _Up)>
1064 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1065 struct __is_copy_assignable_impl;
1067 template<typename _Tp>
1068 struct __is_copy_assignable_impl<_Tp, false>
1069 : public false_type { };
1071 template<typename _Tp>
1072 struct __is_copy_assignable_impl<_Tp, true>
1073 : public is_assignable<_Tp&, const _Tp&>
1076 /// is_copy_assignable
1077 template<typename _Tp>
1078 struct is_copy_assignable
1079 : public __is_copy_assignable_impl<_Tp>
1082 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1083 struct __is_move_assignable_impl;
1085 template<typename _Tp>
1086 struct __is_move_assignable_impl<_Tp, false>
1087 : public false_type { };
1089 template<typename _Tp>
1090 struct __is_move_assignable_impl<_Tp, true>
1091 : public is_assignable<_Tp&, _Tp&&>
1094 /// is_move_assignable
1095 template<typename _Tp>
1096 struct is_move_assignable
1097 : public __is_move_assignable_impl<_Tp>
1100 template<typename _Tp, typename _Up>
1101 struct __is_nt_assignable_impl
1102 : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())>
1105 /// is_nothrow_assignable
1106 template<typename _Tp, typename _Up>
1107 struct is_nothrow_assignable
1108 : public __and_<is_assignable<_Tp, _Up>,
1109 __is_nt_assignable_impl<_Tp, _Up>>
1112 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1113 struct __is_nt_copy_assignable_impl;
1115 template<typename _Tp>
1116 struct __is_nt_copy_assignable_impl<_Tp, false>
1117 : public false_type { };
1119 template<typename _Tp>
1120 struct __is_nt_copy_assignable_impl<_Tp, true>
1121 : public is_nothrow_assignable<_Tp&, const _Tp&>
1124 /// is_nothrow_copy_assignable
1125 template<typename _Tp>
1126 struct is_nothrow_copy_assignable
1127 : public __is_nt_copy_assignable_impl<_Tp>
1130 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1131 struct __is_nt_move_assignable_impl;
1133 template<typename _Tp>
1134 struct __is_nt_move_assignable_impl<_Tp, false>
1135 : public false_type { };
1137 template<typename _Tp>
1138 struct __is_nt_move_assignable_impl<_Tp, true>
1139 : public is_nothrow_assignable<_Tp&, _Tp&&>
1142 /// is_nothrow_move_assignable
1143 template<typename _Tp>
1144 struct is_nothrow_move_assignable
1145 : public __is_nt_move_assignable_impl<_Tp>
1148 /// is_trivially_constructible
1149 template<typename _Tp, typename... _Args>
1150 struct is_trivially_constructible
1151 : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)>
1154 /// is_trivially_default_constructible
1155 template<typename _Tp>
1156 struct is_trivially_default_constructible
1157 : public is_trivially_constructible<_Tp>::type
1160 struct __do_is_implicitly_default_constructible_impl
1162 template <typename _Tp>
1163 static void __helper(const _Tp&);
1165 template <typename _Tp>
1166 static true_type __test(const _Tp&,
1167 decltype(__helper<const _Tp&>({}))* = 0);
1169 static false_type __test(...);
1172 template<typename _Tp>
1173 struct __is_implicitly_default_constructible_impl
1174 : public __do_is_implicitly_default_constructible_impl
1176 typedef decltype(__test(declval<_Tp>())) type;
1179 template<typename _Tp>
1180 struct __is_implicitly_default_constructible_safe
1181 : public __is_implicitly_default_constructible_impl<_Tp>::type
1184 template <typename _Tp>
1185 struct __is_implicitly_default_constructible
1186 : public __and_<is_default_constructible<_Tp>,
1187 __is_implicitly_default_constructible_safe<_Tp>>
1190 /// is_trivially_copy_constructible
1192 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1193 struct __is_trivially_copy_constructible_impl;
1195 template<typename _Tp>
1196 struct __is_trivially_copy_constructible_impl<_Tp, false>
1197 : public false_type { };
1199 template<typename _Tp>
1200 struct __is_trivially_copy_constructible_impl<_Tp, true>
1201 : public __and_<is_copy_constructible<_Tp>,
1202 integral_constant<bool,
1203 __is_trivially_constructible(_Tp, const _Tp&)>>
1206 template<typename _Tp>
1207 struct is_trivially_copy_constructible
1208 : public __is_trivially_copy_constructible_impl<_Tp>
1211 /// is_trivially_move_constructible
1213 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1214 struct __is_trivially_move_constructible_impl;
1216 template<typename _Tp>
1217 struct __is_trivially_move_constructible_impl<_Tp, false>
1218 : public false_type { };
1220 template<typename _Tp>
1221 struct __is_trivially_move_constructible_impl<_Tp, true>
1222 : public __and_<is_move_constructible<_Tp>,
1223 integral_constant<bool,
1224 __is_trivially_constructible(_Tp, _Tp&&)>>
1227 template<typename _Tp>
1228 struct is_trivially_move_constructible
1229 : public __is_trivially_move_constructible_impl<_Tp>
1232 /// is_trivially_assignable
1233 template<typename _Tp, typename _Up>
1234 struct is_trivially_assignable
1235 : public __bool_constant<__is_trivially_assignable(_Tp, _Up)>
1238 /// is_trivially_copy_assignable
1240 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1241 struct __is_trivially_copy_assignable_impl;
1243 template<typename _Tp>
1244 struct __is_trivially_copy_assignable_impl<_Tp, false>
1245 : public false_type { };
1247 template<typename _Tp>
1248 struct __is_trivially_copy_assignable_impl<_Tp, true>
1249 : public __and_<is_copy_assignable<_Tp>,
1250 integral_constant<bool,
1251 __is_trivially_assignable(_Tp&, const _Tp&)>>
1254 template<typename _Tp>
1255 struct is_trivially_copy_assignable
1256 : public __is_trivially_copy_assignable_impl<_Tp>
1259 /// is_trivially_move_assignable
1261 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1262 struct __is_trivially_move_assignable_impl;
1264 template<typename _Tp>
1265 struct __is_trivially_move_assignable_impl<_Tp, false>
1266 : public false_type { };
1268 template<typename _Tp>
1269 struct __is_trivially_move_assignable_impl<_Tp, true>
1270 : public __and_<is_move_assignable<_Tp>,
1271 integral_constant<bool,
1272 __is_trivially_assignable(_Tp&, _Tp&&)>>
1275 template<typename _Tp>
1276 struct is_trivially_move_assignable
1277 : public __is_trivially_move_assignable_impl<_Tp>
1280 /// is_trivially_destructible
1281 template<typename _Tp>
1282 struct is_trivially_destructible
1283 : public __and_<is_destructible<_Tp>, integral_constant<bool,
1284 __has_trivial_destructor(_Tp)>>
1288 /// has_virtual_destructor
1289 template<typename _Tp>
1290 struct has_virtual_destructor
1291 : public integral_constant<bool, __has_virtual_destructor(_Tp)>
1295 // type property queries.
1298 template<typename _Tp>
1300 : public integral_constant<std::size_t, __alignof__(_Tp)> { };
1305 : public integral_constant<std::size_t, 0> { };
1307 template<typename _Tp, std::size_t _Size>
1308 struct rank<_Tp[_Size]>
1309 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1311 template<typename _Tp>
1313 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1316 template<typename, unsigned _Uint>
1318 : public integral_constant<std::size_t, 0> { };
1320 template<typename _Tp, unsigned _Uint, std::size_t _Size>
1321 struct extent<_Tp[_Size], _Uint>
1322 : public integral_constant<std::size_t,
1323 _Uint == 0 ? _Size : extent<_Tp,
1327 template<typename _Tp, unsigned _Uint>
1328 struct extent<_Tp[], _Uint>
1329 : public integral_constant<std::size_t,
1330 _Uint == 0 ? 0 : extent<_Tp,
1338 template<typename, typename>
1340 : public false_type { };
1342 template<typename _Tp>
1343 struct is_same<_Tp, _Tp>
1344 : public true_type { };
1347 template<typename _Base, typename _Derived>
1349 : public integral_constant<bool, __is_base_of(_Base, _Derived)>
1352 template<typename _From, typename _To,
1353 bool = __or_<is_void<_From>, is_function<_To>,
1354 is_array<_To>>::value>
1355 struct __is_convertible_helper
1356 { typedef typename is_void<_To>::type type; };
1358 template<typename _From, typename _To>
1359 class __is_convertible_helper<_From, _To, false>
1361 template<typename _To1>
1362 static void __test_aux(_To1);
1364 template<typename _From1, typename _To1,
1365 typename = decltype(__test_aux<_To1>(std::declval<_From1>()))>
1369 template<typename, typename>
1374 typedef decltype(__test<_From, _To>(0)) type;
1379 template<typename _From, typename _To>
1380 struct is_convertible
1381 : public __is_convertible_helper<_From, _To>::type
1385 // Const-volatile modifications.
1388 template<typename _Tp>
1390 { typedef _Tp type; };
1392 template<typename _Tp>
1393 struct remove_const<_Tp const>
1394 { typedef _Tp type; };
1397 template<typename _Tp>
1398 struct remove_volatile
1399 { typedef _Tp type; };
1401 template<typename _Tp>
1402 struct remove_volatile<_Tp volatile>
1403 { typedef _Tp type; };
1406 template<typename _Tp>
1410 remove_const<typename remove_volatile<_Tp>::type>::type type;
1414 template<typename _Tp>
1416 { typedef _Tp const type; };
1419 template<typename _Tp>
1421 { typedef _Tp volatile type; };
1424 template<typename _Tp>
1428 add_const<typename add_volatile<_Tp>::type>::type type;
1431 #if __cplusplus > 201103L
1433 #define __cpp_lib_transformation_trait_aliases 201304
1435 /// Alias template for remove_const
1436 template<typename _Tp>
1437 using remove_const_t = typename remove_const<_Tp>::type;
1439 /// Alias template for remove_volatile
1440 template<typename _Tp>
1441 using remove_volatile_t = typename remove_volatile<_Tp>::type;
1443 /// Alias template for remove_cv
1444 template<typename _Tp>
1445 using remove_cv_t = typename remove_cv<_Tp>::type;
1447 /// Alias template for add_const
1448 template<typename _Tp>
1449 using add_const_t = typename add_const<_Tp>::type;
1451 /// Alias template for add_volatile
1452 template<typename _Tp>
1453 using add_volatile_t = typename add_volatile<_Tp>::type;
1455 /// Alias template for add_cv
1456 template<typename _Tp>
1457 using add_cv_t = typename add_cv<_Tp>::type;
1460 // Reference transformations.
1462 /// remove_reference
1463 template<typename _Tp>
1464 struct remove_reference
1465 { typedef _Tp type; };
1467 template<typename _Tp>
1468 struct remove_reference<_Tp&>
1469 { typedef _Tp type; };
1471 template<typename _Tp>
1472 struct remove_reference<_Tp&&>
1473 { typedef _Tp type; };
1475 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1476 struct __add_lvalue_reference_helper
1477 { typedef _Tp type; };
1479 template<typename _Tp>
1480 struct __add_lvalue_reference_helper<_Tp, true>
1481 { typedef _Tp& type; };
1483 /// add_lvalue_reference
1484 template<typename _Tp>
1485 struct add_lvalue_reference
1486 : public __add_lvalue_reference_helper<_Tp>
1489 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1490 struct __add_rvalue_reference_helper
1491 { typedef _Tp type; };
1493 template<typename _Tp>
1494 struct __add_rvalue_reference_helper<_Tp, true>
1495 { typedef _Tp&& type; };
1497 /// add_rvalue_reference
1498 template<typename _Tp>
1499 struct add_rvalue_reference
1500 : public __add_rvalue_reference_helper<_Tp>
1503 #if __cplusplus > 201103L
1504 /// Alias template for remove_reference
1505 template<typename _Tp>
1506 using remove_reference_t = typename remove_reference<_Tp>::type;
1508 /// Alias template for add_lvalue_reference
1509 template<typename _Tp>
1510 using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1512 /// Alias template for add_rvalue_reference
1513 template<typename _Tp>
1514 using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1517 // Sign modifications.
1519 // Utility for constructing identically cv-qualified types.
1520 template<typename _Unqualified, bool _IsConst, bool _IsVol>
1521 struct __cv_selector;
1523 template<typename _Unqualified>
1524 struct __cv_selector<_Unqualified, false, false>
1525 { typedef _Unqualified __type; };
1527 template<typename _Unqualified>
1528 struct __cv_selector<_Unqualified, false, true>
1529 { typedef volatile _Unqualified __type; };
1531 template<typename _Unqualified>
1532 struct __cv_selector<_Unqualified, true, false>
1533 { typedef const _Unqualified __type; };
1535 template<typename _Unqualified>
1536 struct __cv_selector<_Unqualified, true, true>
1537 { typedef const volatile _Unqualified __type; };
1539 template<typename _Qualified, typename _Unqualified,
1540 bool _IsConst = is_const<_Qualified>::value,
1541 bool _IsVol = is_volatile<_Qualified>::value>
1542 class __match_cv_qualifiers
1544 typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match;
1547 typedef typename __match::__type __type;
1550 // Utility for finding the unsigned versions of signed integral types.
1551 template<typename _Tp>
1552 struct __make_unsigned
1553 { typedef _Tp __type; };
1556 struct __make_unsigned<char>
1557 { typedef unsigned char __type; };
1560 struct __make_unsigned<signed char>
1561 { typedef unsigned char __type; };
1564 struct __make_unsigned<short>
1565 { typedef unsigned short __type; };
1568 struct __make_unsigned<int>
1569 { typedef unsigned int __type; };
1572 struct __make_unsigned<long>
1573 { typedef unsigned long __type; };
1576 struct __make_unsigned<long long>
1577 { typedef unsigned long long __type; };
1579 #if defined(_GLIBCXX_USE_WCHAR_T) && !defined(__WCHAR_UNSIGNED__)
1581 struct __make_unsigned<wchar_t> : __make_unsigned<__WCHAR_TYPE__>
1585 #if defined(__GLIBCXX_TYPE_INT_N_0)
1587 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0>
1588 { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; };
1590 #if defined(__GLIBCXX_TYPE_INT_N_1)
1592 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1>
1593 { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; };
1595 #if defined(__GLIBCXX_TYPE_INT_N_2)
1597 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2>
1598 { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; };
1600 #if defined(__GLIBCXX_TYPE_INT_N_3)
1602 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3>
1603 { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; };
1606 // Select between integral and enum: not possible to be both.
1607 template<typename _Tp,
1608 bool _IsInt = is_integral<_Tp>::value,
1609 bool _IsEnum = is_enum<_Tp>::value>
1610 class __make_unsigned_selector;
1612 template<typename _Tp>
1613 class __make_unsigned_selector<_Tp, true, false>
1615 typedef __make_unsigned<typename remove_cv<_Tp>::type> __unsignedt;
1616 typedef typename __unsignedt::__type __unsigned_type;
1617 typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
1620 typedef typename __cv_unsigned::__type __type;
1623 template<typename _Tp>
1624 class __make_unsigned_selector<_Tp, false, true>
1626 // With -fshort-enums, an enum may be as small as a char.
1627 typedef unsigned char __smallest;
1628 static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
1629 static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned short);
1630 static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned int);
1631 static const bool __b3 = sizeof(_Tp) <= sizeof(unsigned long);
1632 typedef conditional<__b3, unsigned long, unsigned long long> __cond3;
1633 typedef typename __cond3::type __cond3_type;
1634 typedef conditional<__b2, unsigned int, __cond3_type> __cond2;
1635 typedef typename __cond2::type __cond2_type;
1636 typedef conditional<__b1, unsigned short, __cond2_type> __cond1;
1637 typedef typename __cond1::type __cond1_type;
1639 typedef typename conditional<__b0, __smallest, __cond1_type>::type
1641 typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
1644 typedef typename __cv_unsigned::__type __type;
1647 // Given an integral/enum type, return the corresponding unsigned
1649 // Primary template.
1651 template<typename _Tp>
1652 struct make_unsigned
1653 { typedef typename __make_unsigned_selector<_Tp>::__type type; };
1655 // Integral, but don't define.
1657 struct make_unsigned<bool>;
1660 // Utility for finding the signed versions of unsigned integral types.
1661 template<typename _Tp>
1662 struct __make_signed
1663 { typedef _Tp __type; };
1666 struct __make_signed<char>
1667 { typedef signed char __type; };
1670 struct __make_signed<unsigned char>
1671 { typedef signed char __type; };
1674 struct __make_signed<unsigned short>
1675 { typedef signed short __type; };
1678 struct __make_signed<unsigned int>
1679 { typedef signed int __type; };
1682 struct __make_signed<unsigned long>
1683 { typedef signed long __type; };
1686 struct __make_signed<unsigned long long>
1687 { typedef signed long long __type; };
1689 #if defined(_GLIBCXX_USE_WCHAR_T) && defined(__WCHAR_UNSIGNED__)
1691 struct __make_signed<wchar_t> : __make_signed<__WCHAR_TYPE__>
1695 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
1697 struct __make_signed<char16_t> : __make_signed<uint_least16_t>
1700 struct __make_signed<char32_t> : __make_signed<uint_least32_t>
1704 #if defined(__GLIBCXX_TYPE_INT_N_0)
1706 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0>
1707 { typedef __GLIBCXX_TYPE_INT_N_0 __type; };
1709 #if defined(__GLIBCXX_TYPE_INT_N_1)
1711 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1>
1712 { typedef __GLIBCXX_TYPE_INT_N_1 __type; };
1714 #if defined(__GLIBCXX_TYPE_INT_N_2)
1716 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2>
1717 { typedef __GLIBCXX_TYPE_INT_N_2 __type; };
1719 #if defined(__GLIBCXX_TYPE_INT_N_3)
1721 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3>
1722 { typedef __GLIBCXX_TYPE_INT_N_3 __type; };
1725 // Select between integral and enum: not possible to be both.
1726 template<typename _Tp,
1727 bool _IsInt = is_integral<_Tp>::value,
1728 bool _IsEnum = is_enum<_Tp>::value>
1729 class __make_signed_selector;
1731 template<typename _Tp>
1732 class __make_signed_selector<_Tp, true, false>
1734 typedef __make_signed<typename remove_cv<_Tp>::type> __signedt;
1735 typedef typename __signedt::__type __signed_type;
1736 typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed;
1739 typedef typename __cv_signed::__type __type;
1742 template<typename _Tp>
1743 class __make_signed_selector<_Tp, false, true>
1745 typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type;
1748 typedef typename __make_signed_selector<__unsigned_type>::__type __type;
1751 // Given an integral/enum type, return the corresponding signed
1753 // Primary template.
1755 template<typename _Tp>
1757 { typedef typename __make_signed_selector<_Tp>::__type type; };
1759 // Integral, but don't define.
1761 struct make_signed<bool>;
1763 #if __cplusplus > 201103L
1764 /// Alias template for make_signed
1765 template<typename _Tp>
1766 using make_signed_t = typename make_signed<_Tp>::type;
1768 /// Alias template for make_unsigned
1769 template<typename _Tp>
1770 using make_unsigned_t = typename make_unsigned<_Tp>::type;
1773 // Array modifications.
1776 template<typename _Tp>
1777 struct remove_extent
1778 { typedef _Tp type; };
1780 template<typename _Tp, std::size_t _Size>
1781 struct remove_extent<_Tp[_Size]>
1782 { typedef _Tp type; };
1784 template<typename _Tp>
1785 struct remove_extent<_Tp[]>
1786 { typedef _Tp type; };
1788 /// remove_all_extents
1789 template<typename _Tp>
1790 struct remove_all_extents
1791 { typedef _Tp type; };
1793 template<typename _Tp, std::size_t _Size>
1794 struct remove_all_extents<_Tp[_Size]>
1795 { typedef typename remove_all_extents<_Tp>::type type; };
1797 template<typename _Tp>
1798 struct remove_all_extents<_Tp[]>
1799 { typedef typename remove_all_extents<_Tp>::type type; };
1801 #if __cplusplus > 201103L
1802 /// Alias template for remove_extent
1803 template<typename _Tp>
1804 using remove_extent_t = typename remove_extent<_Tp>::type;
1806 /// Alias template for remove_all_extents
1807 template<typename _Tp>
1808 using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1811 // Pointer modifications.
1813 template<typename _Tp, typename>
1814 struct __remove_pointer_helper
1815 { typedef _Tp type; };
1817 template<typename _Tp, typename _Up>
1818 struct __remove_pointer_helper<_Tp, _Up*>
1819 { typedef _Up type; };
1822 template<typename _Tp>
1823 struct remove_pointer
1824 : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
1828 template<typename _Tp, bool = __or_<__is_referenceable<_Tp>,
1829 is_void<_Tp>>::value>
1830 struct __add_pointer_helper
1831 { typedef _Tp type; };
1833 template<typename _Tp>
1834 struct __add_pointer_helper<_Tp, true>
1835 { typedef typename remove_reference<_Tp>::type* type; };
1837 template<typename _Tp>
1839 : public __add_pointer_helper<_Tp>
1842 #if __cplusplus > 201103L
1843 /// Alias template for remove_pointer
1844 template<typename _Tp>
1845 using remove_pointer_t = typename remove_pointer<_Tp>::type;
1847 /// Alias template for add_pointer
1848 template<typename _Tp>
1849 using add_pointer_t = typename add_pointer<_Tp>::type;
1852 template<std::size_t _Len>
1853 struct __aligned_storage_msa
1857 unsigned char __data[_Len];
1858 struct __attribute__((__aligned__)) { } __align;
1863 * @brief Alignment type.
1865 * The value of _Align is a default-alignment which shall be the
1866 * most stringent alignment requirement for any C++ object type
1867 * whose size is no greater than _Len (3.9). The member typedef
1868 * type shall be a POD type suitable for use as uninitialized
1869 * storage for any object whose size is at most _Len and whose
1870 * alignment is a divisor of _Align.
1872 template<std::size_t _Len, std::size_t _Align =
1873 __alignof__(typename __aligned_storage_msa<_Len>::__type)>
1874 struct aligned_storage
1878 unsigned char __data[_Len];
1879 struct __attribute__((__aligned__((_Align)))) { } __align;
1883 template <typename... _Types>
1884 struct __strictest_alignment
1886 static const size_t _S_alignment = 0;
1887 static const size_t _S_size = 0;
1890 template <typename _Tp, typename... _Types>
1891 struct __strictest_alignment<_Tp, _Types...>
1893 static const size_t _S_alignment =
1894 alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment
1895 ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment;
1896 static const size_t _S_size =
1897 sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size
1898 ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size;
1902 * @brief Provide aligned storage for types.
1904 * [meta.trans.other]
1906 * Provides aligned storage for any of the provided types of at
1909 * @see aligned_storage
1911 template <size_t _Len, typename... _Types>
1912 struct aligned_union
1915 static_assert(sizeof...(_Types) != 0, "At least one type is required");
1917 using __strictest = __strictest_alignment<_Types...>;
1918 static const size_t _S_len = _Len > __strictest::_S_size
1919 ? _Len : __strictest::_S_size;
1921 /// The value of the strictest alignment of _Types.
1922 static const size_t alignment_value = __strictest::_S_alignment;
1924 typedef typename aligned_storage<_S_len, alignment_value>::type type;
1927 template <size_t _Len, typename... _Types>
1928 const size_t aligned_union<_Len, _Types...>::alignment_value;
1930 // Decay trait for arrays and functions, used for perfect forwarding
1931 // in make_pair, make_tuple, etc.
1932 template<typename _Up,
1933 bool _IsArray = is_array<_Up>::value,
1934 bool _IsFunction = is_function<_Up>::value>
1935 struct __decay_selector;
1938 template<typename _Up>
1939 struct __decay_selector<_Up, false, false>
1940 { typedef typename remove_cv<_Up>::type __type; };
1942 template<typename _Up>
1943 struct __decay_selector<_Up, true, false>
1944 { typedef typename remove_extent<_Up>::type* __type; };
1946 template<typename _Up>
1947 struct __decay_selector<_Up, false, true>
1948 { typedef typename add_pointer<_Up>::type __type; };
1951 template<typename _Tp>
1954 typedef typename remove_reference<_Tp>::type __remove_type;
1957 typedef typename __decay_selector<__remove_type>::__type type;
1960 template<typename _Tp>
1961 class reference_wrapper;
1963 // Helper which adds a reference to a type when given a reference_wrapper
1964 template<typename _Tp>
1965 struct __strip_reference_wrapper
1970 template<typename _Tp>
1971 struct __strip_reference_wrapper<reference_wrapper<_Tp> >
1973 typedef _Tp& __type;
1976 template<typename _Tp>
1977 struct __decay_and_strip
1979 typedef typename __strip_reference_wrapper<
1980 typename decay<_Tp>::type>::__type __type;
1984 // Primary template.
1985 /// Define a member typedef @c type only if a boolean constant is true.
1986 template<bool, typename _Tp = void>
1990 // Partial specialization for true.
1991 template<typename _Tp>
1992 struct enable_if<true, _Tp>
1993 { typedef _Tp type; };
1995 template<typename... _Cond>
1996 using _Require = typename enable_if<__and_<_Cond...>::value>::type;
1998 // Primary template.
1999 /// Define a member typedef @c type to one of two argument types.
2000 template<bool _Cond, typename _Iftrue, typename _Iffalse>
2002 { typedef _Iftrue type; };
2004 // Partial specialization for false.
2005 template<typename _Iftrue, typename _Iffalse>
2006 struct conditional<false, _Iftrue, _Iffalse>
2007 { typedef _Iffalse type; };
2010 template<typename... _Tp>
2013 // Sfinae-friendly common_type implementation:
2015 struct __do_common_type_impl
2017 template<typename _Tp, typename _Up>
2018 static __success_type<typename decay<decltype
2019 (true ? std::declval<_Tp>()
2020 : std::declval<_Up>())>::type> _S_test(int);
2022 template<typename, typename>
2023 static __failure_type _S_test(...);
2026 template<typename _Tp, typename _Up>
2027 struct __common_type_impl
2028 : private __do_common_type_impl
2030 typedef decltype(_S_test<_Tp, _Up>(0)) type;
2033 struct __do_member_type_wrapper
2035 template<typename _Tp>
2036 static __success_type<typename _Tp::type> _S_test(int);
2039 static __failure_type _S_test(...);
2042 template<typename _Tp>
2043 struct __member_type_wrapper
2044 : private __do_member_type_wrapper
2046 typedef decltype(_S_test<_Tp>(0)) type;
2049 template<typename _CTp, typename... _Args>
2050 struct __expanded_common_type_wrapper
2052 typedef common_type<typename _CTp::type, _Args...> type;
2055 template<typename... _Args>
2056 struct __expanded_common_type_wrapper<__failure_type, _Args...>
2057 { typedef __failure_type type; };
2059 template<typename _Tp>
2060 struct common_type<_Tp>
2061 { typedef typename decay<_Tp>::type type; };
2063 template<typename _Tp, typename _Up>
2064 struct common_type<_Tp, _Up>
2065 : public __common_type_impl<_Tp, _Up>::type
2068 template<typename _Tp, typename _Up, typename... _Vp>
2069 struct common_type<_Tp, _Up, _Vp...>
2070 : public __expanded_common_type_wrapper<typename __member_type_wrapper<
2071 common_type<_Tp, _Up>>::type, _Vp...>::type
2074 /// The underlying type of an enum.
2075 template<typename _Tp>
2076 struct underlying_type
2078 typedef __underlying_type(_Tp) type;
2081 template<typename _Tp>
2082 struct __declval_protector
2084 static const bool __stop = false;
2087 template<typename _Tp>
2088 auto declval() noexcept -> decltype(__declval<_Tp>(0))
2090 static_assert(__declval_protector<_Tp>::__stop,
2091 "declval() must not be used!");
2092 return __declval<_Tp>(0);
2096 template<typename _Signature>
2099 // Sfinae-friendly result_of implementation:
2101 #define __cpp_lib_result_of_sfinae 201210
2103 struct __invoke_memfun_ref { };
2104 struct __invoke_memfun_deref { };
2105 struct __invoke_memobj_ref { };
2106 struct __invoke_memobj_deref { };
2107 struct __invoke_other { };
2109 // Associate a tag type with a specialization of __success_type.
2110 template<typename _Tp, typename _Tag>
2111 struct __result_of_success : __success_type<_Tp>
2112 { using __invoke_type = _Tag; };
2114 // [func.require] paragraph 1 bullet 1:
2115 struct __result_of_memfun_ref_impl
2117 template<typename _Fp, typename _Tp1, typename... _Args>
2118 static __result_of_success<decltype(
2119 (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...)
2120 ), __invoke_memfun_ref> _S_test(int);
2122 template<typename...>
2123 static __failure_type _S_test(...);
2126 template<typename _MemPtr, typename _Arg, typename... _Args>
2127 struct __result_of_memfun_ref
2128 : private __result_of_memfun_ref_impl
2130 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2133 // [func.require] paragraph 1 bullet 2:
2134 struct __result_of_memfun_deref_impl
2136 template<typename _Fp, typename _Tp1, typename... _Args>
2137 static __result_of_success<decltype(
2138 ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...)
2139 ), __invoke_memfun_deref> _S_test(int);
2141 template<typename...>
2142 static __failure_type _S_test(...);
2145 template<typename _MemPtr, typename _Arg, typename... _Args>
2146 struct __result_of_memfun_deref
2147 : private __result_of_memfun_deref_impl
2149 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2152 // [func.require] paragraph 1 bullet 3:
2153 struct __result_of_memobj_ref_impl
2155 template<typename _Fp, typename _Tp1>
2156 static __result_of_success<decltype(
2157 std::declval<_Tp1>().*std::declval<_Fp>()
2158 ), __invoke_memobj_ref> _S_test(int);
2160 template<typename, typename>
2161 static __failure_type _S_test(...);
2164 template<typename _MemPtr, typename _Arg>
2165 struct __result_of_memobj_ref
2166 : private __result_of_memobj_ref_impl
2168 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2171 // [func.require] paragraph 1 bullet 4:
2172 struct __result_of_memobj_deref_impl
2174 template<typename _Fp, typename _Tp1>
2175 static __result_of_success<decltype(
2176 (*std::declval<_Tp1>()).*std::declval<_Fp>()
2177 ), __invoke_memobj_deref> _S_test(int);
2179 template<typename, typename>
2180 static __failure_type _S_test(...);
2183 template<typename _MemPtr, typename _Arg>
2184 struct __result_of_memobj_deref
2185 : private __result_of_memobj_deref_impl
2187 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2190 template<typename _MemPtr, typename _Arg>
2191 struct __result_of_memobj;
2193 template<typename _Res, typename _Class, typename _Arg>
2194 struct __result_of_memobj<_Res _Class::*, _Arg>
2196 typedef typename remove_cv<typename remove_reference<
2197 _Arg>::type>::type _Argval;
2198 typedef _Res _Class::* _MemPtr;
2199 typedef typename conditional<__or_<is_same<_Argval, _Class>,
2200 is_base_of<_Class, _Argval>>::value,
2201 __result_of_memobj_ref<_MemPtr, _Arg>,
2202 __result_of_memobj_deref<_MemPtr, _Arg>
2206 template<typename _MemPtr, typename _Arg, typename... _Args>
2207 struct __result_of_memfun;
2209 template<typename _Res, typename _Class, typename _Arg, typename... _Args>
2210 struct __result_of_memfun<_Res _Class::*, _Arg, _Args...>
2212 typedef typename remove_cv<typename remove_reference<
2213 _Arg>::type>::type _Argval;
2214 typedef _Res _Class::* _MemPtr;
2215 typedef typename conditional<__or_<is_same<_Argval, _Class>,
2216 is_base_of<_Class, _Argval>>::value,
2217 __result_of_memfun_ref<_MemPtr, _Arg, _Args...>,
2218 __result_of_memfun_deref<_MemPtr, _Arg, _Args...>
2222 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2223 // 2219. INVOKE-ing a pointer to member with a reference_wrapper
2224 // as the object expression
2226 // Used by result_of, invoke etc. to unwrap a reference_wrapper.
2227 template<typename _Tp, typename _Up = typename decay<_Tp>::type>
2233 template<typename _Tp, typename _Up>
2234 struct __inv_unwrap<_Tp, reference_wrapper<_Up>>
2239 template<bool, bool, typename _Functor, typename... _ArgTypes>
2240 struct __result_of_impl
2242 typedef __failure_type type;
2245 template<typename _MemPtr, typename _Arg>
2246 struct __result_of_impl<true, false, _MemPtr, _Arg>
2247 : public __result_of_memobj<typename decay<_MemPtr>::type,
2248 typename __inv_unwrap<_Arg>::type>
2251 template<typename _MemPtr, typename _Arg, typename... _Args>
2252 struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...>
2253 : public __result_of_memfun<typename decay<_MemPtr>::type,
2254 typename __inv_unwrap<_Arg>::type, _Args...>
2257 // [func.require] paragraph 1 bullet 5:
2258 struct __result_of_other_impl
2260 template<typename _Fn, typename... _Args>
2261 static __result_of_success<decltype(
2262 std::declval<_Fn>()(std::declval<_Args>()...)
2263 ), __invoke_other> _S_test(int);
2265 template<typename...>
2266 static __failure_type _S_test(...);
2269 template<typename _Functor, typename... _ArgTypes>
2270 struct __result_of_impl<false, false, _Functor, _ArgTypes...>
2271 : private __result_of_other_impl
2273 typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type;
2276 // __invoke_result (std::invoke_result for C++11)
2277 template<typename _Functor, typename... _ArgTypes>
2278 struct __invoke_result
2279 : public __result_of_impl<
2280 is_member_object_pointer<
2281 typename remove_reference<_Functor>::type
2283 is_member_function_pointer<
2284 typename remove_reference<_Functor>::type
2286 _Functor, _ArgTypes...
2290 template<typename _Functor, typename... _ArgTypes>
2291 struct result_of<_Functor(_ArgTypes...)>
2292 : public __invoke_result<_Functor, _ArgTypes...>
2295 #if __cplusplus > 201103L
2296 /// Alias template for aligned_storage
2297 template<size_t _Len, size_t _Align =
2298 __alignof__(typename __aligned_storage_msa<_Len>::__type)>
2299 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
2301 template <size_t _Len, typename... _Types>
2302 using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
2304 /// Alias template for decay
2305 template<typename _Tp>
2306 using decay_t = typename decay<_Tp>::type;
2308 /// Alias template for enable_if
2309 template<bool _Cond, typename _Tp = void>
2310 using enable_if_t = typename enable_if<_Cond, _Tp>::type;
2312 /// Alias template for conditional
2313 template<bool _Cond, typename _Iftrue, typename _Iffalse>
2314 using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type;
2316 /// Alias template for common_type
2317 template<typename... _Tp>
2318 using common_type_t = typename common_type<_Tp...>::type;
2320 /// Alias template for underlying_type
2321 template<typename _Tp>
2322 using underlying_type_t = typename underlying_type<_Tp>::type;
2324 /// Alias template for result_of
2325 template<typename _Tp>
2326 using result_of_t = typename result_of<_Tp>::type;
2329 template<typename...> using __void_t = void;
2331 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
2332 #define __cpp_lib_void_t 201411
2333 /// A metafunction that always yields void, used for detecting valid types.
2334 template<typename...> using void_t = void;
2337 /// Implementation of the detection idiom (negative case).
2338 template<typename _Default, typename _AlwaysVoid,
2339 template<typename...> class _Op, typename... _Args>
2342 using value_t = false_type;
2343 using type = _Default;
2346 /// Implementation of the detection idiom (positive case).
2347 template<typename _Default, template<typename...> class _Op,
2349 struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...>
2351 using value_t = true_type;
2352 using type = _Op<_Args...>;
2355 // Detect whether _Op<_Args...> is a valid type, use _Default if not.
2356 template<typename _Default, template<typename...> class _Op,
2358 using __detected_or = __detector<_Default, void, _Op, _Args...>;
2360 // _Op<_Args...> if that is a valid type, otherwise _Default.
2361 template<typename _Default, template<typename...> class _Op,
2363 using __detected_or_t
2364 = typename __detected_or<_Default, _Op, _Args...>::type;
2366 /// @} group metaprogramming
2369 * Use SFINAE to determine if the type _Tp has a publicly-accessible
2370 * member type _NTYPE.
2372 #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \
2373 template<typename _Tp, typename = __void_t<>> \
2374 struct __has_##_NTYPE \
2377 template<typename _Tp> \
2378 struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \
2382 template <typename _Tp>
2383 struct __is_swappable;
2385 template <typename _Tp>
2386 struct __is_nothrow_swappable;
2388 template<typename... _Elements>
2392 struct __is_tuple_like_impl : false_type
2395 template<typename... _Tps>
2396 struct __is_tuple_like_impl<tuple<_Tps...>> : true_type
2399 // Internal type trait that allows us to sfinae-protect tuple_cat.
2400 template<typename _Tp>
2401 struct __is_tuple_like
2402 : public __is_tuple_like_impl<typename remove_cv<
2403 typename remove_reference<_Tp>::type>::type>::type
2406 template<typename _Tp>
2408 typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>,
2409 is_move_constructible<_Tp>,
2410 is_move_assignable<_Tp>>::value>::type
2412 noexcept(__and_<is_nothrow_move_constructible<_Tp>,
2413 is_nothrow_move_assignable<_Tp>>::value);
2415 template<typename _Tp, size_t _Nm>
2417 typename enable_if<__is_swappable<_Tp>::value>::type
2418 swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
2419 noexcept(__is_nothrow_swappable<_Tp>::value);
2421 namespace __swappable_details {
2424 struct __do_is_swappable_impl
2426 template<typename _Tp, typename
2427 = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))>
2428 static true_type __test(int);
2431 static false_type __test(...);
2434 struct __do_is_nothrow_swappable_impl
2436 template<typename _Tp>
2437 static __bool_constant<
2438 noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))
2442 static false_type __test(...);
2445 } // namespace __swappable_details
2447 template<typename _Tp>
2448 struct __is_swappable_impl
2449 : public __swappable_details::__do_is_swappable_impl
2451 typedef decltype(__test<_Tp>(0)) type;
2454 template<typename _Tp>
2455 struct __is_nothrow_swappable_impl
2456 : public __swappable_details::__do_is_nothrow_swappable_impl
2458 typedef decltype(__test<_Tp>(0)) type;
2461 template<typename _Tp>
2462 struct __is_swappable
2463 : public __is_swappable_impl<_Tp>::type
2466 template<typename _Tp>
2467 struct __is_nothrow_swappable
2468 : public __is_nothrow_swappable_impl<_Tp>::type
2471 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
2472 #define __cpp_lib_is_swappable 201603
2473 /// Metafunctions used for detecting swappable types: p0185r1
2476 template<typename _Tp>
2478 : public __is_swappable_impl<_Tp>::type
2481 /// is_nothrow_swappable
2482 template<typename _Tp>
2483 struct is_nothrow_swappable
2484 : public __is_nothrow_swappable_impl<_Tp>::type
2487 #if __cplusplus >= 201402L
2489 template<typename _Tp>
2490 _GLIBCXX17_INLINE constexpr bool is_swappable_v =
2491 is_swappable<_Tp>::value;
2493 /// is_nothrow_swappable_v
2494 template<typename _Tp>
2495 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v =
2496 is_nothrow_swappable<_Tp>::value;
2497 #endif // __cplusplus >= 201402L
2499 namespace __swappable_with_details {
2502 struct __do_is_swappable_with_impl
2504 template<typename _Tp, typename _Up, typename
2505 = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())),
2507 = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))>
2508 static true_type __test(int);
2510 template<typename, typename>
2511 static false_type __test(...);
2514 struct __do_is_nothrow_swappable_with_impl
2516 template<typename _Tp, typename _Up>
2517 static __bool_constant<
2518 noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))
2520 noexcept(swap(std::declval<_Up>(), std::declval<_Tp>()))
2523 template<typename, typename>
2524 static false_type __test(...);
2527 } // namespace __swappable_with_details
2529 template<typename _Tp, typename _Up>
2530 struct __is_swappable_with_impl
2531 : public __swappable_with_details::__do_is_swappable_with_impl
2533 typedef decltype(__test<_Tp, _Up>(0)) type;
2536 // Optimization for the homogenous lvalue case, not required:
2537 template<typename _Tp>
2538 struct __is_swappable_with_impl<_Tp&, _Tp&>
2539 : public __swappable_details::__do_is_swappable_impl
2541 typedef decltype(__test<_Tp&>(0)) type;
2544 template<typename _Tp, typename _Up>
2545 struct __is_nothrow_swappable_with_impl
2546 : public __swappable_with_details::__do_is_nothrow_swappable_with_impl
2548 typedef decltype(__test<_Tp, _Up>(0)) type;
2551 // Optimization for the homogenous lvalue case, not required:
2552 template<typename _Tp>
2553 struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&>
2554 : public __swappable_details::__do_is_nothrow_swappable_impl
2556 typedef decltype(__test<_Tp&>(0)) type;
2559 /// is_swappable_with
2560 template<typename _Tp, typename _Up>
2561 struct is_swappable_with
2562 : public __is_swappable_with_impl<_Tp, _Up>::type
2565 /// is_nothrow_swappable_with
2566 template<typename _Tp, typename _Up>
2567 struct is_nothrow_swappable_with
2568 : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type
2571 #if __cplusplus >= 201402L
2572 /// is_swappable_with_v
2573 template<typename _Tp, typename _Up>
2574 _GLIBCXX17_INLINE constexpr bool is_swappable_with_v =
2575 is_swappable_with<_Tp, _Up>::value;
2577 /// is_nothrow_swappable_with_v
2578 template<typename _Tp, typename _Up>
2579 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v =
2580 is_nothrow_swappable_with<_Tp, _Up>::value;
2581 #endif // __cplusplus >= 201402L
2583 #endif// c++1z or gnu++11
2585 // __is_invocable (std::is_invocable for C++11)
2587 template<typename _Result, typename _Ret, typename = void>
2588 struct __is_invocable_impl : false_type { };
2590 template<typename _Result, typename _Ret>
2591 struct __is_invocable_impl<_Result, _Ret, __void_t<typename _Result::type>>
2592 : __or_<is_void<_Ret>, is_convertible<typename _Result::type, _Ret>>::type
2595 template<typename _Fn, typename... _ArgTypes>
2596 struct __is_invocable
2597 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
2600 template<typename _Fn, typename _Tp, typename... _Args>
2601 constexpr bool __call_is_nt(__invoke_memfun_ref)
2603 using _Up = typename __inv_unwrap<_Tp>::type;
2604 return noexcept((std::declval<_Up>().*std::declval<_Fn>())(
2605 std::declval<_Args>()...));
2608 template<typename _Fn, typename _Tp, typename... _Args>
2609 constexpr bool __call_is_nt(__invoke_memfun_deref)
2611 return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())(
2612 std::declval<_Args>()...));
2615 template<typename _Fn, typename _Tp>
2616 constexpr bool __call_is_nt(__invoke_memobj_ref)
2618 using _Up = typename __inv_unwrap<_Tp>::type;
2619 return noexcept(std::declval<_Up>().*std::declval<_Fn>());
2622 template<typename _Fn, typename _Tp>
2623 constexpr bool __call_is_nt(__invoke_memobj_deref)
2625 return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>());
2628 template<typename _Fn, typename... _Args>
2629 constexpr bool __call_is_nt(__invoke_other)
2631 return noexcept(std::declval<_Fn>()(std::declval<_Args>()...));
2634 template<typename _Result, typename _Fn, typename... _Args>
2635 struct __call_is_nothrow
2637 std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{})
2641 template<typename _Fn, typename... _Args>
2642 using __call_is_nothrow_
2643 = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>;
2645 // __is_nothrow_invocable (std::is_nothrow_invocable for C++11)
2646 template<typename _Fn, typename... _Args>
2647 struct __is_nothrow_invocable
2648 : __and_<__is_invocable<_Fn, _Args...>,
2649 __call_is_nothrow_<_Fn, _Args...>>::type
2653 __nonesuch() = delete;
2654 ~__nonesuch() = delete;
2655 __nonesuch(__nonesuch const&) = delete;
2656 void operator=(__nonesuch const&) = delete;
2659 #if __cplusplus >= 201703L
2660 # define __cpp_lib_is_invocable 201703
2662 /// std::invoke_result
2663 template<typename _Functor, typename... _ArgTypes>
2664 struct invoke_result
2665 : public __invoke_result<_Functor, _ArgTypes...>
2668 /// std::invoke_result_t
2669 template<typename _Fn, typename... _Args>
2670 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
2672 /// std::is_invocable
2673 template<typename _Fn, typename... _ArgTypes>
2675 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
2678 /// std::is_invocable_r
2679 template<typename _Ret, typename _Fn, typename... _ArgTypes>
2680 struct is_invocable_r
2681 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type
2684 /// std::is_nothrow_invocable
2685 template<typename _Fn, typename... _ArgTypes>
2686 struct is_nothrow_invocable
2687 : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>,
2688 __call_is_nothrow_<_Fn, _ArgTypes...>>::type
2691 template<typename _Result, typename _Ret, typename = void>
2692 struct __is_nt_invocable_impl : false_type { };
2694 template<typename _Result, typename _Ret>
2695 struct __is_nt_invocable_impl<_Result, _Ret,
2696 __void_t<typename _Result::type>>
2697 : __or_<is_void<_Ret>,
2698 __and_<is_convertible<typename _Result::type, _Ret>,
2699 is_nothrow_constructible<_Ret, typename _Result::type>>>
2702 /// std::is_nothrow_invocable_r
2703 template<typename _Ret, typename _Fn, typename... _ArgTypes>
2704 struct is_nothrow_invocable_r
2705 : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>,
2706 __call_is_nothrow_<_Fn, _ArgTypes...>>::type
2709 /// std::is_invocable_v
2710 template<typename _Fn, typename... _Args>
2711 inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
2713 /// std::is_nothrow_invocable_v
2714 template<typename _Fn, typename... _Args>
2715 inline constexpr bool is_nothrow_invocable_v
2716 = is_nothrow_invocable<_Fn, _Args...>::value;
2718 /// std::is_invocable_r_v
2719 template<typename _Fn, typename... _Args>
2720 inline constexpr bool is_invocable_r_v
2721 = is_invocable_r<_Fn, _Args...>::value;
2723 /// std::is_nothrow_invocable_r_v
2724 template<typename _Fn, typename... _Args>
2725 inline constexpr bool is_nothrow_invocable_r_v
2726 = is_nothrow_invocable_r<_Fn, _Args...>::value;
2729 #if __cplusplus >= 201703L
2730 # define __cpp_lib_type_trait_variable_templates 201510L
2731 template <typename _Tp>
2732 inline constexpr bool is_void_v = is_void<_Tp>::value;
2733 template <typename _Tp>
2734 inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
2735 template <typename _Tp>
2736 inline constexpr bool is_integral_v = is_integral<_Tp>::value;
2737 template <typename _Tp>
2738 inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
2739 template <typename _Tp>
2740 inline constexpr bool is_array_v = is_array<_Tp>::value;
2741 template <typename _Tp>
2742 inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
2743 template <typename _Tp>
2744 inline constexpr bool is_lvalue_reference_v =
2745 is_lvalue_reference<_Tp>::value;
2746 template <typename _Tp>
2747 inline constexpr bool is_rvalue_reference_v =
2748 is_rvalue_reference<_Tp>::value;
2749 template <typename _Tp>
2750 inline constexpr bool is_member_object_pointer_v =
2751 is_member_object_pointer<_Tp>::value;
2752 template <typename _Tp>
2753 inline constexpr bool is_member_function_pointer_v =
2754 is_member_function_pointer<_Tp>::value;
2755 template <typename _Tp>
2756 inline constexpr bool is_enum_v = is_enum<_Tp>::value;
2757 template <typename _Tp>
2758 inline constexpr bool is_union_v = is_union<_Tp>::value;
2759 template <typename _Tp>
2760 inline constexpr bool is_class_v = is_class<_Tp>::value;
2761 template <typename _Tp>
2762 inline constexpr bool is_function_v = is_function<_Tp>::value;
2763 template <typename _Tp>
2764 inline constexpr bool is_reference_v = is_reference<_Tp>::value;
2765 template <typename _Tp>
2766 inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
2767 template <typename _Tp>
2768 inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
2769 template <typename _Tp>
2770 inline constexpr bool is_object_v = is_object<_Tp>::value;
2771 template <typename _Tp>
2772 inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
2773 template <typename _Tp>
2774 inline constexpr bool is_compound_v = is_compound<_Tp>::value;
2775 template <typename _Tp>
2776 inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
2777 template <typename _Tp>
2778 inline constexpr bool is_const_v = is_const<_Tp>::value;
2779 template <typename _Tp>
2780 inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
2781 template <typename _Tp>
2782 inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;
2783 template <typename _Tp>
2784 inline constexpr bool is_trivially_copyable_v =
2785 is_trivially_copyable<_Tp>::value;
2786 template <typename _Tp>
2787 inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
2788 template <typename _Tp>
2789 inline constexpr bool is_pod_v = is_pod<_Tp>::value;
2790 template <typename _Tp>
2791 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
2792 template <typename _Tp>
2793 inline constexpr bool is_empty_v = is_empty<_Tp>::value;
2794 template <typename _Tp>
2795 inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
2796 template <typename _Tp>
2797 inline constexpr bool is_abstract_v = is_abstract<_Tp>::value;
2798 template <typename _Tp>
2799 inline constexpr bool is_final_v = is_final<_Tp>::value;
2800 template <typename _Tp>
2801 inline constexpr bool is_signed_v = is_signed<_Tp>::value;
2802 template <typename _Tp>
2803 inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
2804 template <typename _Tp, typename... _Args>
2805 inline constexpr bool is_constructible_v =
2806 is_constructible<_Tp, _Args...>::value;
2807 template <typename _Tp>
2808 inline constexpr bool is_default_constructible_v =
2809 is_default_constructible<_Tp>::value;
2810 template <typename _Tp>
2811 inline constexpr bool is_copy_constructible_v =
2812 is_copy_constructible<_Tp>::value;
2813 template <typename _Tp>
2814 inline constexpr bool is_move_constructible_v =
2815 is_move_constructible<_Tp>::value;
2816 template <typename _Tp, typename _Up>
2817 inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value;
2818 template <typename _Tp>
2819 inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
2820 template <typename _Tp>
2821 inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
2822 template <typename _Tp>
2823 inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
2824 template <typename _Tp, typename... _Args>
2825 inline constexpr bool is_trivially_constructible_v =
2826 is_trivially_constructible<_Tp, _Args...>::value;
2827 template <typename _Tp>
2828 inline constexpr bool is_trivially_default_constructible_v =
2829 is_trivially_default_constructible<_Tp>::value;
2830 template <typename _Tp>
2831 inline constexpr bool is_trivially_copy_constructible_v =
2832 is_trivially_copy_constructible<_Tp>::value;
2833 template <typename _Tp>
2834 inline constexpr bool is_trivially_move_constructible_v =
2835 is_trivially_move_constructible<_Tp>::value;
2836 template <typename _Tp, typename _Up>
2837 inline constexpr bool is_trivially_assignable_v =
2838 is_trivially_assignable<_Tp, _Up>::value;
2839 template <typename _Tp>
2840 inline constexpr bool is_trivially_copy_assignable_v =
2841 is_trivially_copy_assignable<_Tp>::value;
2842 template <typename _Tp>
2843 inline constexpr bool is_trivially_move_assignable_v =
2844 is_trivially_move_assignable<_Tp>::value;
2845 template <typename _Tp>
2846 inline constexpr bool is_trivially_destructible_v =
2847 is_trivially_destructible<_Tp>::value;
2848 template <typename _Tp, typename... _Args>
2849 inline constexpr bool is_nothrow_constructible_v =
2850 is_nothrow_constructible<_Tp, _Args...>::value;
2851 template <typename _Tp>
2852 inline constexpr bool is_nothrow_default_constructible_v =
2853 is_nothrow_default_constructible<_Tp>::value;
2854 template <typename _Tp>
2855 inline constexpr bool is_nothrow_copy_constructible_v =
2856 is_nothrow_copy_constructible<_Tp>::value;
2857 template <typename _Tp>
2858 inline constexpr bool is_nothrow_move_constructible_v =
2859 is_nothrow_move_constructible<_Tp>::value;
2860 template <typename _Tp, typename _Up>
2861 inline constexpr bool is_nothrow_assignable_v =
2862 is_nothrow_assignable<_Tp, _Up>::value;
2863 template <typename _Tp>
2864 inline constexpr bool is_nothrow_copy_assignable_v =
2865 is_nothrow_copy_assignable<_Tp>::value;
2866 template <typename _Tp>
2867 inline constexpr bool is_nothrow_move_assignable_v =
2868 is_nothrow_move_assignable<_Tp>::value;
2869 template <typename _Tp>
2870 inline constexpr bool is_nothrow_destructible_v =
2871 is_nothrow_destructible<_Tp>::value;
2872 template <typename _Tp>
2873 inline constexpr bool has_virtual_destructor_v =
2874 has_virtual_destructor<_Tp>::value;
2875 template <typename _Tp>
2876 inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
2877 template <typename _Tp>
2878 inline constexpr size_t rank_v = rank<_Tp>::value;
2879 template <typename _Tp, unsigned _Idx = 0>
2880 inline constexpr size_t extent_v = extent<_Tp, _Idx>::value;
2881 template <typename _Tp, typename _Up>
2882 inline constexpr bool is_same_v = is_same<_Tp, _Up>::value;
2883 template <typename _Base, typename _Derived>
2884 inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
2885 template <typename _From, typename _To>
2886 inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
2889 # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
2890 #elif defined(__is_identifier)
2891 // For non-GNU compilers:
2892 # if ! __is_identifier(__has_unique_object_representations)
2893 # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
2897 #ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
2898 # define __cpp_lib_has_unique_object_representations 201606
2899 /// has_unique_object_representations
2900 template<typename _Tp>
2901 struct has_unique_object_representations
2902 : bool_constant<__has_unique_object_representations(
2903 remove_cv_t<remove_all_extents_t<_Tp>>
2907 template<typename _Tp>
2908 inline constexpr bool has_unique_object_representations_v
2909 = has_unique_object_representations<_Tp>::value;
2911 #undef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
2914 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
2915 #elif defined(__is_identifier)
2916 // For non-GNU compilers:
2917 # if ! __is_identifier(__is_aggregate)
2918 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
2922 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
2923 #define __cpp_lib_is_aggregate 201703
2925 template<typename _Tp>
2927 : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> { };
2930 template<typename _Tp>
2931 inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
2933 #undef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
2937 #if __cplusplus > 201703L
2941 little = __ORDER_LITTLE_ENDIAN__,
2942 big = __ORDER_BIG_ENDIAN__,
2943 native = __BYTE_ORDER__
2947 _GLIBCXX_END_NAMESPACE_VERSION
2952 #endif // _GLIBCXX_TYPE_TRAITS