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 namespace std _GLIBCXX_VISIBILITY(default)
42 _GLIBCXX_BEGIN_NAMESPACE_VERSION
45 * @defgroup metaprogramming Metaprogramming
48 * Template utilities for compile-time introspection and modification,
49 * including type classification traits, type property inspection traits
50 * and type transformation traits.
56 template<typename _Tp, _Tp __v>
57 struct integral_constant
59 static constexpr _Tp value = __v;
60 typedef _Tp value_type;
61 typedef integral_constant<_Tp, __v> type;
62 constexpr operator value_type() const noexcept { return value; }
63 #if __cplusplus > 201103L
65 #define __cpp_lib_integral_constant_callable 201304
67 constexpr value_type operator()() const noexcept { return value; }
71 template<typename _Tp, _Tp __v>
72 constexpr _Tp integral_constant<_Tp, __v>::value;
74 /// The type used as a compile-time boolean with true value.
75 typedef integral_constant<bool, true> true_type;
77 /// The type used as a compile-time boolean with false value.
78 typedef integral_constant<bool, false> false_type;
81 using __bool_constant = integral_constant<bool, __v>;
83 #if __cplusplus > 201402L
84 # define __cpp_lib_bool_constant 201505
86 using bool_constant = integral_constant<bool, __v>;
89 // Meta programming helper types.
91 template<bool, typename, typename>
102 template<typename _B1>
107 template<typename _B1, typename _B2>
108 struct __or_<_B1, _B2>
109 : public conditional<_B1::value, _B1, _B2>::type
112 template<typename _B1, typename _B2, typename _B3, typename... _Bn>
113 struct __or_<_B1, _B2, _B3, _Bn...>
114 : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type
117 template<typename...>
125 template<typename _B1>
130 template<typename _B1, typename _B2>
131 struct __and_<_B1, _B2>
132 : public conditional<_B1::value, _B2, _B1>::type
135 template<typename _B1, typename _B2, typename _B3, typename... _Bn>
136 struct __and_<_B1, _B2, _B3, _Bn...>
137 : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type
140 template<typename _Pp>
142 : public __bool_constant<!bool(_Pp::value)>
145 #if __cplusplus >= 201703L
147 #define __cpp_lib_logical_traits 201510
149 template<typename... _Bn>
154 template<typename... _Bn>
159 template<typename _Pp>
164 template<typename... _Bn>
165 inline constexpr bool conjunction_v = conjunction<_Bn...>::value;
167 template<typename... _Bn>
168 inline constexpr bool disjunction_v = disjunction<_Bn...>::value;
170 template<typename _Pp>
171 inline constexpr bool negation_v = negation<_Pp>::value;
175 // For several sfinae-friendly trait implementations we transport both the
176 // result information (as the member type) and the failure information (no
177 // member type). This is very similar to std::enable_if, but we cannot use
178 // them, because we need to derive from them as an implementation detail.
180 template<typename _Tp>
181 struct __success_type
182 { typedef _Tp type; };
184 struct __failure_type
187 // Primary type categories.
193 struct __is_void_helper
194 : public false_type { };
197 struct __is_void_helper<void>
198 : public true_type { };
201 template<typename _Tp>
203 : public __is_void_helper<typename remove_cv<_Tp>::type>::type
207 struct __is_integral_helper
208 : public false_type { };
211 struct __is_integral_helper<bool>
212 : public true_type { };
215 struct __is_integral_helper<char>
216 : public true_type { };
219 struct __is_integral_helper<signed char>
220 : public true_type { };
223 struct __is_integral_helper<unsigned char>
224 : public true_type { };
226 #ifdef _GLIBCXX_USE_WCHAR_T
228 struct __is_integral_helper<wchar_t>
229 : public true_type { };
233 struct __is_integral_helper<char16_t>
234 : public true_type { };
237 struct __is_integral_helper<char32_t>
238 : public true_type { };
241 struct __is_integral_helper<short>
242 : public true_type { };
245 struct __is_integral_helper<unsigned short>
246 : public true_type { };
249 struct __is_integral_helper<int>
250 : public true_type { };
253 struct __is_integral_helper<unsigned int>
254 : public true_type { };
257 struct __is_integral_helper<long>
258 : public true_type { };
261 struct __is_integral_helper<unsigned long>
262 : public true_type { };
265 struct __is_integral_helper<long long>
266 : public true_type { };
269 struct __is_integral_helper<unsigned long long>
270 : public true_type { };
272 // Conditionalizing on __STRICT_ANSI__ here will break any port that
273 // uses one of these types for size_t.
274 #if defined(__GLIBCXX_TYPE_INT_N_0)
276 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0>
277 : public true_type { };
280 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0>
281 : public true_type { };
283 #if defined(__GLIBCXX_TYPE_INT_N_1)
285 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1>
286 : public true_type { };
289 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1>
290 : public true_type { };
292 #if defined(__GLIBCXX_TYPE_INT_N_2)
294 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2>
295 : public true_type { };
298 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2>
299 : public true_type { };
301 #if defined(__GLIBCXX_TYPE_INT_N_3)
303 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3>
304 : public true_type { };
307 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3>
308 : public true_type { };
312 template<typename _Tp>
314 : public __is_integral_helper<typename remove_cv<_Tp>::type>::type
318 struct __is_floating_point_helper
319 : public false_type { };
322 struct __is_floating_point_helper<float>
323 : public true_type { };
326 struct __is_floating_point_helper<double>
327 : public true_type { };
330 struct __is_floating_point_helper<long double>
331 : public true_type { };
333 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
335 struct __is_floating_point_helper<__float128>
336 : public true_type { };
339 /// is_floating_point
340 template<typename _Tp>
341 struct is_floating_point
342 : public __is_floating_point_helper<typename remove_cv<_Tp>::type>::type
348 : public false_type { };
350 template<typename _Tp, std::size_t _Size>
351 struct is_array<_Tp[_Size]>
352 : public true_type { };
354 template<typename _Tp>
355 struct is_array<_Tp[]>
356 : public true_type { };
359 struct __is_pointer_helper
360 : public false_type { };
362 template<typename _Tp>
363 struct __is_pointer_helper<_Tp*>
364 : public true_type { };
367 template<typename _Tp>
369 : public __is_pointer_helper<typename remove_cv<_Tp>::type>::type
372 /// is_lvalue_reference
374 struct is_lvalue_reference
375 : public false_type { };
377 template<typename _Tp>
378 struct is_lvalue_reference<_Tp&>
379 : public true_type { };
381 /// is_rvalue_reference
383 struct is_rvalue_reference
384 : public false_type { };
386 template<typename _Tp>
387 struct is_rvalue_reference<_Tp&&>
388 : public true_type { };
394 struct __is_member_object_pointer_helper
395 : public false_type { };
397 template<typename _Tp, typename _Cp>
398 struct __is_member_object_pointer_helper<_Tp _Cp::*>
399 : public __not_<is_function<_Tp>>::type { };
401 /// is_member_object_pointer
402 template<typename _Tp>
403 struct is_member_object_pointer
404 : public __is_member_object_pointer_helper<
405 typename remove_cv<_Tp>::type>::type
409 struct __is_member_function_pointer_helper
410 : public false_type { };
412 template<typename _Tp, typename _Cp>
413 struct __is_member_function_pointer_helper<_Tp _Cp::*>
414 : public is_function<_Tp>::type { };
416 /// is_member_function_pointer
417 template<typename _Tp>
418 struct is_member_function_pointer
419 : public __is_member_function_pointer_helper<
420 typename remove_cv<_Tp>::type>::type
424 template<typename _Tp>
426 : public integral_constant<bool, __is_enum(_Tp)>
430 template<typename _Tp>
432 : public integral_constant<bool, __is_union(_Tp)>
436 template<typename _Tp>
438 : public integral_constant<bool, __is_class(_Tp)>
444 : public false_type { };
446 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
447 struct is_function<_Res(_ArgTypes...) _GLIBCXX_NOEXCEPT_QUAL>
448 : public true_type { };
450 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
451 struct is_function<_Res(_ArgTypes...) & _GLIBCXX_NOEXCEPT_QUAL>
452 : public true_type { };
454 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
455 struct is_function<_Res(_ArgTypes...) && _GLIBCXX_NOEXCEPT_QUAL>
456 : public true_type { };
458 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
459 struct is_function<_Res(_ArgTypes......) _GLIBCXX_NOEXCEPT_QUAL>
460 : public true_type { };
462 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
463 struct is_function<_Res(_ArgTypes......) & _GLIBCXX_NOEXCEPT_QUAL>
464 : public true_type { };
466 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
467 struct is_function<_Res(_ArgTypes......) && _GLIBCXX_NOEXCEPT_QUAL>
468 : public true_type { };
470 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
471 struct is_function<_Res(_ArgTypes...) const _GLIBCXX_NOEXCEPT_QUAL>
472 : public true_type { };
474 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
475 struct is_function<_Res(_ArgTypes...) const & _GLIBCXX_NOEXCEPT_QUAL>
476 : public true_type { };
478 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
479 struct is_function<_Res(_ArgTypes...) const && _GLIBCXX_NOEXCEPT_QUAL>
480 : public true_type { };
482 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
483 struct is_function<_Res(_ArgTypes......) const _GLIBCXX_NOEXCEPT_QUAL>
484 : public true_type { };
486 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
487 struct is_function<_Res(_ArgTypes......) const & _GLIBCXX_NOEXCEPT_QUAL>
488 : public true_type { };
490 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
491 struct is_function<_Res(_ArgTypes......) const && _GLIBCXX_NOEXCEPT_QUAL>
492 : public true_type { };
494 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
495 struct is_function<_Res(_ArgTypes...) volatile _GLIBCXX_NOEXCEPT_QUAL>
496 : public true_type { };
498 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
499 struct is_function<_Res(_ArgTypes...) volatile & _GLIBCXX_NOEXCEPT_QUAL>
500 : public true_type { };
502 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
503 struct is_function<_Res(_ArgTypes...) volatile && _GLIBCXX_NOEXCEPT_QUAL>
504 : public true_type { };
506 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
507 struct is_function<_Res(_ArgTypes......) volatile _GLIBCXX_NOEXCEPT_QUAL>
508 : public true_type { };
510 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
511 struct is_function<_Res(_ArgTypes......) volatile & _GLIBCXX_NOEXCEPT_QUAL>
512 : public true_type { };
514 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
515 struct is_function<_Res(_ArgTypes......) volatile && _GLIBCXX_NOEXCEPT_QUAL>
516 : public true_type { };
518 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
519 struct is_function<_Res(_ArgTypes...) const volatile _GLIBCXX_NOEXCEPT_QUAL>
520 : public true_type { };
522 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
523 struct is_function<_Res(_ArgTypes...) const volatile & _GLIBCXX_NOEXCEPT_QUAL>
524 : public true_type { };
526 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
527 struct is_function<_Res(_ArgTypes...) const volatile && _GLIBCXX_NOEXCEPT_QUAL>
528 : public true_type { };
530 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
531 struct is_function<_Res(_ArgTypes......) const volatile _GLIBCXX_NOEXCEPT_QUAL>
532 : public true_type { };
534 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
535 struct is_function<_Res(_ArgTypes......) const volatile & _GLIBCXX_NOEXCEPT_QUAL>
536 : public true_type { };
538 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM>
539 struct is_function<_Res(_ArgTypes......) const volatile && _GLIBCXX_NOEXCEPT_QUAL>
540 : public true_type { };
542 #define __cpp_lib_is_null_pointer 201309
545 struct __is_null_pointer_helper
546 : public false_type { };
549 struct __is_null_pointer_helper<std::nullptr_t>
550 : public true_type { };
552 /// is_null_pointer (LWG 2247).
553 template<typename _Tp>
554 struct is_null_pointer
555 : public __is_null_pointer_helper<typename remove_cv<_Tp>::type>::type
558 /// __is_nullptr_t (extension).
559 template<typename _Tp>
560 struct __is_nullptr_t
561 : public is_null_pointer<_Tp>
564 // Composite type categories.
567 template<typename _Tp>
569 : public __or_<is_lvalue_reference<_Tp>,
570 is_rvalue_reference<_Tp>>::type
574 template<typename _Tp>
576 : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type
580 template<typename _Tp>
581 struct is_fundamental
582 : public __or_<is_arithmetic<_Tp>, is_void<_Tp>,
583 is_null_pointer<_Tp>>::type
587 template<typename _Tp>
589 : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
594 struct is_member_pointer;
597 template<typename _Tp>
599 : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
600 is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
604 template<typename _Tp>
606 : public __not_<is_fundamental<_Tp>>::type { };
608 template<typename _Tp>
609 struct __is_member_pointer_helper
610 : public false_type { };
612 template<typename _Tp, typename _Cp>
613 struct __is_member_pointer_helper<_Tp _Cp::*>
614 : public true_type { };
616 /// is_member_pointer
617 template<typename _Tp>
618 struct is_member_pointer
619 : public __is_member_pointer_helper<typename remove_cv<_Tp>::type>::type
622 // Utility to detect referenceable types ([defns.referenceable]).
624 template<typename _Tp>
625 struct __is_referenceable
626 : public __or_<is_object<_Tp>, is_reference<_Tp>>::type
629 template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM>
630 struct __is_referenceable<_Res(_Args...) _GLIBCXX_NOEXCEPT_QUAL>
634 template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM>
635 struct __is_referenceable<_Res(_Args......) _GLIBCXX_NOEXCEPT_QUAL>
644 : public false_type { };
646 template<typename _Tp>
647 struct is_const<_Tp const>
648 : public true_type { };
653 : public false_type { };
655 template<typename _Tp>
656 struct is_volatile<_Tp volatile>
657 : public true_type { };
660 template<typename _Tp>
662 : public integral_constant<bool, __is_trivial(_Tp)>
665 // is_trivially_copyable
666 template<typename _Tp>
667 struct is_trivially_copyable
668 : public integral_constant<bool, __is_trivially_copyable(_Tp)>
671 /// is_standard_layout
672 template<typename _Tp>
673 struct is_standard_layout
674 : public integral_constant<bool, __is_standard_layout(_Tp)>
678 // Could use is_standard_layout && is_trivial instead of the builtin.
679 template<typename _Tp>
681 : public integral_constant<bool, __is_pod(_Tp)>
685 template<typename _Tp>
686 struct is_literal_type
687 : public integral_constant<bool, __is_literal_type(_Tp)>
691 template<typename _Tp>
693 : public integral_constant<bool, __is_empty(_Tp)>
697 template<typename _Tp>
698 struct is_polymorphic
699 : public integral_constant<bool, __is_polymorphic(_Tp)>
702 #if __cplusplus >= 201402L
703 #define __cpp_lib_is_final 201402L
705 template<typename _Tp>
707 : public integral_constant<bool, __is_final(_Tp)>
712 template<typename _Tp>
714 : public integral_constant<bool, __is_abstract(_Tp)>
717 template<typename _Tp,
718 bool = is_arithmetic<_Tp>::value>
719 struct __is_signed_helper
720 : public false_type { };
722 template<typename _Tp>
723 struct __is_signed_helper<_Tp, true>
724 : public integral_constant<bool, _Tp(-1) < _Tp(0)>
728 template<typename _Tp>
730 : public __is_signed_helper<_Tp>::type
734 template<typename _Tp>
736 : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>
740 // Destructible and constructible type properties.
743 * @brief Utility to simplify expressions used in unevaluated operands
747 template<typename _Tp, typename _Up = _Tp&&>
751 template<typename _Tp>
755 template<typename _Tp>
756 auto declval() noexcept -> decltype(__declval<_Tp>(0));
758 template<typename, unsigned = 0>
762 struct remove_all_extents;
764 template<typename _Tp>
765 struct __is_array_known_bounds
766 : public integral_constant<bool, (extent<_Tp>::value > 0)>
769 template<typename _Tp>
770 struct __is_array_unknown_bounds
771 : public __and_<is_array<_Tp>, __not_<extent<_Tp>>>
774 // In N3290 is_destructible does not say anything about function
775 // types and abstract types, see LWG 2049. This implementation
776 // describes function types as non-destructible and all complete
777 // object types as destructible, iff the explicit destructor
778 // call expression is wellformed.
779 struct __do_is_destructible_impl
781 template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())>
782 static true_type __test(int);
785 static false_type __test(...);
788 template<typename _Tp>
789 struct __is_destructible_impl
790 : public __do_is_destructible_impl
792 typedef decltype(__test<_Tp>(0)) type;
795 template<typename _Tp,
796 bool = __or_<is_void<_Tp>,
797 __is_array_unknown_bounds<_Tp>,
798 is_function<_Tp>>::value,
799 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
800 struct __is_destructible_safe;
802 template<typename _Tp>
803 struct __is_destructible_safe<_Tp, false, false>
804 : public __is_destructible_impl<typename
805 remove_all_extents<_Tp>::type>::type
808 template<typename _Tp>
809 struct __is_destructible_safe<_Tp, true, false>
810 : public false_type { };
812 template<typename _Tp>
813 struct __is_destructible_safe<_Tp, false, true>
814 : public true_type { };
817 template<typename _Tp>
818 struct is_destructible
819 : public __is_destructible_safe<_Tp>::type
822 // is_nothrow_destructible requires that is_destructible is
823 // satisfied as well. We realize that by mimicing the
824 // implementation of is_destructible but refer to noexcept(expr)
825 // instead of decltype(expr).
826 struct __do_is_nt_destructible_impl
828 template<typename _Tp>
829 static __bool_constant<noexcept(declval<_Tp&>().~_Tp())>
833 static false_type __test(...);
836 template<typename _Tp>
837 struct __is_nt_destructible_impl
838 : public __do_is_nt_destructible_impl
840 typedef decltype(__test<_Tp>(0)) type;
843 template<typename _Tp,
844 bool = __or_<is_void<_Tp>,
845 __is_array_unknown_bounds<_Tp>,
846 is_function<_Tp>>::value,
847 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
848 struct __is_nt_destructible_safe;
850 template<typename _Tp>
851 struct __is_nt_destructible_safe<_Tp, false, false>
852 : public __is_nt_destructible_impl<typename
853 remove_all_extents<_Tp>::type>::type
856 template<typename _Tp>
857 struct __is_nt_destructible_safe<_Tp, true, false>
858 : public false_type { };
860 template<typename _Tp>
861 struct __is_nt_destructible_safe<_Tp, false, true>
862 : public true_type { };
864 /// is_nothrow_destructible
865 template<typename _Tp>
866 struct is_nothrow_destructible
867 : public __is_nt_destructible_safe<_Tp>::type
870 struct __do_is_default_constructible_impl
872 template<typename _Tp, typename = decltype(_Tp())>
873 static true_type __test(int);
876 static false_type __test(...);
879 template<typename _Tp>
880 struct __is_default_constructible_impl
881 : public __do_is_default_constructible_impl
883 typedef decltype(__test<_Tp>(0)) type;
886 template<typename _Tp>
887 struct __is_default_constructible_atom
888 : public __and_<__not_<is_void<_Tp>>,
889 __is_default_constructible_impl<_Tp>>
892 template<typename _Tp, bool = is_array<_Tp>::value>
893 struct __is_default_constructible_safe;
895 // The following technique is a workaround for a current core language
896 // restriction, which does not allow for array types to occur in
897 // functional casts of the form T(). Complete arrays can be default-
898 // constructed, if the element type is default-constructible, but
899 // arrays with unknown bounds are not.
900 template<typename _Tp>
901 struct __is_default_constructible_safe<_Tp, true>
902 : public __and_<__is_array_known_bounds<_Tp>,
903 __is_default_constructible_atom<typename
904 remove_all_extents<_Tp>::type>>
907 template<typename _Tp>
908 struct __is_default_constructible_safe<_Tp, false>
909 : public __is_default_constructible_atom<_Tp>::type
912 /// is_default_constructible
913 template<typename _Tp>
914 struct is_default_constructible
915 : public __is_default_constructible_safe<_Tp>::type
919 template<typename _Tp, typename... _Args>
920 struct is_constructible
921 : public __bool_constant<__is_constructible(_Tp, _Args...)>
924 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
925 struct __is_copy_constructible_impl;
927 template<typename _Tp>
928 struct __is_copy_constructible_impl<_Tp, false>
929 : public false_type { };
931 template<typename _Tp>
932 struct __is_copy_constructible_impl<_Tp, true>
933 : public is_constructible<_Tp, const _Tp&>
936 /// is_copy_constructible
937 template<typename _Tp>
938 struct is_copy_constructible
939 : public __is_copy_constructible_impl<_Tp>
942 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
943 struct __is_move_constructible_impl;
945 template<typename _Tp>
946 struct __is_move_constructible_impl<_Tp, false>
947 : public false_type { };
949 template<typename _Tp>
950 struct __is_move_constructible_impl<_Tp, true>
951 : public is_constructible<_Tp, _Tp&&>
954 /// is_move_constructible
955 template<typename _Tp>
956 struct is_move_constructible
957 : public __is_move_constructible_impl<_Tp>
960 template<typename _Tp>
961 struct __is_nt_default_constructible_atom
962 : public integral_constant<bool, noexcept(_Tp())>
965 template<typename _Tp, bool = is_array<_Tp>::value>
966 struct __is_nt_default_constructible_impl;
968 template<typename _Tp>
969 struct __is_nt_default_constructible_impl<_Tp, true>
970 : public __and_<__is_array_known_bounds<_Tp>,
971 __is_nt_default_constructible_atom<typename
972 remove_all_extents<_Tp>::type>>
975 template<typename _Tp>
976 struct __is_nt_default_constructible_impl<_Tp, false>
977 : public __is_nt_default_constructible_atom<_Tp>
980 /// is_nothrow_default_constructible
981 template<typename _Tp>
982 struct is_nothrow_default_constructible
983 : public __and_<is_default_constructible<_Tp>,
984 __is_nt_default_constructible_impl<_Tp>>
987 template<typename _Tp, typename... _Args>
988 struct __is_nt_constructible_impl
989 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
992 template<typename _Tp, typename _Arg>
993 struct __is_nt_constructible_impl<_Tp, _Arg>
994 : public integral_constant<bool,
995 noexcept(static_cast<_Tp>(declval<_Arg>()))>
998 template<typename _Tp>
999 struct __is_nt_constructible_impl<_Tp>
1000 : public is_nothrow_default_constructible<_Tp>
1003 /// is_nothrow_constructible
1004 template<typename _Tp, typename... _Args>
1005 struct is_nothrow_constructible
1006 : public __and_<is_constructible<_Tp, _Args...>,
1007 __is_nt_constructible_impl<_Tp, _Args...>>
1010 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1011 struct __is_nothrow_copy_constructible_impl;
1013 template<typename _Tp>
1014 struct __is_nothrow_copy_constructible_impl<_Tp, false>
1015 : public false_type { };
1017 template<typename _Tp>
1018 struct __is_nothrow_copy_constructible_impl<_Tp, true>
1019 : public is_nothrow_constructible<_Tp, const _Tp&>
1022 /// is_nothrow_copy_constructible
1023 template<typename _Tp>
1024 struct is_nothrow_copy_constructible
1025 : public __is_nothrow_copy_constructible_impl<_Tp>
1028 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1029 struct __is_nothrow_move_constructible_impl;
1031 template<typename _Tp>
1032 struct __is_nothrow_move_constructible_impl<_Tp, false>
1033 : public false_type { };
1035 template<typename _Tp>
1036 struct __is_nothrow_move_constructible_impl<_Tp, true>
1037 : public is_nothrow_constructible<_Tp, _Tp&&>
1040 /// is_nothrow_move_constructible
1041 template<typename _Tp>
1042 struct is_nothrow_move_constructible
1043 : public __is_nothrow_move_constructible_impl<_Tp>
1047 template<typename _Tp, typename _Up>
1048 struct is_assignable
1049 : public __bool_constant<__is_assignable(_Tp, _Up)>
1052 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1053 struct __is_copy_assignable_impl;
1055 template<typename _Tp>
1056 struct __is_copy_assignable_impl<_Tp, false>
1057 : public false_type { };
1059 template<typename _Tp>
1060 struct __is_copy_assignable_impl<_Tp, true>
1061 : public is_assignable<_Tp&, const _Tp&>
1064 /// is_copy_assignable
1065 template<typename _Tp>
1066 struct is_copy_assignable
1067 : public __is_copy_assignable_impl<_Tp>
1070 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1071 struct __is_move_assignable_impl;
1073 template<typename _Tp>
1074 struct __is_move_assignable_impl<_Tp, false>
1075 : public false_type { };
1077 template<typename _Tp>
1078 struct __is_move_assignable_impl<_Tp, true>
1079 : public is_assignable<_Tp&, _Tp&&>
1082 /// is_move_assignable
1083 template<typename _Tp>
1084 struct is_move_assignable
1085 : public __is_move_assignable_impl<_Tp>
1088 template<typename _Tp, typename _Up>
1089 struct __is_nt_assignable_impl
1090 : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())>
1093 /// is_nothrow_assignable
1094 template<typename _Tp, typename _Up>
1095 struct is_nothrow_assignable
1096 : public __and_<is_assignable<_Tp, _Up>,
1097 __is_nt_assignable_impl<_Tp, _Up>>
1100 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1101 struct __is_nt_copy_assignable_impl;
1103 template<typename _Tp>
1104 struct __is_nt_copy_assignable_impl<_Tp, false>
1105 : public false_type { };
1107 template<typename _Tp>
1108 struct __is_nt_copy_assignable_impl<_Tp, true>
1109 : public is_nothrow_assignable<_Tp&, const _Tp&>
1112 /// is_nothrow_copy_assignable
1113 template<typename _Tp>
1114 struct is_nothrow_copy_assignable
1115 : public __is_nt_copy_assignable_impl<_Tp>
1118 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1119 struct __is_nt_move_assignable_impl;
1121 template<typename _Tp>
1122 struct __is_nt_move_assignable_impl<_Tp, false>
1123 : public false_type { };
1125 template<typename _Tp>
1126 struct __is_nt_move_assignable_impl<_Tp, true>
1127 : public is_nothrow_assignable<_Tp&, _Tp&&>
1130 /// is_nothrow_move_assignable
1131 template<typename _Tp>
1132 struct is_nothrow_move_assignable
1133 : public __is_nt_move_assignable_impl<_Tp>
1136 /// is_trivially_constructible
1137 template<typename _Tp, typename... _Args>
1138 struct is_trivially_constructible
1139 : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)>
1142 /// is_trivially_default_constructible
1143 template<typename _Tp>
1144 struct is_trivially_default_constructible
1145 : public is_trivially_constructible<_Tp>::type
1148 struct __do_is_implicitly_default_constructible_impl
1150 template <typename _Tp>
1151 static void __helper(const _Tp&);
1153 template <typename _Tp>
1154 static true_type __test(const _Tp&,
1155 decltype(__helper<const _Tp&>({}))* = 0);
1157 static false_type __test(...);
1160 template<typename _Tp>
1161 struct __is_implicitly_default_constructible_impl
1162 : public __do_is_implicitly_default_constructible_impl
1164 typedef decltype(__test(declval<_Tp>())) type;
1167 template<typename _Tp>
1168 struct __is_implicitly_default_constructible_safe
1169 : public __is_implicitly_default_constructible_impl<_Tp>::type
1172 template <typename _Tp>
1173 struct __is_implicitly_default_constructible
1174 : public __and_<is_default_constructible<_Tp>,
1175 __is_implicitly_default_constructible_safe<_Tp>>
1178 /// is_trivially_copy_constructible
1180 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1181 struct __is_trivially_copy_constructible_impl;
1183 template<typename _Tp>
1184 struct __is_trivially_copy_constructible_impl<_Tp, false>
1185 : public false_type { };
1187 template<typename _Tp>
1188 struct __is_trivially_copy_constructible_impl<_Tp, true>
1189 : public __and_<is_copy_constructible<_Tp>,
1190 integral_constant<bool,
1191 __is_trivially_constructible(_Tp, const _Tp&)>>
1194 template<typename _Tp>
1195 struct is_trivially_copy_constructible
1196 : public __is_trivially_copy_constructible_impl<_Tp>
1199 /// is_trivially_move_constructible
1201 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1202 struct __is_trivially_move_constructible_impl;
1204 template<typename _Tp>
1205 struct __is_trivially_move_constructible_impl<_Tp, false>
1206 : public false_type { };
1208 template<typename _Tp>
1209 struct __is_trivially_move_constructible_impl<_Tp, true>
1210 : public __and_<is_move_constructible<_Tp>,
1211 integral_constant<bool,
1212 __is_trivially_constructible(_Tp, _Tp&&)>>
1215 template<typename _Tp>
1216 struct is_trivially_move_constructible
1217 : public __is_trivially_move_constructible_impl<_Tp>
1220 /// is_trivially_assignable
1221 template<typename _Tp, typename _Up>
1222 struct is_trivially_assignable
1223 : public __bool_constant<__is_trivially_assignable(_Tp, _Up)>
1226 /// is_trivially_copy_assignable
1228 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1229 struct __is_trivially_copy_assignable_impl;
1231 template<typename _Tp>
1232 struct __is_trivially_copy_assignable_impl<_Tp, false>
1233 : public false_type { };
1235 template<typename _Tp>
1236 struct __is_trivially_copy_assignable_impl<_Tp, true>
1237 : public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)>
1240 template<typename _Tp>
1241 struct is_trivially_copy_assignable
1242 : public __is_trivially_copy_assignable_impl<_Tp>
1245 /// is_trivially_move_assignable
1247 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1248 struct __is_trivially_move_assignable_impl;
1250 template<typename _Tp>
1251 struct __is_trivially_move_assignable_impl<_Tp, false>
1252 : public false_type { };
1254 template<typename _Tp>
1255 struct __is_trivially_move_assignable_impl<_Tp, true>
1256 : public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)>
1259 template<typename _Tp>
1260 struct is_trivially_move_assignable
1261 : public __is_trivially_move_assignable_impl<_Tp>
1264 /// is_trivially_destructible
1265 template<typename _Tp>
1266 struct is_trivially_destructible
1267 : public __and_<is_destructible<_Tp>,
1268 __bool_constant<__has_trivial_destructor(_Tp)>>
1272 /// has_virtual_destructor
1273 template<typename _Tp>
1274 struct has_virtual_destructor
1275 : public integral_constant<bool, __has_virtual_destructor(_Tp)>
1279 // type property queries.
1282 template<typename _Tp>
1284 : public integral_constant<std::size_t, __alignof__(_Tp)> { };
1289 : public integral_constant<std::size_t, 0> { };
1291 template<typename _Tp, std::size_t _Size>
1292 struct rank<_Tp[_Size]>
1293 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1295 template<typename _Tp>
1297 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
1300 template<typename, unsigned _Uint>
1302 : public integral_constant<std::size_t, 0> { };
1304 template<typename _Tp, unsigned _Uint, std::size_t _Size>
1305 struct extent<_Tp[_Size], _Uint>
1306 : public integral_constant<std::size_t,
1307 _Uint == 0 ? _Size : extent<_Tp,
1311 template<typename _Tp, unsigned _Uint>
1312 struct extent<_Tp[], _Uint>
1313 : public integral_constant<std::size_t,
1314 _Uint == 0 ? 0 : extent<_Tp,
1322 template<typename, typename>
1324 : public false_type { };
1326 template<typename _Tp>
1327 struct is_same<_Tp, _Tp>
1328 : public true_type { };
1331 template<typename _Base, typename _Derived>
1333 : public integral_constant<bool, __is_base_of(_Base, _Derived)>
1336 template<typename _From, typename _To,
1337 bool = __or_<is_void<_From>, is_function<_To>,
1338 is_array<_To>>::value>
1339 struct __is_convertible_helper
1341 typedef typename is_void<_To>::type type;
1342 #if __cplusplus > 201703L
1343 typedef type __is_nothrow_type;
1347 template<typename _From, typename _To>
1348 class __is_convertible_helper<_From, _To, false>
1350 template<typename _To1>
1351 static void __test_aux(_To1) noexcept;
1353 template<typename _From1, typename _To1,
1354 typename = decltype(__test_aux<_To1>(std::declval<_From1>()))>
1358 template<typename, typename>
1362 #if __cplusplus > 201703L
1363 template<typename _From1, typename _To1,
1364 bool _NoEx = noexcept(__test_aux<_To1>(std::declval<_From1>()))>
1365 static __bool_constant<_NoEx>
1366 __test_nothrow(int);
1368 template<typename, typename>
1370 __test_nothrow(...);
1374 typedef decltype(__test<_From, _To>(0)) type;
1376 #if __cplusplus > 201703L
1377 typedef decltype(__test_nothrow<_From, _To>(0)) __is_nothrow_type;
1383 template<typename _From, typename _To>
1384 struct is_convertible
1385 : public __is_convertible_helper<_From, _To>::type
1388 #if __cplusplus > 201703L
1389 /// is_nothrow_convertible
1390 template<typename _From, typename _To>
1391 struct is_nothrow_convertible
1392 : public __is_convertible_helper<_From, _To>::__is_nothrow_type
1395 /// is_nothrow_convertible_v
1396 template<typename _From, typename _To>
1397 inline constexpr bool is_nothrow_convertible_v
1398 = is_nothrow_convertible<_From, _To>::value;
1401 // Const-volatile modifications.
1404 template<typename _Tp>
1406 { typedef _Tp type; };
1408 template<typename _Tp>
1409 struct remove_const<_Tp const>
1410 { typedef _Tp type; };
1413 template<typename _Tp>
1414 struct remove_volatile
1415 { typedef _Tp type; };
1417 template<typename _Tp>
1418 struct remove_volatile<_Tp volatile>
1419 { typedef _Tp type; };
1422 template<typename _Tp>
1426 remove_const<typename remove_volatile<_Tp>::type>::type type;
1430 template<typename _Tp>
1432 { typedef _Tp const type; };
1435 template<typename _Tp>
1437 { typedef _Tp volatile type; };
1440 template<typename _Tp>
1444 add_const<typename add_volatile<_Tp>::type>::type type;
1447 #if __cplusplus > 201103L
1449 #define __cpp_lib_transformation_trait_aliases 201304
1451 /// Alias template for remove_const
1452 template<typename _Tp>
1453 using remove_const_t = typename remove_const<_Tp>::type;
1455 /// Alias template for remove_volatile
1456 template<typename _Tp>
1457 using remove_volatile_t = typename remove_volatile<_Tp>::type;
1459 /// Alias template for remove_cv
1460 template<typename _Tp>
1461 using remove_cv_t = typename remove_cv<_Tp>::type;
1463 /// Alias template for add_const
1464 template<typename _Tp>
1465 using add_const_t = typename add_const<_Tp>::type;
1467 /// Alias template for add_volatile
1468 template<typename _Tp>
1469 using add_volatile_t = typename add_volatile<_Tp>::type;
1471 /// Alias template for add_cv
1472 template<typename _Tp>
1473 using add_cv_t = typename add_cv<_Tp>::type;
1476 // Reference transformations.
1478 /// remove_reference
1479 template<typename _Tp>
1480 struct remove_reference
1481 { typedef _Tp type; };
1483 template<typename _Tp>
1484 struct remove_reference<_Tp&>
1485 { typedef _Tp type; };
1487 template<typename _Tp>
1488 struct remove_reference<_Tp&&>
1489 { typedef _Tp type; };
1491 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1492 struct __add_lvalue_reference_helper
1493 { typedef _Tp type; };
1495 template<typename _Tp>
1496 struct __add_lvalue_reference_helper<_Tp, true>
1497 { typedef _Tp& type; };
1499 /// add_lvalue_reference
1500 template<typename _Tp>
1501 struct add_lvalue_reference
1502 : public __add_lvalue_reference_helper<_Tp>
1505 template<typename _Tp, bool = __is_referenceable<_Tp>::value>
1506 struct __add_rvalue_reference_helper
1507 { typedef _Tp type; };
1509 template<typename _Tp>
1510 struct __add_rvalue_reference_helper<_Tp, true>
1511 { typedef _Tp&& type; };
1513 /// add_rvalue_reference
1514 template<typename _Tp>
1515 struct add_rvalue_reference
1516 : public __add_rvalue_reference_helper<_Tp>
1519 #if __cplusplus > 201103L
1520 /// Alias template for remove_reference
1521 template<typename _Tp>
1522 using remove_reference_t = typename remove_reference<_Tp>::type;
1524 /// Alias template for add_lvalue_reference
1525 template<typename _Tp>
1526 using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
1528 /// Alias template for add_rvalue_reference
1529 template<typename _Tp>
1530 using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
1533 // Sign modifications.
1535 // Utility for constructing identically cv-qualified types.
1536 template<typename _Unqualified, bool _IsConst, bool _IsVol>
1537 struct __cv_selector;
1539 template<typename _Unqualified>
1540 struct __cv_selector<_Unqualified, false, false>
1541 { typedef _Unqualified __type; };
1543 template<typename _Unqualified>
1544 struct __cv_selector<_Unqualified, false, true>
1545 { typedef volatile _Unqualified __type; };
1547 template<typename _Unqualified>
1548 struct __cv_selector<_Unqualified, true, false>
1549 { typedef const _Unqualified __type; };
1551 template<typename _Unqualified>
1552 struct __cv_selector<_Unqualified, true, true>
1553 { typedef const volatile _Unqualified __type; };
1555 template<typename _Qualified, typename _Unqualified,
1556 bool _IsConst = is_const<_Qualified>::value,
1557 bool _IsVol = is_volatile<_Qualified>::value>
1558 class __match_cv_qualifiers
1560 typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match;
1563 typedef typename __match::__type __type;
1566 // Utility for finding the unsigned versions of signed integral types.
1567 template<typename _Tp>
1568 struct __make_unsigned
1569 { typedef _Tp __type; };
1572 struct __make_unsigned<char>
1573 { typedef unsigned char __type; };
1576 struct __make_unsigned<signed char>
1577 { typedef unsigned char __type; };
1580 struct __make_unsigned<short>
1581 { typedef unsigned short __type; };
1584 struct __make_unsigned<int>
1585 { typedef unsigned int __type; };
1588 struct __make_unsigned<long>
1589 { typedef unsigned long __type; };
1592 struct __make_unsigned<long long>
1593 { typedef unsigned long long __type; };
1595 #if defined(__GLIBCXX_TYPE_INT_N_0)
1597 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0>
1598 { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; };
1600 #if defined(__GLIBCXX_TYPE_INT_N_1)
1602 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1>
1603 { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; };
1605 #if defined(__GLIBCXX_TYPE_INT_N_2)
1607 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2>
1608 { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; };
1610 #if defined(__GLIBCXX_TYPE_INT_N_3)
1612 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3>
1613 { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; };
1616 // Select between integral and enum: not possible to be both.
1617 template<typename _Tp,
1618 bool _IsInt = is_integral<_Tp>::value,
1619 bool _IsEnum = is_enum<_Tp>::value>
1620 class __make_unsigned_selector;
1622 template<typename _Tp>
1623 class __make_unsigned_selector<_Tp, true, false>
1625 using __unsigned_type
1626 = typename __make_unsigned<typename remove_cv<_Tp>::type>::__type;
1630 = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type;
1633 class __make_unsigned_selector_base
1636 template<typename...> struct _List { };
1638 template<typename _Tp, typename... _Up>
1639 struct _List<_Tp, _Up...> : _List<_Up...>
1640 { static constexpr size_t __size = sizeof(_Tp); };
1642 template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
1645 template<size_t _Sz, typename _Uint, typename... _UInts>
1646 struct __select<_Sz, _List<_Uint, _UInts...>, true>
1647 { using __type = _Uint; };
1649 template<size_t _Sz, typename _Uint, typename... _UInts>
1650 struct __select<_Sz, _List<_Uint, _UInts...>, false>
1651 : __select<_Sz, _List<_UInts...>>
1655 // Choose unsigned integer type with the smallest rank and same size as _Tp
1656 template<typename _Tp>
1657 class __make_unsigned_selector<_Tp, false, true>
1658 : __make_unsigned_selector_base
1660 // With -fshort-enums, an enum may be as small as a char.
1661 using _UInts = _List<unsigned char, unsigned short, unsigned int,
1662 unsigned long, unsigned long long>;
1664 using __unsigned_type = typename __select<sizeof(_Tp), _UInts>::__type;
1668 = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type;
1671 // wchar_t, char16_t and char32_t are integral types but are neither
1672 // signed integer types nor unsigned integer types, so must be
1673 // transformed to the unsigned integer type with the smallest rank.
1674 // Use the partial specialization for enumeration types to do that.
1675 #if defined(_GLIBCXX_USE_WCHAR_T)
1677 struct __make_unsigned<wchar_t>
1680 = typename __make_unsigned_selector<wchar_t, false, true>::__type;
1685 struct __make_unsigned<char16_t>
1688 = typename __make_unsigned_selector<char16_t, false, true>::__type;
1692 struct __make_unsigned<char32_t>
1695 = typename __make_unsigned_selector<char32_t, false, true>::__type;
1698 // Given an integral/enum type, return the corresponding unsigned
1700 // Primary template.
1702 template<typename _Tp>
1703 struct make_unsigned
1704 { typedef typename __make_unsigned_selector<_Tp>::__type type; };
1706 // Integral, but don't define.
1708 struct make_unsigned<bool>;
1711 // Utility for finding the signed versions of unsigned integral types.
1712 template<typename _Tp>
1713 struct __make_signed
1714 { typedef _Tp __type; };
1717 struct __make_signed<char>
1718 { typedef signed char __type; };
1721 struct __make_signed<unsigned char>
1722 { typedef signed char __type; };
1725 struct __make_signed<unsigned short>
1726 { typedef signed short __type; };
1729 struct __make_signed<unsigned int>
1730 { typedef signed int __type; };
1733 struct __make_signed<unsigned long>
1734 { typedef signed long __type; };
1737 struct __make_signed<unsigned long long>
1738 { typedef signed long long __type; };
1740 #if defined(__GLIBCXX_TYPE_INT_N_0)
1742 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0>
1743 { typedef __GLIBCXX_TYPE_INT_N_0 __type; };
1745 #if defined(__GLIBCXX_TYPE_INT_N_1)
1747 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1>
1748 { typedef __GLIBCXX_TYPE_INT_N_1 __type; };
1750 #if defined(__GLIBCXX_TYPE_INT_N_2)
1752 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2>
1753 { typedef __GLIBCXX_TYPE_INT_N_2 __type; };
1755 #if defined(__GLIBCXX_TYPE_INT_N_3)
1757 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3>
1758 { typedef __GLIBCXX_TYPE_INT_N_3 __type; };
1761 // Select between integral and enum: not possible to be both.
1762 template<typename _Tp,
1763 bool _IsInt = is_integral<_Tp>::value,
1764 bool _IsEnum = is_enum<_Tp>::value>
1765 class __make_signed_selector;
1767 template<typename _Tp>
1768 class __make_signed_selector<_Tp, true, false>
1771 = typename __make_signed<typename remove_cv<_Tp>::type>::__type;
1775 = typename __match_cv_qualifiers<_Tp, __signed_type>::__type;
1778 // Choose signed integer type with the smallest rank and same size as _Tp
1779 template<typename _Tp>
1780 class __make_signed_selector<_Tp, false, true>
1782 typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type;
1785 typedef typename __make_signed_selector<__unsigned_type>::__type __type;
1788 // wchar_t, char16_t and char32_t are integral types but are neither
1789 // signed integer types nor unsigned integer types, so must be
1790 // transformed to the signed integer type with the smallest rank.
1791 // Use the partial specialization for enumeration types to do that.
1792 #if defined(_GLIBCXX_USE_WCHAR_T)
1794 struct __make_signed<wchar_t>
1797 = typename __make_signed_selector<wchar_t, false, true>::__type;
1802 struct __make_signed<char16_t>
1805 = typename __make_signed_selector<char16_t, false, true>::__type;
1809 struct __make_signed<char32_t>
1812 = typename __make_signed_selector<char32_t, false, true>::__type;
1815 // Given an integral/enum type, return the corresponding signed
1817 // Primary template.
1819 template<typename _Tp>
1821 { typedef typename __make_signed_selector<_Tp>::__type type; };
1823 // Integral, but don't define.
1825 struct make_signed<bool>;
1827 #if __cplusplus > 201103L
1828 /// Alias template for make_signed
1829 template<typename _Tp>
1830 using make_signed_t = typename make_signed<_Tp>::type;
1832 /// Alias template for make_unsigned
1833 template<typename _Tp>
1834 using make_unsigned_t = typename make_unsigned<_Tp>::type;
1837 // Array modifications.
1840 template<typename _Tp>
1841 struct remove_extent
1842 { typedef _Tp type; };
1844 template<typename _Tp, std::size_t _Size>
1845 struct remove_extent<_Tp[_Size]>
1846 { typedef _Tp type; };
1848 template<typename _Tp>
1849 struct remove_extent<_Tp[]>
1850 { typedef _Tp type; };
1852 /// remove_all_extents
1853 template<typename _Tp>
1854 struct remove_all_extents
1855 { typedef _Tp type; };
1857 template<typename _Tp, std::size_t _Size>
1858 struct remove_all_extents<_Tp[_Size]>
1859 { typedef typename remove_all_extents<_Tp>::type type; };
1861 template<typename _Tp>
1862 struct remove_all_extents<_Tp[]>
1863 { typedef typename remove_all_extents<_Tp>::type type; };
1865 #if __cplusplus > 201103L
1866 /// Alias template for remove_extent
1867 template<typename _Tp>
1868 using remove_extent_t = typename remove_extent<_Tp>::type;
1870 /// Alias template for remove_all_extents
1871 template<typename _Tp>
1872 using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
1875 // Pointer modifications.
1877 template<typename _Tp, typename>
1878 struct __remove_pointer_helper
1879 { typedef _Tp type; };
1881 template<typename _Tp, typename _Up>
1882 struct __remove_pointer_helper<_Tp, _Up*>
1883 { typedef _Up type; };
1886 template<typename _Tp>
1887 struct remove_pointer
1888 : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
1892 template<typename _Tp, bool = __or_<__is_referenceable<_Tp>,
1893 is_void<_Tp>>::value>
1894 struct __add_pointer_helper
1895 { typedef _Tp type; };
1897 template<typename _Tp>
1898 struct __add_pointer_helper<_Tp, true>
1899 { typedef typename remove_reference<_Tp>::type* type; };
1901 template<typename _Tp>
1903 : public __add_pointer_helper<_Tp>
1906 #if __cplusplus > 201103L
1907 /// Alias template for remove_pointer
1908 template<typename _Tp>
1909 using remove_pointer_t = typename remove_pointer<_Tp>::type;
1911 /// Alias template for add_pointer
1912 template<typename _Tp>
1913 using add_pointer_t = typename add_pointer<_Tp>::type;
1916 template<std::size_t _Len>
1917 struct __aligned_storage_msa
1921 unsigned char __data[_Len];
1922 struct __attribute__((__aligned__)) { } __align;
1927 * @brief Alignment type.
1929 * The value of _Align is a default-alignment which shall be the
1930 * most stringent alignment requirement for any C++ object type
1931 * whose size is no greater than _Len (3.9). The member typedef
1932 * type shall be a POD type suitable for use as uninitialized
1933 * storage for any object whose size is at most _Len and whose
1934 * alignment is a divisor of _Align.
1936 template<std::size_t _Len, std::size_t _Align =
1937 __alignof__(typename __aligned_storage_msa<_Len>::__type)>
1938 struct aligned_storage
1942 unsigned char __data[_Len];
1943 struct __attribute__((__aligned__((_Align)))) { } __align;
1947 template <typename... _Types>
1948 struct __strictest_alignment
1950 static const size_t _S_alignment = 0;
1951 static const size_t _S_size = 0;
1954 template <typename _Tp, typename... _Types>
1955 struct __strictest_alignment<_Tp, _Types...>
1957 static const size_t _S_alignment =
1958 alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment
1959 ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment;
1960 static const size_t _S_size =
1961 sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size
1962 ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size;
1966 * @brief Provide aligned storage for types.
1968 * [meta.trans.other]
1970 * Provides aligned storage for any of the provided types of at
1973 * @see aligned_storage
1975 template <size_t _Len, typename... _Types>
1976 struct aligned_union
1979 static_assert(sizeof...(_Types) != 0, "At least one type is required");
1981 using __strictest = __strictest_alignment<_Types...>;
1982 static const size_t _S_len = _Len > __strictest::_S_size
1983 ? _Len : __strictest::_S_size;
1985 /// The value of the strictest alignment of _Types.
1986 static const size_t alignment_value = __strictest::_S_alignment;
1988 typedef typename aligned_storage<_S_len, alignment_value>::type type;
1991 template <size_t _Len, typename... _Types>
1992 const size_t aligned_union<_Len, _Types...>::alignment_value;
1994 // Decay trait for arrays and functions, used for perfect forwarding
1995 // in make_pair, make_tuple, etc.
1996 template<typename _Up,
1997 bool _IsArray = is_array<_Up>::value,
1998 bool _IsFunction = is_function<_Up>::value>
1999 struct __decay_selector;
2002 template<typename _Up>
2003 struct __decay_selector<_Up, false, false>
2004 { typedef typename remove_cv<_Up>::type __type; };
2006 template<typename _Up>
2007 struct __decay_selector<_Up, true, false>
2008 { typedef typename remove_extent<_Up>::type* __type; };
2010 template<typename _Up>
2011 struct __decay_selector<_Up, false, true>
2012 { typedef typename add_pointer<_Up>::type __type; };
2015 template<typename _Tp>
2018 typedef typename remove_reference<_Tp>::type __remove_type;
2021 typedef typename __decay_selector<__remove_type>::__type type;
2024 template<typename _Tp>
2025 class reference_wrapper;
2027 // Helper which adds a reference to a type when given a reference_wrapper
2028 template<typename _Tp>
2029 struct __strip_reference_wrapper
2034 template<typename _Tp>
2035 struct __strip_reference_wrapper<reference_wrapper<_Tp> >
2037 typedef _Tp& __type;
2040 template<typename _Tp>
2041 struct __decay_and_strip
2043 typedef typename __strip_reference_wrapper<
2044 typename decay<_Tp>::type>::__type __type;
2048 // Primary template.
2049 /// Define a member typedef @c type only if a boolean constant is true.
2050 template<bool, typename _Tp = void>
2054 // Partial specialization for true.
2055 template<typename _Tp>
2056 struct enable_if<true, _Tp>
2057 { typedef _Tp type; };
2059 template<typename... _Cond>
2060 using _Require = typename enable_if<__and_<_Cond...>::value>::type;
2062 // Primary template.
2063 /// Define a member typedef @c type to one of two argument types.
2064 template<bool _Cond, typename _Iftrue, typename _Iffalse>
2066 { typedef _Iftrue type; };
2068 // Partial specialization for false.
2069 template<typename _Iftrue, typename _Iffalse>
2070 struct conditional<false, _Iftrue, _Iffalse>
2071 { typedef _Iffalse type; };
2074 template<typename... _Tp>
2077 // Sfinae-friendly common_type implementation:
2079 struct __do_common_type_impl
2081 template<typename _Tp, typename _Up>
2082 static __success_type<typename decay<decltype
2083 (true ? std::declval<_Tp>()
2084 : std::declval<_Up>())>::type> _S_test(int);
2086 template<typename, typename>
2087 static __failure_type _S_test(...);
2090 template<typename _Tp, typename _Up>
2091 struct __common_type_impl
2092 : private __do_common_type_impl
2094 typedef decltype(_S_test<_Tp, _Up>(0)) type;
2097 struct __do_member_type_wrapper
2099 template<typename _Tp>
2100 static __success_type<typename _Tp::type> _S_test(int);
2103 static __failure_type _S_test(...);
2106 template<typename _Tp>
2107 struct __member_type_wrapper
2108 : private __do_member_type_wrapper
2110 typedef decltype(_S_test<_Tp>(0)) type;
2113 template<typename _CTp, typename... _Args>
2114 struct __expanded_common_type_wrapper
2116 typedef common_type<typename _CTp::type, _Args...> type;
2119 template<typename... _Args>
2120 struct __expanded_common_type_wrapper<__failure_type, _Args...>
2121 { typedef __failure_type type; };
2123 template<typename _Tp>
2124 struct common_type<_Tp>
2125 { typedef typename decay<_Tp>::type type; };
2127 template<typename _Tp, typename _Up>
2128 struct common_type<_Tp, _Up>
2129 : public __common_type_impl<_Tp, _Up>::type
2132 template<typename _Tp, typename _Up, typename... _Vp>
2133 struct common_type<_Tp, _Up, _Vp...>
2134 : public __expanded_common_type_wrapper<typename __member_type_wrapper<
2135 common_type<_Tp, _Up>>::type, _Vp...>::type
2138 /// The underlying type of an enum.
2139 template<typename _Tp>
2140 struct underlying_type
2142 typedef __underlying_type(_Tp) type;
2145 template<typename _Tp>
2146 struct __declval_protector
2148 static const bool __stop = false;
2151 template<typename _Tp>
2152 auto declval() noexcept -> decltype(__declval<_Tp>(0))
2154 static_assert(__declval_protector<_Tp>::__stop,
2155 "declval() must not be used!");
2156 return __declval<_Tp>(0);
2159 // __remove_cvref_t (std::remove_cvref_t for C++11).
2160 template<typename _Tp>
2161 using __remove_cvref_t
2162 = typename remove_cv<typename remove_reference<_Tp>::type>::type;
2165 template<typename _Signature>
2168 // Sfinae-friendly result_of implementation:
2170 #define __cpp_lib_result_of_sfinae 201210
2172 struct __invoke_memfun_ref { };
2173 struct __invoke_memfun_deref { };
2174 struct __invoke_memobj_ref { };
2175 struct __invoke_memobj_deref { };
2176 struct __invoke_other { };
2178 // Associate a tag type with a specialization of __success_type.
2179 template<typename _Tp, typename _Tag>
2180 struct __result_of_success : __success_type<_Tp>
2181 { using __invoke_type = _Tag; };
2183 // [func.require] paragraph 1 bullet 1:
2184 struct __result_of_memfun_ref_impl
2186 template<typename _Fp, typename _Tp1, typename... _Args>
2187 static __result_of_success<decltype(
2188 (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...)
2189 ), __invoke_memfun_ref> _S_test(int);
2191 template<typename...>
2192 static __failure_type _S_test(...);
2195 template<typename _MemPtr, typename _Arg, typename... _Args>
2196 struct __result_of_memfun_ref
2197 : private __result_of_memfun_ref_impl
2199 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2202 // [func.require] paragraph 1 bullet 2:
2203 struct __result_of_memfun_deref_impl
2205 template<typename _Fp, typename _Tp1, typename... _Args>
2206 static __result_of_success<decltype(
2207 ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...)
2208 ), __invoke_memfun_deref> _S_test(int);
2210 template<typename...>
2211 static __failure_type _S_test(...);
2214 template<typename _MemPtr, typename _Arg, typename... _Args>
2215 struct __result_of_memfun_deref
2216 : private __result_of_memfun_deref_impl
2218 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
2221 // [func.require] paragraph 1 bullet 3:
2222 struct __result_of_memobj_ref_impl
2224 template<typename _Fp, typename _Tp1>
2225 static __result_of_success<decltype(
2226 std::declval<_Tp1>().*std::declval<_Fp>()
2227 ), __invoke_memobj_ref> _S_test(int);
2229 template<typename, typename>
2230 static __failure_type _S_test(...);
2233 template<typename _MemPtr, typename _Arg>
2234 struct __result_of_memobj_ref
2235 : private __result_of_memobj_ref_impl
2237 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2240 // [func.require] paragraph 1 bullet 4:
2241 struct __result_of_memobj_deref_impl
2243 template<typename _Fp, typename _Tp1>
2244 static __result_of_success<decltype(
2245 (*std::declval<_Tp1>()).*std::declval<_Fp>()
2246 ), __invoke_memobj_deref> _S_test(int);
2248 template<typename, typename>
2249 static __failure_type _S_test(...);
2252 template<typename _MemPtr, typename _Arg>
2253 struct __result_of_memobj_deref
2254 : private __result_of_memobj_deref_impl
2256 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
2259 template<typename _MemPtr, typename _Arg>
2260 struct __result_of_memobj;
2262 template<typename _Res, typename _Class, typename _Arg>
2263 struct __result_of_memobj<_Res _Class::*, _Arg>
2265 typedef __remove_cvref_t<_Arg> _Argval;
2266 typedef _Res _Class::* _MemPtr;
2267 typedef typename conditional<__or_<is_same<_Argval, _Class>,
2268 is_base_of<_Class, _Argval>>::value,
2269 __result_of_memobj_ref<_MemPtr, _Arg>,
2270 __result_of_memobj_deref<_MemPtr, _Arg>
2274 template<typename _MemPtr, typename _Arg, typename... _Args>
2275 struct __result_of_memfun;
2277 template<typename _Res, typename _Class, typename _Arg, typename... _Args>
2278 struct __result_of_memfun<_Res _Class::*, _Arg, _Args...>
2280 typedef __remove_cvref_t<_Arg> _Argval;
2281 typedef _Res _Class::* _MemPtr;
2282 typedef typename conditional<__or_<is_same<_Argval, _Class>,
2283 is_base_of<_Class, _Argval>>::value,
2284 __result_of_memfun_ref<_MemPtr, _Arg, _Args...>,
2285 __result_of_memfun_deref<_MemPtr, _Arg, _Args...>
2289 // _GLIBCXX_RESOLVE_LIB_DEFECTS
2290 // 2219. INVOKE-ing a pointer to member with a reference_wrapper
2291 // as the object expression
2293 // Used by result_of, invoke etc. to unwrap a reference_wrapper.
2294 template<typename _Tp, typename _Up = typename decay<_Tp>::type>
2300 template<typename _Tp, typename _Up>
2301 struct __inv_unwrap<_Tp, reference_wrapper<_Up>>
2306 template<bool, bool, typename _Functor, typename... _ArgTypes>
2307 struct __result_of_impl
2309 typedef __failure_type type;
2312 template<typename _MemPtr, typename _Arg>
2313 struct __result_of_impl<true, false, _MemPtr, _Arg>
2314 : public __result_of_memobj<typename decay<_MemPtr>::type,
2315 typename __inv_unwrap<_Arg>::type>
2318 template<typename _MemPtr, typename _Arg, typename... _Args>
2319 struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...>
2320 : public __result_of_memfun<typename decay<_MemPtr>::type,
2321 typename __inv_unwrap<_Arg>::type, _Args...>
2324 // [func.require] paragraph 1 bullet 5:
2325 struct __result_of_other_impl
2327 template<typename _Fn, typename... _Args>
2328 static __result_of_success<decltype(
2329 std::declval<_Fn>()(std::declval<_Args>()...)
2330 ), __invoke_other> _S_test(int);
2332 template<typename...>
2333 static __failure_type _S_test(...);
2336 template<typename _Functor, typename... _ArgTypes>
2337 struct __result_of_impl<false, false, _Functor, _ArgTypes...>
2338 : private __result_of_other_impl
2340 typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type;
2343 // __invoke_result (std::invoke_result for C++11)
2344 template<typename _Functor, typename... _ArgTypes>
2345 struct __invoke_result
2346 : public __result_of_impl<
2347 is_member_object_pointer<
2348 typename remove_reference<_Functor>::type
2350 is_member_function_pointer<
2351 typename remove_reference<_Functor>::type
2353 _Functor, _ArgTypes...
2357 template<typename _Functor, typename... _ArgTypes>
2358 struct result_of<_Functor(_ArgTypes...)>
2359 : public __invoke_result<_Functor, _ArgTypes...>
2362 #if __cplusplus >= 201402L
2363 /// Alias template for aligned_storage
2364 template<size_t _Len, size_t _Align =
2365 __alignof__(typename __aligned_storage_msa<_Len>::__type)>
2366 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
2368 template <size_t _Len, typename... _Types>
2369 using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
2371 /// Alias template for decay
2372 template<typename _Tp>
2373 using decay_t = typename decay<_Tp>::type;
2375 /// Alias template for enable_if
2376 template<bool _Cond, typename _Tp = void>
2377 using enable_if_t = typename enable_if<_Cond, _Tp>::type;
2379 /// Alias template for conditional
2380 template<bool _Cond, typename _Iftrue, typename _Iffalse>
2381 using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type;
2383 /// Alias template for common_type
2384 template<typename... _Tp>
2385 using common_type_t = typename common_type<_Tp...>::type;
2387 /// Alias template for underlying_type
2388 template<typename _Tp>
2389 using underlying_type_t = typename underlying_type<_Tp>::type;
2391 /// Alias template for result_of
2392 template<typename _Tp>
2393 using result_of_t = typename result_of<_Tp>::type;
2396 // __enable_if_t (std::enable_if_t for C++11)
2397 template<bool _Cond, typename _Tp = void>
2398 using __enable_if_t = typename enable_if<_Cond, _Tp>::type;
2400 // __void_t (std::void_t for C++11)
2401 template<typename...> using __void_t = void;
2403 #if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++11
2404 #define __cpp_lib_void_t 201411
2405 /// A metafunction that always yields void, used for detecting valid types.
2406 template<typename...> using void_t = void;
2409 /// Implementation of the detection idiom (negative case).
2410 template<typename _Default, typename _AlwaysVoid,
2411 template<typename...> class _Op, typename... _Args>
2414 using value_t = false_type;
2415 using type = _Default;
2418 /// Implementation of the detection idiom (positive case).
2419 template<typename _Default, template<typename...> class _Op,
2421 struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...>
2423 using value_t = true_type;
2424 using type = _Op<_Args...>;
2427 // Detect whether _Op<_Args...> is a valid type, use _Default if not.
2428 template<typename _Default, template<typename...> class _Op,
2430 using __detected_or = __detector<_Default, void, _Op, _Args...>;
2432 // _Op<_Args...> if that is a valid type, otherwise _Default.
2433 template<typename _Default, template<typename...> class _Op,
2435 using __detected_or_t
2436 = typename __detected_or<_Default, _Op, _Args...>::type;
2438 /// @} group metaprogramming
2441 * Use SFINAE to determine if the type _Tp has a publicly-accessible
2442 * member type _NTYPE.
2444 #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \
2445 template<typename _Tp, typename = __void_t<>> \
2446 struct __has_##_NTYPE \
2449 template<typename _Tp> \
2450 struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \
2454 template <typename _Tp>
2455 struct __is_swappable;
2457 template <typename _Tp>
2458 struct __is_nothrow_swappable;
2460 template<typename... _Elements>
2464 struct __is_tuple_like_impl : false_type
2467 template<typename... _Tps>
2468 struct __is_tuple_like_impl<tuple<_Tps...>> : true_type
2471 // Internal type trait that allows us to sfinae-protect tuple_cat.
2472 template<typename _Tp>
2473 struct __is_tuple_like
2474 : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type
2477 template<typename _Tp>
2479 typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>,
2480 is_move_constructible<_Tp>,
2481 is_move_assignable<_Tp>>::value>::type
2483 noexcept(__and_<is_nothrow_move_constructible<_Tp>,
2484 is_nothrow_move_assignable<_Tp>>::value);
2486 template<typename _Tp, size_t _Nm>
2488 typename enable_if<__is_swappable<_Tp>::value>::type
2489 swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
2490 noexcept(__is_nothrow_swappable<_Tp>::value);
2492 namespace __swappable_details {
2495 struct __do_is_swappable_impl
2497 template<typename _Tp, typename
2498 = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))>
2499 static true_type __test(int);
2502 static false_type __test(...);
2505 struct __do_is_nothrow_swappable_impl
2507 template<typename _Tp>
2508 static __bool_constant<
2509 noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))
2513 static false_type __test(...);
2516 } // namespace __swappable_details
2518 template<typename _Tp>
2519 struct __is_swappable_impl
2520 : public __swappable_details::__do_is_swappable_impl
2522 typedef decltype(__test<_Tp>(0)) type;
2525 template<typename _Tp>
2526 struct __is_nothrow_swappable_impl
2527 : public __swappable_details::__do_is_nothrow_swappable_impl
2529 typedef decltype(__test<_Tp>(0)) type;
2532 template<typename _Tp>
2533 struct __is_swappable
2534 : public __is_swappable_impl<_Tp>::type
2537 template<typename _Tp>
2538 struct __is_nothrow_swappable
2539 : public __is_nothrow_swappable_impl<_Tp>::type
2542 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
2543 #define __cpp_lib_is_swappable 201603
2544 /// Metafunctions used for detecting swappable types: p0185r1
2547 template<typename _Tp>
2549 : public __is_swappable_impl<_Tp>::type
2552 /// is_nothrow_swappable
2553 template<typename _Tp>
2554 struct is_nothrow_swappable
2555 : public __is_nothrow_swappable_impl<_Tp>::type
2558 #if __cplusplus >= 201402L
2560 template<typename _Tp>
2561 _GLIBCXX17_INLINE constexpr bool is_swappable_v =
2562 is_swappable<_Tp>::value;
2564 /// is_nothrow_swappable_v
2565 template<typename _Tp>
2566 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v =
2567 is_nothrow_swappable<_Tp>::value;
2568 #endif // __cplusplus >= 201402L
2570 namespace __swappable_with_details {
2573 struct __do_is_swappable_with_impl
2575 template<typename _Tp, typename _Up, typename
2576 = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())),
2578 = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))>
2579 static true_type __test(int);
2581 template<typename, typename>
2582 static false_type __test(...);
2585 struct __do_is_nothrow_swappable_with_impl
2587 template<typename _Tp, typename _Up>
2588 static __bool_constant<
2589 noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))
2591 noexcept(swap(std::declval<_Up>(), std::declval<_Tp>()))
2594 template<typename, typename>
2595 static false_type __test(...);
2598 } // namespace __swappable_with_details
2600 template<typename _Tp, typename _Up>
2601 struct __is_swappable_with_impl
2602 : public __swappable_with_details::__do_is_swappable_with_impl
2604 typedef decltype(__test<_Tp, _Up>(0)) type;
2607 // Optimization for the homogenous lvalue case, not required:
2608 template<typename _Tp>
2609 struct __is_swappable_with_impl<_Tp&, _Tp&>
2610 : public __swappable_details::__do_is_swappable_impl
2612 typedef decltype(__test<_Tp&>(0)) type;
2615 template<typename _Tp, typename _Up>
2616 struct __is_nothrow_swappable_with_impl
2617 : public __swappable_with_details::__do_is_nothrow_swappable_with_impl
2619 typedef decltype(__test<_Tp, _Up>(0)) type;
2622 // Optimization for the homogenous lvalue case, not required:
2623 template<typename _Tp>
2624 struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&>
2625 : public __swappable_details::__do_is_nothrow_swappable_impl
2627 typedef decltype(__test<_Tp&>(0)) type;
2630 /// is_swappable_with
2631 template<typename _Tp, typename _Up>
2632 struct is_swappable_with
2633 : public __is_swappable_with_impl<_Tp, _Up>::type
2636 /// is_nothrow_swappable_with
2637 template<typename _Tp, typename _Up>
2638 struct is_nothrow_swappable_with
2639 : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type
2642 #if __cplusplus >= 201402L
2643 /// is_swappable_with_v
2644 template<typename _Tp, typename _Up>
2645 _GLIBCXX17_INLINE constexpr bool is_swappable_with_v =
2646 is_swappable_with<_Tp, _Up>::value;
2648 /// is_nothrow_swappable_with_v
2649 template<typename _Tp, typename _Up>
2650 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v =
2651 is_nothrow_swappable_with<_Tp, _Up>::value;
2652 #endif // __cplusplus >= 201402L
2654 #endif// c++1z or gnu++11
2656 // __is_invocable (std::is_invocable for C++11)
2658 template<typename _Result, typename _Ret, typename = void>
2659 struct __is_invocable_impl : false_type { };
2661 template<typename _Result, typename _Ret>
2662 struct __is_invocable_impl<_Result, _Ret, __void_t<typename _Result::type>>
2663 : __or_<is_void<_Ret>, is_convertible<typename _Result::type, _Ret>>::type
2666 template<typename _Fn, typename... _ArgTypes>
2667 struct __is_invocable
2668 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
2671 template<typename _Fn, typename _Tp, typename... _Args>
2672 constexpr bool __call_is_nt(__invoke_memfun_ref)
2674 using _Up = typename __inv_unwrap<_Tp>::type;
2675 return noexcept((std::declval<_Up>().*std::declval<_Fn>())(
2676 std::declval<_Args>()...));
2679 template<typename _Fn, typename _Tp, typename... _Args>
2680 constexpr bool __call_is_nt(__invoke_memfun_deref)
2682 return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())(
2683 std::declval<_Args>()...));
2686 template<typename _Fn, typename _Tp>
2687 constexpr bool __call_is_nt(__invoke_memobj_ref)
2689 using _Up = typename __inv_unwrap<_Tp>::type;
2690 return noexcept(std::declval<_Up>().*std::declval<_Fn>());
2693 template<typename _Fn, typename _Tp>
2694 constexpr bool __call_is_nt(__invoke_memobj_deref)
2696 return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>());
2699 template<typename _Fn, typename... _Args>
2700 constexpr bool __call_is_nt(__invoke_other)
2702 return noexcept(std::declval<_Fn>()(std::declval<_Args>()...));
2705 template<typename _Result, typename _Fn, typename... _Args>
2706 struct __call_is_nothrow
2708 std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{})
2712 template<typename _Fn, typename... _Args>
2713 using __call_is_nothrow_
2714 = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>;
2716 // __is_nothrow_invocable (std::is_nothrow_invocable for C++11)
2717 template<typename _Fn, typename... _Args>
2718 struct __is_nothrow_invocable
2719 : __and_<__is_invocable<_Fn, _Args...>,
2720 __call_is_nothrow_<_Fn, _Args...>>::type
2724 __nonesuch() = delete;
2725 ~__nonesuch() = delete;
2726 __nonesuch(__nonesuch const&) = delete;
2727 void operator=(__nonesuch const&) = delete;
2730 #if __cplusplus >= 201703L
2731 # define __cpp_lib_is_invocable 201703
2733 /// std::invoke_result
2734 template<typename _Functor, typename... _ArgTypes>
2735 struct invoke_result
2736 : public __invoke_result<_Functor, _ArgTypes...>
2739 /// std::invoke_result_t
2740 template<typename _Fn, typename... _Args>
2741 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
2743 /// std::is_invocable
2744 template<typename _Fn, typename... _ArgTypes>
2746 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type
2749 /// std::is_invocable_r
2750 template<typename _Ret, typename _Fn, typename... _ArgTypes>
2751 struct is_invocable_r
2752 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type
2755 /// std::is_nothrow_invocable
2756 template<typename _Fn, typename... _ArgTypes>
2757 struct is_nothrow_invocable
2758 : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>,
2759 __call_is_nothrow_<_Fn, _ArgTypes...>>::type
2762 template<typename _Result, typename _Ret, typename = void>
2763 struct __is_nt_invocable_impl : false_type { };
2765 template<typename _Result, typename _Ret>
2766 struct __is_nt_invocable_impl<_Result, _Ret,
2767 __void_t<typename _Result::type>>
2768 : __or_<is_void<_Ret>,
2769 __and_<is_convertible<typename _Result::type, _Ret>,
2770 is_nothrow_constructible<_Ret, typename _Result::type>>>
2773 /// std::is_nothrow_invocable_r
2774 template<typename _Ret, typename _Fn, typename... _ArgTypes>
2775 struct is_nothrow_invocable_r
2776 : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>,
2777 __call_is_nothrow_<_Fn, _ArgTypes...>>::type
2780 /// std::is_invocable_v
2781 template<typename _Fn, typename... _Args>
2782 inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
2784 /// std::is_nothrow_invocable_v
2785 template<typename _Fn, typename... _Args>
2786 inline constexpr bool is_nothrow_invocable_v
2787 = is_nothrow_invocable<_Fn, _Args...>::value;
2789 /// std::is_invocable_r_v
2790 template<typename _Fn, typename... _Args>
2791 inline constexpr bool is_invocable_r_v
2792 = is_invocable_r<_Fn, _Args...>::value;
2794 /// std::is_nothrow_invocable_r_v
2795 template<typename _Fn, typename... _Args>
2796 inline constexpr bool is_nothrow_invocable_r_v
2797 = is_nothrow_invocable_r<_Fn, _Args...>::value;
2800 #if __cplusplus >= 201703L
2801 # define __cpp_lib_type_trait_variable_templates 201510L
2802 template <typename _Tp>
2803 inline constexpr bool is_void_v = is_void<_Tp>::value;
2804 template <typename _Tp>
2805 inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
2806 template <typename _Tp>
2807 inline constexpr bool is_integral_v = is_integral<_Tp>::value;
2808 template <typename _Tp>
2809 inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
2810 template <typename _Tp>
2811 inline constexpr bool is_array_v = is_array<_Tp>::value;
2812 template <typename _Tp>
2813 inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
2814 template <typename _Tp>
2815 inline constexpr bool is_lvalue_reference_v =
2816 is_lvalue_reference<_Tp>::value;
2817 template <typename _Tp>
2818 inline constexpr bool is_rvalue_reference_v =
2819 is_rvalue_reference<_Tp>::value;
2820 template <typename _Tp>
2821 inline constexpr bool is_member_object_pointer_v =
2822 is_member_object_pointer<_Tp>::value;
2823 template <typename _Tp>
2824 inline constexpr bool is_member_function_pointer_v =
2825 is_member_function_pointer<_Tp>::value;
2826 template <typename _Tp>
2827 inline constexpr bool is_enum_v = is_enum<_Tp>::value;
2828 template <typename _Tp>
2829 inline constexpr bool is_union_v = is_union<_Tp>::value;
2830 template <typename _Tp>
2831 inline constexpr bool is_class_v = is_class<_Tp>::value;
2832 template <typename _Tp>
2833 inline constexpr bool is_function_v = is_function<_Tp>::value;
2834 template <typename _Tp>
2835 inline constexpr bool is_reference_v = is_reference<_Tp>::value;
2836 template <typename _Tp>
2837 inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
2838 template <typename _Tp>
2839 inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
2840 template <typename _Tp>
2841 inline constexpr bool is_object_v = is_object<_Tp>::value;
2842 template <typename _Tp>
2843 inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
2844 template <typename _Tp>
2845 inline constexpr bool is_compound_v = is_compound<_Tp>::value;
2846 template <typename _Tp>
2847 inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
2848 template <typename _Tp>
2849 inline constexpr bool is_const_v = is_const<_Tp>::value;
2850 template <typename _Tp>
2851 inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
2852 template <typename _Tp>
2853 inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;
2854 template <typename _Tp>
2855 inline constexpr bool is_trivially_copyable_v =
2856 is_trivially_copyable<_Tp>::value;
2857 template <typename _Tp>
2858 inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
2859 template <typename _Tp>
2860 inline constexpr bool is_pod_v = is_pod<_Tp>::value;
2861 template <typename _Tp>
2862 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
2863 template <typename _Tp>
2864 inline constexpr bool is_empty_v = is_empty<_Tp>::value;
2865 template <typename _Tp>
2866 inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
2867 template <typename _Tp>
2868 inline constexpr bool is_abstract_v = is_abstract<_Tp>::value;
2869 template <typename _Tp>
2870 inline constexpr bool is_final_v = is_final<_Tp>::value;
2871 template <typename _Tp>
2872 inline constexpr bool is_signed_v = is_signed<_Tp>::value;
2873 template <typename _Tp>
2874 inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
2875 template <typename _Tp, typename... _Args>
2876 inline constexpr bool is_constructible_v =
2877 is_constructible<_Tp, _Args...>::value;
2878 template <typename _Tp>
2879 inline constexpr bool is_default_constructible_v =
2880 is_default_constructible<_Tp>::value;
2881 template <typename _Tp>
2882 inline constexpr bool is_copy_constructible_v =
2883 is_copy_constructible<_Tp>::value;
2884 template <typename _Tp>
2885 inline constexpr bool is_move_constructible_v =
2886 is_move_constructible<_Tp>::value;
2887 template <typename _Tp, typename _Up>
2888 inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value;
2889 template <typename _Tp>
2890 inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
2891 template <typename _Tp>
2892 inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
2893 template <typename _Tp>
2894 inline constexpr bool is_destructible_v = is_destructible<_Tp>::value;
2895 template <typename _Tp, typename... _Args>
2896 inline constexpr bool is_trivially_constructible_v =
2897 is_trivially_constructible<_Tp, _Args...>::value;
2898 template <typename _Tp>
2899 inline constexpr bool is_trivially_default_constructible_v =
2900 is_trivially_default_constructible<_Tp>::value;
2901 template <typename _Tp>
2902 inline constexpr bool is_trivially_copy_constructible_v =
2903 is_trivially_copy_constructible<_Tp>::value;
2904 template <typename _Tp>
2905 inline constexpr bool is_trivially_move_constructible_v =
2906 is_trivially_move_constructible<_Tp>::value;
2907 template <typename _Tp, typename _Up>
2908 inline constexpr bool is_trivially_assignable_v =
2909 is_trivially_assignable<_Tp, _Up>::value;
2910 template <typename _Tp>
2911 inline constexpr bool is_trivially_copy_assignable_v =
2912 is_trivially_copy_assignable<_Tp>::value;
2913 template <typename _Tp>
2914 inline constexpr bool is_trivially_move_assignable_v =
2915 is_trivially_move_assignable<_Tp>::value;
2916 template <typename _Tp>
2917 inline constexpr bool is_trivially_destructible_v =
2918 is_trivially_destructible<_Tp>::value;
2919 template <typename _Tp, typename... _Args>
2920 inline constexpr bool is_nothrow_constructible_v =
2921 is_nothrow_constructible<_Tp, _Args...>::value;
2922 template <typename _Tp>
2923 inline constexpr bool is_nothrow_default_constructible_v =
2924 is_nothrow_default_constructible<_Tp>::value;
2925 template <typename _Tp>
2926 inline constexpr bool is_nothrow_copy_constructible_v =
2927 is_nothrow_copy_constructible<_Tp>::value;
2928 template <typename _Tp>
2929 inline constexpr bool is_nothrow_move_constructible_v =
2930 is_nothrow_move_constructible<_Tp>::value;
2931 template <typename _Tp, typename _Up>
2932 inline constexpr bool is_nothrow_assignable_v =
2933 is_nothrow_assignable<_Tp, _Up>::value;
2934 template <typename _Tp>
2935 inline constexpr bool is_nothrow_copy_assignable_v =
2936 is_nothrow_copy_assignable<_Tp>::value;
2937 template <typename _Tp>
2938 inline constexpr bool is_nothrow_move_assignable_v =
2939 is_nothrow_move_assignable<_Tp>::value;
2940 template <typename _Tp>
2941 inline constexpr bool is_nothrow_destructible_v =
2942 is_nothrow_destructible<_Tp>::value;
2943 template <typename _Tp>
2944 inline constexpr bool has_virtual_destructor_v =
2945 has_virtual_destructor<_Tp>::value;
2946 template <typename _Tp>
2947 inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
2948 template <typename _Tp>
2949 inline constexpr size_t rank_v = rank<_Tp>::value;
2950 template <typename _Tp, unsigned _Idx = 0>
2951 inline constexpr size_t extent_v = extent<_Tp, _Idx>::value;
2952 template <typename _Tp, typename _Up>
2953 inline constexpr bool is_same_v = is_same<_Tp, _Up>::value;
2954 template <typename _Base, typename _Derived>
2955 inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
2956 template <typename _From, typename _To>
2957 inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
2959 #ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
2960 # define __cpp_lib_has_unique_object_representations 201606
2961 /// has_unique_object_representations
2962 template<typename _Tp>
2963 struct has_unique_object_representations
2964 : bool_constant<__has_unique_object_representations(
2965 remove_cv_t<remove_all_extents_t<_Tp>>
2969 template<typename _Tp>
2970 inline constexpr bool has_unique_object_representations_v
2971 = has_unique_object_representations<_Tp>::value;
2974 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE
2975 # define __cpp_lib_is_aggregate 201703
2977 template<typename _Tp>
2979 : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> { };
2982 template<typename _Tp>
2983 inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value;
2987 #if __cplusplus > 201703L
2991 little = __ORDER_LITTLE_ENDIAN__,
2992 big = __ORDER_BIG_ENDIAN__,
2993 native = __BYTE_ORDER__
2996 /// Remove references and cv-qualifiers.
2997 template<typename _Tp>
3000 using type = __remove_cvref_t<_Tp>;
3003 template<typename _Tp>
3004 using remove_cvref_t = __remove_cvref_t<_Tp>;
3006 /// Identity metafunction.
3007 template<typename _Tp>
3008 struct type_identity { using type = _Tp; };
3010 template<typename _Tp>
3011 using type_identity_t = typename type_identity<_Tp>::type;
3015 _GLIBCXX_END_NAMESPACE_VERSION
3020 #endif // _GLIBCXX_TYPE_TRAITS