608 template<
typename... _Elements>
614 using _TCC = _TupleConstraints<_Cond, _Elements...>;
617 template<
bool _Dummy>
618 using _ImplicitDefaultCtor = __enable_if_t<
619 _TCC<_Dummy>::__is_implicitly_default_constructible(),
623 template<
bool _Dummy>
624 using _ExplicitDefaultCtor = __enable_if_t<
625 _TCC<_Dummy>::__is_explicitly_default_constructible(),
629 template<
bool _Cond,
typename... _Args>
630 using _ImplicitCtor = __enable_if_t<
631 _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(),
635 template<
bool _Cond,
typename... _Args>
636 using _ExplicitCtor = __enable_if_t<
637 _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(),
640 template<
typename... _UElements>
642 __enable_if_t<
sizeof...(_UElements) ==
sizeof...(_Elements),
bool>
644 {
return __and_<is_assignable<_Elements&, _UElements>...>::value; }
647 template<
typename... _UElements>
648 static constexpr bool __nothrow_assignable()
651 __and_<is_nothrow_assignable<_Elements&, _UElements>...>::value;
655 template<
typename... _UElements>
656 static constexpr bool __nothrow_constructible()
659 __and_<is_nothrow_constructible<_Elements, _UElements>...>::value;
663 template<
typename _Up>
664 static constexpr bool __valid_args()
666 return sizeof...(_Elements) == 1
667 && !
is_same<tuple, __remove_cvref_t<_Up>>::value;
671 template<
typename,
typename,
typename... _Tail>
672 static constexpr bool __valid_args()
673 {
return (
sizeof...(_Tail) + 2) ==
sizeof...(_Elements); }
684 template<
typename _Tuple,
typename = tuple,
685 typename = __remove_cvref_t<_Tuple>>
691 template<
typename _Tuple,
typename _Tp,
typename _Up>
692 struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Up>>
693 : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>
697 template<
typename _Tuple,
typename _Tp>
698 struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Tp>>
705 template<
typename _Tuple>
706 static constexpr bool __use_other_ctor()
707 {
return _UseOtherCtor<_Tuple>::value; }
710 template<
typename _Dummy = void,
711 _ImplicitDefaultCtor<is_void<_Dummy>::value> =
true>
714 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
717 template<
typename _Dummy = void,
718 _ExplicitDefaultCtor<is_void<_Dummy>::value> =
false>
721 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
724 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
725 _ImplicitCtor<_NotEmpty, const _Elements&...> =
true>
727 tuple(
const _Elements&... __elements)
728 noexcept(__nothrow_constructible<
const _Elements&...>())
729 : _Inherited(__elements...) { }
731 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
732 _ExplicitCtor<_NotEmpty, const _Elements&...> =
false>
734 tuple(
const _Elements&... __elements)
735 noexcept(__nothrow_constructible<
const _Elements&...>())
736 : _Inherited(__elements...) { }
738 template<
typename... _UElements,
739 bool _Valid = __valid_args<_UElements...>(),
740 _ImplicitCtor<_Valid, _UElements...> =
true>
742 tuple(_UElements&&... __elements)
743 noexcept(__nothrow_constructible<_UElements...>())
746 template<
typename... _UElements,
747 bool _Valid = __valid_args<_UElements...>(),
748 _ExplicitCtor<_Valid, _UElements...> =
false>
750 tuple(_UElements&&... __elements)
751 noexcept(__nothrow_constructible<_UElements...>())
754 constexpr tuple(
const tuple&) =
default;
756 constexpr tuple(tuple&&) =
default;
758 template<
typename... _UElements,
759 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
760 && !__use_other_ctor<
const tuple<_UElements...>&>(),
761 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
763 tuple(
const tuple<_UElements...>& __in)
764 noexcept(__nothrow_constructible<
const _UElements&...>())
765 : _Inherited(
static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
768 template<
typename... _UElements,
769 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
770 && !__use_other_ctor<
const tuple<_UElements...>&>(),
771 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
773 tuple(
const tuple<_UElements...>& __in)
774 noexcept(__nothrow_constructible<
const _UElements&...>())
775 : _Inherited(
static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
778 template<
typename... _UElements,
779 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
780 && !__use_other_ctor<tuple<_UElements...>&&>(),
781 _ImplicitCtor<_Valid, _UElements...> =
true>
783 tuple(tuple<_UElements...>&& __in)
784 noexcept(__nothrow_constructible<_UElements...>())
785 : _Inherited(
static_cast<_Tuple_impl<0, _UElements...
>&&>(__in)) { }
787 template<
typename... _UElements,
788 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
789 && !__use_other_ctor<tuple<_UElements...>&&>(),
790 _ExplicitCtor<_Valid, _UElements...> =
false>
792 tuple(tuple<_UElements...>&& __in)
793 noexcept(__nothrow_constructible<_UElements...>())
794 : _Inherited(
static_cast<_Tuple_impl<0, _UElements...
>&&>(__in)) { }
798 template<
typename _Alloc,
799 _ImplicitDefaultCtor<is_object<_Alloc>::value> =
true>
801 tuple(allocator_arg_t __tag,
const _Alloc& __a)
802 : _Inherited(__tag, __a) { }
804 template<
typename _Alloc,
805 _ExplicitDefaultCtor<is_object<_Alloc>::value> =
false>
808 tuple(allocator_arg_t __tag,
const _Alloc& __a)
809 : _Inherited(__tag, __a) { }
811 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
812 _ImplicitCtor<_NotEmpty, const _Elements&...> =
true>
814 tuple(allocator_arg_t __tag,
const _Alloc& __a,
815 const _Elements&... __elements)
816 : _Inherited(__tag, __a, __elements...) { }
818 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
819 _ExplicitCtor<_NotEmpty, const _Elements&...> =
false>
822 tuple(allocator_arg_t __tag,
const _Alloc& __a,
823 const _Elements&... __elements)
824 : _Inherited(__tag, __a, __elements...) { }
826 template<
typename _Alloc,
typename... _UElements,
827 bool _Valid = __valid_args<_UElements...>(),
828 _ImplicitCtor<_Valid, _UElements...> =
true>
830 tuple(allocator_arg_t __tag,
const _Alloc& __a,
831 _UElements&&... __elements)
835 template<
typename _Alloc,
typename... _UElements,
836 bool _Valid = __valid_args<_UElements...>(),
837 _ExplicitCtor<_Valid, _UElements...> =
false>
840 tuple(allocator_arg_t __tag,
const _Alloc& __a,
841 _UElements&&... __elements)
845 template<
typename _Alloc>
847 tuple(allocator_arg_t __tag,
const _Alloc& __a,
const tuple& __in)
848 : _Inherited(__tag, __a,
static_cast<const _Inherited&
>(__in)) { }
850 template<
typename _Alloc>
852 tuple(allocator_arg_t __tag,
const _Alloc& __a, tuple&& __in)
853 : _Inherited(__tag, __a,
static_cast<_Inherited&&
>(__in)) { }
855 template<
typename _Alloc,
typename... _UElements,
856 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
857 && !__use_other_ctor<
const tuple<_UElements...>&>(),
858 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
860 tuple(allocator_arg_t __tag,
const _Alloc& __a,
861 const tuple<_UElements...>& __in)
862 : _Inherited(__tag, __a,
863 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
866 template<
typename _Alloc,
typename... _UElements,
867 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
868 && !__use_other_ctor<
const tuple<_UElements...>&>(),
869 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
872 tuple(allocator_arg_t __tag,
const _Alloc& __a,
873 const tuple<_UElements...>& __in)
874 : _Inherited(__tag, __a,
875 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
878 template<
typename _Alloc,
typename... _UElements,
879 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
880 && !__use_other_ctor<tuple<_UElements...>&&>(),
881 _ImplicitCtor<_Valid, _UElements...> =
true>
883 tuple(allocator_arg_t __tag,
const _Alloc& __a,
884 tuple<_UElements...>&& __in)
885 : _Inherited(__tag, __a,
886 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
889 template<
typename _Alloc,
typename... _UElements,
890 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
891 && !__use_other_ctor<tuple<_UElements...>&&>(),
892 _ExplicitCtor<_Valid, _UElements...> =
false>
895 tuple(allocator_arg_t __tag,
const _Alloc& __a,
896 tuple<_UElements...>&& __in)
897 : _Inherited(__tag, __a,
898 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
905 operator=(
typename conditional<__assignable<const _Elements&...>(),
907 const __nonesuch&>
::type __in)
908 noexcept(__nothrow_assignable<
const _Elements&...>())
910 this->_M_assign(__in);
916 operator=(
typename conditional<__assignable<_Elements...>(),
919 noexcept(__nothrow_assignable<_Elements...>())
925 template<
typename... _UElements>
927 __enable_if_t<__assignable<
const _UElements&...>(), tuple&>
928 operator=(
const tuple<_UElements...>& __in)
929 noexcept(__nothrow_assignable<
const _UElements&...>())
931 this->_M_assign(__in);
935 template<
typename... _UElements>
937 __enable_if_t<__assignable<_UElements...>(), tuple&>
938 operator=(tuple<_UElements...>&& __in)
939 noexcept(__nothrow_assignable<_UElements...>())
949 noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value)
950 { _Inherited::_M_swap(__in); }
987 template<
typename _T1,
typename _T2>
988 class tuple<_T1, _T2> :
public _Tuple_impl<0, _T1, _T2>
993 template<
bool _Dummy,
typename _U1,
typename _U2>
994 using _ImplicitDefaultCtor = __enable_if_t<
995 _TupleConstraints<_Dummy, _U1, _U2>::
996 __is_implicitly_default_constructible(),
1000 template<
bool _Dummy,
typename _U1,
typename _U2>
1001 using _ExplicitDefaultCtor = __enable_if_t<
1002 _TupleConstraints<_Dummy, _U1, _U2>::
1003 __is_explicitly_default_constructible(),
1006 template<
bool _Dummy>
1007 using _TCC = _TupleConstraints<_Dummy, _T1, _T2>;
1010 template<
bool _Cond,
typename _U1,
typename _U2>
1011 using _ImplicitCtor = __enable_if_t<
1012 _TCC<_Cond>::template __is_implicitly_constructible<_U1, _U2>(),
1016 template<
bool _Cond,
typename _U1,
typename _U2>
1017 using _ExplicitCtor = __enable_if_t<
1018 _TCC<_Cond>::template __is_explicitly_constructible<_U1, _U2>(),
1021 template<
typename _U1,
typename _U2>
1022 static constexpr bool __assignable()
1024 return __and_<is_assignable<_T1&, _U1>,
1028 template<
typename _U1,
typename _U2>
1029 static constexpr bool __nothrow_assignable()
1031 return __and_<is_nothrow_assignable<_T1&, _U1>,
1035 template<
typename _U1,
typename _U2>
1036 static constexpr bool __nothrow_constructible()
1038 return __and_<is_nothrow_constructible<_T1, _U1>,
1042 static constexpr bool __nothrow_default_constructible()
1044 return __and_<is_nothrow_default_constructible<_T1>,
1048 template<
typename _U1>
1049 static constexpr bool __is_alloc_arg()
1053 template<
bool _Dummy =
true,
1054 _ImplicitDefaultCtor<_Dummy, _T1, _T2> =
true>
1057 noexcept(__nothrow_default_constructible())
1060 template<
bool _Dummy =
true,
1061 _ExplicitDefaultCtor<_Dummy, _T1, _T2> =
false>
1064 noexcept(__nothrow_default_constructible())
1067 template<
bool _Dummy =
true,
1068 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1070 tuple(
const _T1& __a1,
const _T2& __a2)
1071 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
1072 : _Inherited(__a1, __a2) { }
1074 template<
bool _Dummy =
true,
1075 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1077 tuple(
const _T1& __a1,
const _T2& __a2)
1078 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
1079 : _Inherited(__a1, __a2) { }
1081 template<
typename _U1,
typename _U2,
1082 _ImplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
true>
1084 tuple(_U1&& __a1, _U2&& __a2)
1085 noexcept(__nothrow_constructible<_U1, _U2>())
1088 template<
typename _U1,
typename _U2,
1089 _ExplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
false>
1091 tuple(_U1&& __a1, _U2&& __a2)
1092 noexcept(__nothrow_constructible<_U1, _U2>())
1095 constexpr tuple(
const tuple&) =
default;
1097 constexpr tuple(tuple&&) =
default;
1099 template<
typename _U1,
typename _U2,
1100 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1102 tuple(
const tuple<_U1, _U2>& __in)
1103 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1106 template<
typename _U1,
typename _U2,
1107 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1109 tuple(
const tuple<_U1, _U2>& __in)
1110 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1113 template<
typename _U1,
typename _U2,
1114 _ImplicitCtor<true, _U1, _U2> =
true>
1116 tuple(tuple<_U1, _U2>&& __in)
1117 noexcept(__nothrow_constructible<_U1, _U2>())
1120 template<
typename _U1,
typename _U2,
1121 _ExplicitCtor<true, _U1, _U2> =
false>
1123 tuple(tuple<_U1, _U2>&& __in)
1124 noexcept(__nothrow_constructible<_U1, _U2>())
1127 template<
typename _U1,
typename _U2,
1128 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1131 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1132 : _Inherited(__in.first, __in.second) { }
1134 template<
typename _U1,
typename _U2,
1135 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1138 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1139 : _Inherited(__in.first, __in.second) { }
1141 template<
typename _U1,
typename _U2,
1142 _ImplicitCtor<true, _U1, _U2> =
true>
1145 noexcept(__nothrow_constructible<_U1, _U2>())
1149 template<
typename _U1,
typename _U2,
1150 _ExplicitCtor<true, _U1, _U2> =
false>
1153 noexcept(__nothrow_constructible<_U1, _U2>())
1159 template<
typename _Alloc,
1160 _ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> =
true>
1161 _GLIBCXX20_CONSTEXPR
1162 tuple(allocator_arg_t __tag,
const _Alloc& __a)
1163 : _Inherited(__tag, __a) { }
1165 template<
typename _Alloc,
1166 _ExplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> =
false>
1167 _GLIBCXX20_CONSTEXPR
1169 tuple(allocator_arg_t __tag,
const _Alloc& __a)
1170 : _Inherited(__tag, __a) { }
1172 template<
typename _Alloc,
bool _Dummy =
true,
1173 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1174 _GLIBCXX20_CONSTEXPR
1175 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1176 const _T1& __a1,
const _T2& __a2)
1177 : _Inherited(__tag, __a, __a1, __a2) { }
1179 template<
typename _Alloc,
bool _Dummy =
true,
1180 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1182 _GLIBCXX20_CONSTEXPR
1183 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1184 const _T1& __a1,
const _T2& __a2)
1185 : _Inherited(__tag, __a, __a1, __a2) { }
1187 template<
typename _Alloc,
typename _U1,
typename _U2,
1188 _ImplicitCtor<true, _U1, _U2> =
true>
1189 _GLIBCXX20_CONSTEXPR
1190 tuple(allocator_arg_t __tag,
const _Alloc& __a, _U1&& __a1, _U2&& __a2)
1194 template<
typename _Alloc,
typename _U1,
typename _U2,
1195 _ExplicitCtor<true, _U1, _U2> =
false>
1197 _GLIBCXX20_CONSTEXPR
1198 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1199 _U1&& __a1, _U2&& __a2)
1203 template<
typename _Alloc>
1204 _GLIBCXX20_CONSTEXPR
1205 tuple(allocator_arg_t __tag,
const _Alloc& __a,
const tuple& __in)
1206 : _Inherited(__tag, __a,
static_cast<const _Inherited&
>(__in)) { }
1208 template<
typename _Alloc>
1209 _GLIBCXX20_CONSTEXPR
1210 tuple(allocator_arg_t __tag,
const _Alloc& __a, tuple&& __in)
1211 : _Inherited(__tag, __a,
static_cast<_Inherited&&
>(__in)) { }
1213 template<
typename _Alloc,
typename _U1,
typename _U2,
1214 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1215 _GLIBCXX20_CONSTEXPR
1216 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1217 const tuple<_U1, _U2>& __in)
1218 : _Inherited(__tag, __a,
1222 template<
typename _Alloc,
typename _U1,
typename _U2,
1223 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1225 _GLIBCXX20_CONSTEXPR
1226 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1227 const tuple<_U1, _U2>& __in)
1228 : _Inherited(__tag, __a,
1232 template<
typename _Alloc,
typename _U1,
typename _U2,
1233 _ImplicitCtor<true, _U1, _U2> =
true>
1234 _GLIBCXX20_CONSTEXPR
1235 tuple(allocator_arg_t __tag,
const _Alloc& __a, tuple<_U1, _U2>&& __in)
1239 template<
typename _Alloc,
typename _U1,
typename _U2,
1240 _ExplicitCtor<true, _U1, _U2> =
false>
1242 _GLIBCXX20_CONSTEXPR
1243 tuple(allocator_arg_t __tag,
const _Alloc& __a, tuple<_U1, _U2>&& __in)
1247 template<
typename _Alloc,
typename _U1,
typename _U2,
1248 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1249 _GLIBCXX20_CONSTEXPR
1250 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1252 : _Inherited(__tag, __a, __in.first, __in.second) { }
1254 template<
typename _Alloc,
typename _U1,
typename _U2,
1255 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1257 _GLIBCXX20_CONSTEXPR
1258 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1260 : _Inherited(__tag, __a, __in.first, __in.second) { }
1262 template<
typename _Alloc,
typename _U1,
typename _U2,
1263 _ImplicitCtor<true, _U1, _U2> =
true>
1264 _GLIBCXX20_CONSTEXPR
1265 tuple(allocator_arg_t __tag,
const _Alloc& __a,
pair<_U1, _U2>&& __in)
1269 template<
typename _Alloc,
typename _U1,
typename _U2,
1270 _ExplicitCtor<true, _U1, _U2> =
false>
1272 _GLIBCXX20_CONSTEXPR
1273 tuple(allocator_arg_t __tag,
const _Alloc& __a,
pair<_U1, _U2>&& __in)
1279 _GLIBCXX20_CONSTEXPR
1281 operator=(
typename conditional<__assignable<const _T1&, const _T2&>(),
1283 const __nonesuch&>
::type __in)
1284 noexcept(__nothrow_assignable<const _T1&, const _T2&>())
1286 this->_M_assign(__in);
1290 _GLIBCXX20_CONSTEXPR
1292 operator=(
typename conditional<__assignable<_T1, _T2>(),
1294 __nonesuch&&>
::type __in)
1295 noexcept(__nothrow_assignable<_T1, _T2>())
1301 template<
typename _U1,
typename _U2>
1302 _GLIBCXX20_CONSTEXPR
1303 __enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&>
1304 operator=(
const tuple<_U1, _U2>& __in)
1305 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1307 this->_M_assign(__in);
1311 template<
typename _U1,
typename _U2>
1312 _GLIBCXX20_CONSTEXPR
1313 __enable_if_t<__assignable<_U1, _U2>(), tuple&>
1314 operator=(tuple<_U1, _U2>&& __in)
1315 noexcept(__nothrow_assignable<_U1, _U2>())
1321 template<
typename _U1,
typename _U2>
1322 _GLIBCXX20_CONSTEXPR
1323 __enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&>
1325 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1327 this->_M_head(*
this) = __in.first;
1328 this->_M_tail(*this)._M_head(*
this) = __in.second;
1332 template<
typename _U1,
typename _U2>
1333 _GLIBCXX20_CONSTEXPR
1334 __enable_if_t<__assignable<_U1, _U2>(), tuple&>
1336 noexcept(__nothrow_assignable<_U1, _U2>())
1343 _GLIBCXX20_CONSTEXPR
1346 noexcept(__and_<__is_nothrow_swappable<_T1>,
1347 __is_nothrow_swappable<_T2>>::value)
1348 { _Inherited::_M_swap(__in); }