29 #ifndef _GLIBCXX_TUPLE
30 #define _GLIBCXX_TUPLE 1
32 #pragma GCC system_header
34 #if __cplusplus < 201103L
40 #include <bits/uses_allocator.h>
42 #if __cplusplus > 201703L
44 # define __cpp_lib_constexpr_tuple 201811L
47 namespace std _GLIBCXX_VISIBILITY(default)
49 _GLIBCXX_BEGIN_NAMESPACE_VERSION
56 template<
typename... _Elements>
59 template<
typename _Tp>
60 struct __is_empty_non_tuple : is_empty<_Tp> { };
63 template<
typename _El0,
typename... _El>
64 struct __is_empty_non_tuple<tuple<_El0, _El...>> :
false_type { };
67 template<
typename _Tp>
68 using __empty_not_final
69 =
typename conditional<__is_final(_Tp),
false_type,
70 __is_empty_non_tuple<_Tp>>::type;
72 template<std::size_t _Idx,
typename _Head,
73 bool = __empty_not_final<_Head>::value>
76 template<std::
size_t _Idx,
typename _Head>
77 struct _Head_base<_Idx, _Head, true>
80 constexpr _Head_base()
83 constexpr _Head_base(
const _Head& __h)
86 constexpr _Head_base(
const _Head_base&) =
default;
87 constexpr _Head_base(_Head_base&&) =
default;
89 template<
typename _UHead>
90 constexpr _Head_base(_UHead&& __h)
94 _Head_base(allocator_arg_t, __uses_alloc0)
97 template<
typename _Alloc>
99 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
100 : _Head(allocator_arg, *__a._M_a) { }
102 template<
typename _Alloc>
104 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
105 : _Head(*__a._M_a) { }
107 template<
typename _UHead>
109 _Head_base(__uses_alloc0, _UHead&& __uhead)
112 template<
typename _Alloc,
typename _UHead>
114 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
115 : _Head(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead)) { }
117 template<
typename _Alloc,
typename _UHead>
119 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
120 : _Head(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
122 static constexpr _Head&
123 _M_head(_Head_base& __b) noexcept {
return __b; }
125 static constexpr
const _Head&
126 _M_head(
const _Head_base& __b) noexcept {
return __b; }
129 template<std::
size_t _Idx,
typename _Head>
130 struct _Head_base<_Idx, _Head, false>
132 constexpr _Head_base()
135 constexpr _Head_base(
const _Head& __h)
136 : _M_head_impl(__h) { }
138 constexpr _Head_base(
const _Head_base&) =
default;
139 constexpr _Head_base(_Head_base&&) =
default;
141 template<
typename _UHead>
142 constexpr _Head_base(_UHead&& __h)
146 _Head_base(allocator_arg_t, __uses_alloc0)
149 template<
typename _Alloc>
151 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
152 : _M_head_impl(allocator_arg, *__a._M_a) { }
154 template<
typename _Alloc>
156 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
157 : _M_head_impl(*__a._M_a) { }
159 template<
typename _UHead>
161 _Head_base(__uses_alloc0, _UHead&& __uhead)
162 : _M_head_impl(
std::
forward<_UHead>(__uhead)) { }
164 template<
typename _Alloc,
typename _UHead>
166 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
167 : _M_head_impl(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead))
170 template<
typename _Alloc,
typename _UHead>
172 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
173 : _M_head_impl(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
175 static constexpr _Head&
176 _M_head(_Head_base& __b) noexcept {
return __b._M_head_impl; }
178 static constexpr
const _Head&
179 _M_head(
const _Head_base& __b) noexcept {
return __b._M_head_impl; }
192 template<std::size_t _Idx,
typename... _Elements>
200 template<std::size_t _Idx,
typename _Head,
typename... _Tail>
203 private _Head_base<_Idx, _Head>
205 template<std::size_t,
typename...>
friend class _Tuple_impl;
208 typedef _Head_base<_Idx, _Head> _Base;
210 static constexpr _Head&
211 _M_head(
_Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
213 static constexpr
const _Head&
214 _M_head(
const _Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
220 _M_tail(
const _Tuple_impl& __t) noexcept {
return __t; }
226 constexpr
_Tuple_impl(
const _Head& __head,
const _Tail&... __tail)
229 template<
typename _UHead,
typename... _UTail,
typename =
typename
230 enable_if<
sizeof...(_Tail) ==
sizeof...(_UTail)>::type>
232 constexpr
_Tuple_impl(_UHead&& __head, _UTail&&... __tail)
233 :
_Inherited(std::forward<_UTail>(__tail)...),
234 _Base(std::forward<_UHead>(__head)) { }
247 _Base(std::forward<_Head>(_M_head(__in))) { }
249 template<
typename... _UElements>
254 template<
typename _UHead,
typename... _UTails>
258 _Base(std::forward<_UHead>
261 template<
typename _Alloc>
265 _Base(__tag, __use_alloc<_Head>(__a)) { }
267 template<
typename _Alloc>
270 const _Head& __head,
const _Tail&... __tail)
272 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
274 template<
typename _Alloc,
typename _UHead,
typename... _UTail,
275 typename =
typename enable_if<
sizeof...(_Tail)
276 ==
sizeof...(_UTail)>::type>
279 _UHead&& __head, _UTail&&... __tail)
280 :
_Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
281 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
282 std::forward<_UHead>(__head)) { }
284 template<
typename _Alloc>
289 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
291 template<
typename _Alloc>
296 _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
297 std::forward<_Head>(_M_head(__in))) { }
299 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
305 _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
308 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
314 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
318 template<
typename... _UElements>
324 _M_tail(*this)._M_assign(
328 template<
typename _UHead,
typename... _UTails>
333 _M_head(*
this) = std::forward<_UHead>
335 _M_tail(*this)._M_assign(
345 swap(_M_head(*
this), _M_head(__in));
346 _Inherited::_M_swap(_M_tail(__in));
351 template<std::
size_t _Idx,
typename _Head>
353 :
private _Head_base<_Idx, _Head>
355 template<std::size_t,
typename...>
friend class _Tuple_impl;
357 typedef _Head_base<_Idx, _Head> _Base;
359 static constexpr _Head&
360 _M_head(
_Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
362 static constexpr
const _Head&
363 _M_head(
const _Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
365 constexpr _Tuple_impl()
369 constexpr _Tuple_impl(
const _Head& __head)
372 template<
typename _UHead>
374 constexpr _Tuple_impl(_UHead&& __head)
377 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
381 _Tuple_impl& operator=(
const _Tuple_impl&) =
delete;
384 _Tuple_impl(_Tuple_impl&& __in)
385 noexcept(is_nothrow_move_constructible<_Head>::value)
386 : _Base(
std::
forward<_Head>(_M_head(__in))) { }
388 template<
typename _UHead>
390 : _Base(
_Tuple_impl<_Idx, _UHead>::_M_head(__in)) { }
392 template<
typename _UHead>
397 template<
typename _Alloc>
399 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a)
400 : _Base(__tag, __use_alloc<_Head>(__a)) { }
402 template<
typename _Alloc>
404 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
406 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
408 template<
typename _Alloc,
typename _UHead>
410 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
412 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
415 template<
typename _Alloc>
417 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
418 const _Tuple_impl& __in)
419 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
421 template<
typename _Alloc>
423 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
425 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
428 template<
typename _Alloc,
typename _UHead>
430 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
431 const _Tuple_impl<_Idx, _UHead>& __in)
432 : _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
433 _Tuple_impl<_Idx, _UHead>::_M_head(__in)) { }
435 template<
typename _Alloc,
typename _UHead>
437 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
438 _Tuple_impl<_Idx, _UHead>&& __in)
439 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
440 std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
443 template<
typename _UHead>
446 _M_assign(
const _Tuple_impl<_Idx, _UHead>& __in)
448 _M_head(*
this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in);
451 template<
typename _UHead>
454 _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
457 = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
463 _M_swap(_Tuple_impl& __in)
466 swap(_M_head(*
this), _M_head(__in));
472 template<bool,
typename... _Types>
473 struct _TupleConstraints
475 template<
typename _Tp,
typename _Up>
476 using is_constructible
477 = __bool_constant<__is_constructible(_Tp, _Up)>;
482 template<
typename... _UTypes>
483 static constexpr
bool __is_implicitly_constructible()
485 return __and_<is_constructible<_Types, _UTypes>...,
486 is_convertible<_UTypes, _Types>...
493 template<
typename... _UTypes>
494 static constexpr
bool __is_explicitly_constructible()
496 return __and_<is_constructible<_Types, _UTypes>...,
497 __not_<__and_<is_convertible<_UTypes, _Types>...>>
501 static constexpr
bool __is_implicitly_default_constructible()
503 return __and_<std::__is_implicitly_default_constructible<_Types>...
507 static constexpr
bool __is_explicitly_default_constructible()
509 return __and_<is_default_constructible<_Types>...,
511 std::__is_implicitly_default_constructible<_Types>...>
518 template<
typename... _Types>
519 struct _TupleConstraints<false, _Types...>
521 template<
typename... _UTypes>
522 static constexpr
bool __is_implicitly_constructible()
525 template<
typename... _UTypes>
526 static constexpr
bool __is_explicitly_constructible()
531 template<
typename... _Elements>
537 using _TCC = _TupleConstraints<_Cond, _Elements...>;
540 template<
bool _Dummy>
541 using _ImplicitDefaultCtor = __enable_if_t<
542 _TCC<_Dummy>::__is_implicitly_default_constructible(),
546 template<
bool _Dummy>
547 using _ExplicitDefaultCtor = __enable_if_t<
548 _TCC<_Dummy>::__is_explicitly_default_constructible(),
552 template<
bool _Cond,
typename... _Args>
553 using _ImplicitCtor = __enable_if_t<
554 _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(),
558 template<
bool _Cond,
typename... _Args>
559 using _ExplicitCtor = __enable_if_t<
560 _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(),
563 template<
typename... _UElements>
565 __enable_if_t<
sizeof...(_UElements) ==
sizeof...(_Elements),
bool>
567 {
return __and_<is_assignable<_Elements&, _UElements>...>::value; }
570 template<
typename... _UElements>
571 static constexpr
bool __nothrow_assignable()
574 __and_<is_nothrow_assignable<_Elements&, _UElements>...>::value;
578 template<
typename... _UElements>
579 static constexpr
bool __nothrow_constructible()
582 __and_<is_nothrow_constructible<_Elements, _UElements>...>::value;
586 template<
typename _Up>
587 static constexpr
bool __valid_args()
589 return sizeof...(_Elements) == 1
594 template<
typename,
typename,
typename... _Tail>
595 static constexpr
bool __valid_args()
596 {
return (
sizeof...(_Tail) + 2) ==
sizeof...(_Elements); }
607 template<
typename _Tuple,
typename =
tuple,
608 typename = __remove_cvref_t<_Tuple>>
614 template<
typename _Tuple,
typename _Tp,
typename _Up>
615 struct _UseOtherCtor<_Tuple,
tuple<_Tp>,
tuple<_Up>>
616 : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>
620 template<
typename _Tuple,
typename _Tp>
621 struct _UseOtherCtor<_Tuple,
tuple<_Tp>,
tuple<_Tp>>
628 template<
typename _Tuple>
629 static constexpr
bool __use_other_ctor()
630 {
return _UseOtherCtor<_Tuple>::value; }
633 template<
typename _Dummy = void,
634 _ImplicitDefaultCtor<is_void<_Dummy>::value> =
true>
640 template<
typename _Dummy = void,
641 _ExplicitDefaultCtor<is_void<_Dummy>::value> =
false>
647 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
648 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
650 tuple(
const _Elements&... __elements)
651 noexcept(__nothrow_constructible<const _Elements&...>())
654 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
655 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
657 tuple(
const _Elements&... __elements)
658 noexcept(__nothrow_constructible<const _Elements&...>())
661 template<
typename... _UElements,
662 bool _Valid = __valid_args<_UElements...>(),
663 _ImplicitCtor<_Valid, _UElements...> =
true>
665 tuple(_UElements&&... __elements)
666 noexcept(__nothrow_constructible<_UElements...>())
667 :
_Inherited(std::forward<_UElements>(__elements)...) { }
669 template<
typename... _UElements,
670 bool _Valid = __valid_args<_UElements...>(),
671 _ExplicitCtor<_Valid, _UElements...> =
false>
673 tuple(_UElements&&... __elements)
674 noexcept(__nothrow_constructible<_UElements...>())
675 :
_Inherited(std::forward<_UElements>(__elements)...) { }
681 template<
typename... _UElements,
682 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
684 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
687 noexcept(__nothrow_constructible<const _UElements&...>())
691 template<
typename... _UElements,
692 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
694 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
697 noexcept(__nothrow_constructible<const _UElements&...>())
701 template<
typename... _UElements,
702 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
704 _ImplicitCtor<_Valid, _UElements...> =
true>
707 noexcept(__nothrow_constructible<_UElements...>())
710 template<
typename... _UElements,
711 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
713 _ExplicitCtor<_Valid, _UElements...> =
false>
716 noexcept(__nothrow_constructible<_UElements...>())
721 template<
typename _Alloc,
722 _ImplicitDefaultCtor<is_object<_Alloc>::value> =
true>
727 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
728 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
731 const _Elements&... __elements)
734 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
735 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
739 const _Elements&... __elements)
742 template<
typename _Alloc,
typename... _UElements,
743 bool _Valid = __valid_args<_UElements...>(),
744 _ImplicitCtor<_Valid, _UElements...> =
true>
747 _UElements&&... __elements)
748 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
751 template<
typename _Alloc,
typename... _UElements,
752 bool _Valid = __valid_args<_UElements...>(),
753 _ExplicitCtor<_Valid, _UElements...> =
false>
757 _UElements&&... __elements)
758 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
761 template<
typename _Alloc>
766 template<
typename _Alloc>
771 template<
typename _Alloc,
typename... _UElements,
772 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
774 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
779 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
782 template<
typename _Alloc,
typename... _UElements,
783 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
785 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
791 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
794 template<
typename _Alloc,
typename... _UElements,
795 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
797 _ImplicitCtor<_Valid, _UElements...> =
true>
802 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
805 template<
typename _Alloc,
typename... _UElements,
806 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
808 _ExplicitCtor<_Valid, _UElements...> =
false>
814 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
821 operator=(
typename conditional<__assignable<const _Elements&...>(),
823 const __nonesuch&>::type __in)
824 noexcept(__nothrow_assignable<const _Elements&...>())
826 this->_M_assign(__in);
832 operator=(
typename conditional<__assignable<_Elements...>(),
834 __nonesuch&&>::type __in)
835 noexcept(__nothrow_assignable<_Elements...>())
841 template<
typename... _UElements>
843 __enable_if_t<__assignable<
const _UElements&...>(),
tuple&>
845 noexcept(__nothrow_assignable<const _UElements&...>())
847 this->_M_assign(__in);
851 template<
typename... _UElements>
853 __enable_if_t<__assignable<_UElements...>(),
tuple&>
855 noexcept(__nothrow_assignable<_UElements...>())
865 noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value)
866 { _Inherited::_M_swap(__in); }
869 #if __cpp_deduction_guides >= 201606
870 template<
typename... _UTypes>
872 template<
typename _T1,
typename _T2>
874 template<
typename _Alloc,
typename... _UTypes>
876 template<
typename _Alloc,
typename _T1,
typename _T2>
878 template<
typename _Alloc,
typename... _UTypes>
888 void swap(
tuple&) noexcept { }
893 template<
typename _Alloc>
895 tuple(allocator_arg_t,
const _Alloc&) noexcept { }
896 template<
typename _Alloc>
898 tuple(allocator_arg_t,
const _Alloc&,
const tuple&) noexcept { }
903 template<
typename _T1,
typename _T2>
909 template<
bool _Dummy,
typename _U1,
typename _U2>
910 using _ImplicitDefaultCtor = __enable_if_t<
911 _TupleConstraints<_Dummy, _U1, _U2>::
912 __is_implicitly_default_constructible(),
916 template<
bool _Dummy,
typename _U1,
typename _U2>
917 using _ExplicitDefaultCtor = __enable_if_t<
918 _TupleConstraints<_Dummy, _U1, _U2>::
919 __is_explicitly_default_constructible(),
922 template<
bool _Dummy>
923 using _TCC = _TupleConstraints<_Dummy, _T1, _T2>;
926 template<
bool _Cond,
typename _U1,
typename _U2>
927 using _ImplicitCtor = __enable_if_t<
928 _TCC<_Cond>::template __is_implicitly_constructible<_U1, _U2>(),
932 template<
bool _Cond,
typename _U1,
typename _U2>
933 using _ExplicitCtor = __enable_if_t<
934 _TCC<_Cond>::template __is_explicitly_constructible<_U1, _U2>(),
937 template<
typename _U1,
typename _U2>
938 static constexpr
bool __assignable()
940 return __and_<is_assignable<_T1&, _U1>,
944 template<
typename _U1,
typename _U2>
945 static constexpr
bool __nothrow_assignable()
947 return __and_<is_nothrow_assignable<_T1&, _U1>,
951 template<
typename _U1,
typename _U2>
952 static constexpr
bool __nothrow_constructible()
954 return __and_<is_nothrow_constructible<_T1, _U1>,
958 static constexpr
bool __nothrow_default_constructible()
960 return __and_<is_nothrow_default_constructible<_T1>,
964 template<
typename _U1>
965 static constexpr
bool __is_alloc_arg()
969 template<
bool _Dummy =
true,
970 _ImplicitDefaultCtor<_Dummy, _T1, _T2> =
true>
973 noexcept(__nothrow_default_constructible())
976 template<
bool _Dummy =
true,
977 _ExplicitDefaultCtor<_Dummy, _T1, _T2> =
false>
980 noexcept(__nothrow_default_constructible())
983 template<
bool _Dummy =
true,
984 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
986 tuple(
const _T1& __a1,
const _T2& __a2)
987 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
990 template<
bool _Dummy =
true,
991 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
993 tuple(
const _T1& __a1,
const _T2& __a2)
994 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
997 template<
typename _U1,
typename _U2,
998 _ImplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
true>
1000 tuple(_U1&& __a1, _U2&& __a2)
1001 noexcept(__nothrow_constructible<_U1, _U2>())
1002 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
1004 template<
typename _U1,
typename _U2,
1005 _ExplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
false>
1007 tuple(_U1&& __a1, _U2&& __a2)
1008 noexcept(__nothrow_constructible<_U1, _U2>())
1009 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
1015 template<
typename _U1,
typename _U2,
1016 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1019 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1022 template<
typename _U1,
typename _U2,
1023 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1026 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1029 template<
typename _U1,
typename _U2,
1030 _ImplicitCtor<true, _U1, _U2> =
true>
1033 noexcept(__nothrow_constructible<_U1, _U2>())
1036 template<
typename _U1,
typename _U2,
1037 _ExplicitCtor<true, _U1, _U2> =
false>
1040 noexcept(__nothrow_constructible<_U1, _U2>())
1043 template<
typename _U1,
typename _U2,
1044 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1047 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1050 template<
typename _U1,
typename _U2,
1051 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1054 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1057 template<
typename _U1,
typename _U2,
1058 _ImplicitCtor<true, _U1, _U2> =
true>
1061 noexcept(__nothrow_constructible<_U1, _U2>())
1063 std::forward<_U2>(__in.second)) { }
1065 template<
typename _U1,
typename _U2,
1066 _ExplicitCtor<true, _U1, _U2> =
false>
1069 noexcept(__nothrow_constructible<_U1, _U2>())
1071 std::forward<_U2>(__in.second)) { }
1075 template<
typename _Alloc,
1076 _ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> =
true>
1077 _GLIBCXX20_CONSTEXPR
1081 template<
typename _Alloc,
bool _Dummy =
true,
1082 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1083 _GLIBCXX20_CONSTEXPR
1085 const _T1& __a1,
const _T2& __a2)
1088 template<
typename _Alloc,
bool _Dummy =
true,
1089 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1091 _GLIBCXX20_CONSTEXPR
1093 const _T1& __a1,
const _T2& __a2)
1096 template<
typename _Alloc,
typename _U1,
typename _U2,
1097 _ImplicitCtor<true, _U1, _U2> =
true>
1098 _GLIBCXX20_CONSTEXPR
1100 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1101 std::forward<_U2>(__a2)) { }
1103 template<
typename _Alloc,
typename _U1,
typename _U2,
1104 _ExplicitCtor<true, _U1, _U2> =
false>
1106 _GLIBCXX20_CONSTEXPR
1108 _U1&& __a1, _U2&& __a2)
1109 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1110 std::forward<_U2>(__a2)) { }
1112 template<
typename _Alloc>
1113 _GLIBCXX20_CONSTEXPR
1117 template<
typename _Alloc>
1118 _GLIBCXX20_CONSTEXPR
1122 template<
typename _Alloc,
typename _U1,
typename _U2,
1123 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1124 _GLIBCXX20_CONSTEXPR
1131 template<
typename _Alloc,
typename _U1,
typename _U2,
1132 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1134 _GLIBCXX20_CONSTEXPR
1141 template<
typename _Alloc,
typename _U1,
typename _U2,
1142 _ImplicitCtor<true, _U1, _U2> =
true>
1143 _GLIBCXX20_CONSTEXPR
1148 template<
typename _Alloc,
typename _U1,
typename _U2,
1149 _ExplicitCtor<true, _U1, _U2> =
false>
1151 _GLIBCXX20_CONSTEXPR
1156 template<
typename _Alloc,
typename _U1,
typename _U2,
1157 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1158 _GLIBCXX20_CONSTEXPR
1161 :
_Inherited(__tag, __a, __in.first, __in.second) { }
1163 template<
typename _Alloc,
typename _U1,
typename _U2,
1164 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1166 _GLIBCXX20_CONSTEXPR
1169 :
_Inherited(__tag, __a, __in.first, __in.second) { }
1171 template<
typename _Alloc,
typename _U1,
typename _U2,
1172 _ImplicitCtor<true, _U1, _U2> =
true>
1173 _GLIBCXX20_CONSTEXPR
1175 :
_Inherited(__tag, __a, std::forward<_U1>(__in.first),
1176 std::forward<_U2>(__in.second)) { }
1178 template<
typename _Alloc,
typename _U1,
typename _U2,
1179 _ExplicitCtor<true, _U1, _U2> =
false>
1181 _GLIBCXX20_CONSTEXPR
1183 :
_Inherited(__tag, __a, std::forward<_U1>(__in.first),
1184 std::forward<_U2>(__in.second)) { }
1188 _GLIBCXX20_CONSTEXPR
1190 operator=(
typename conditional<__assignable<const _T1&, const _T2&>(),
1192 const __nonesuch&>::type __in)
1193 noexcept(__nothrow_assignable<const _T1&, const _T2&>())
1195 this->_M_assign(__in);
1199 _GLIBCXX20_CONSTEXPR
1201 operator=(
typename conditional<__assignable<_T1, _T2>(),
1203 __nonesuch&&>::type __in)
1204 noexcept(__nothrow_assignable<_T1, _T2>())
1210 template<
typename _U1,
typename _U2>
1211 _GLIBCXX20_CONSTEXPR
1212 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
1214 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1216 this->_M_assign(__in);
1220 template<
typename _U1,
typename _U2>
1221 _GLIBCXX20_CONSTEXPR
1222 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
1224 noexcept(__nothrow_assignable<_U1, _U2>())
1230 template<
typename _U1,
typename _U2>
1231 _GLIBCXX20_CONSTEXPR
1232 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
1234 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1236 this->_M_head(*
this) = __in.first;
1237 this->_M_tail(*this)._M_head(*
this) = __in.second;
1241 template<
typename _U1,
typename _U2>
1242 _GLIBCXX20_CONSTEXPR
1243 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
1245 noexcept(__nothrow_assignable<_U1, _U2>())
1247 this->_M_head(*
this) = std::forward<_U1>(__in.first);
1248 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.second);
1252 _GLIBCXX20_CONSTEXPR
1255 noexcept(__and_<__is_nothrow_swappable<_T1>,
1256 __is_nothrow_swappable<_T2>>::value)
1257 { _Inherited::_M_swap(__in); }
1262 template<
typename... _Elements>
1266 #if __cplusplus > 201402L
1267 template <
typename _Tp>
1275 template<std::size_t __i,
typename _Head,
typename... _Tail>
1282 template<
typename _Head,
typename... _Tail>
1291 template<
size_t __i>
1295 "tuple index is in range");
1298 template<std::size_t __i,
typename _Head,
typename... _Tail>
1303 template<std::size_t __i,
typename _Head,
typename... _Tail>
1304 constexpr
const _Head&
1305 __get_helper(
const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
1306 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1309 template<std::size_t __i,
typename... _Elements>
1310 constexpr __tuple_element_t<__i, tuple<_Elements...>>&
1312 {
return std::__get_helper<__i>(__t); }
1315 template<std::size_t __i,
typename... _Elements>
1316 constexpr
const __tuple_element_t<__i, tuple<_Elements...>>&
1318 {
return std::__get_helper<__i>(__t); }
1321 template<std::size_t __i,
typename... _Elements>
1322 constexpr __tuple_element_t<__i, tuple<_Elements...>>&&
1325 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1326 return std::forward<__element_type&&>(std::get<__i>(__t));
1330 template<std::size_t __i,
typename... _Elements>
1331 constexpr
const __tuple_element_t<__i, tuple<_Elements...>>&&
1334 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1335 return std::forward<const __element_type&&>(std::get<__i>(__t));
1338 #if __cplusplus >= 201402L
1340 #define __cpp_lib_tuples_by_type 201304
1342 template<
typename _Head,
size_t __i,
typename... _Tail>
1344 __get_helper2(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
1345 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1347 template<
typename _Head,
size_t __i,
typename... _Tail>
1348 constexpr
const _Head&
1349 __get_helper2(
const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
1350 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1353 template <
typename _Tp,
typename... _Types>
1356 {
return std::__get_helper2<_Tp>(__t); }
1359 template <
typename _Tp,
typename... _Types>
1362 {
return std::forward<_Tp&&>(std::__get_helper2<_Tp>(__t)); }
1365 template <
typename _Tp,
typename... _Types>
1366 constexpr
const _Tp&
1368 {
return std::__get_helper2<_Tp>(__t); }
1372 template <
typename _Tp,
typename... _Types>
1373 constexpr
const _Tp&&
1375 {
return std::forward<const _Tp&&>(std::__get_helper2<_Tp>(__t)); }
1379 template<
typename _Tp,
typename _Up,
size_t __i,
size_t __size>
1380 struct __tuple_compare
1382 static constexpr
bool
1383 __eq(
const _Tp& __t,
const _Up& __u)
1385 return bool(std::get<__i>(__t) == std::get<__i>(__u))
1386 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u);
1389 static constexpr
bool
1390 __less(
const _Tp& __t,
const _Up& __u)
1392 return bool(std::get<__i>(__t) < std::get<__i>(__u))
1393 || (!bool(std::get<__i>(__u) < std::get<__i>(__t))
1394 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u));
1398 template<
typename _Tp,
typename _Up,
size_t __size>
1399 struct __tuple_compare<_Tp, _Up, __size, __size>
1401 static constexpr
bool
1402 __eq(
const _Tp&,
const _Up&) {
return true; }
1404 static constexpr
bool
1405 __less(
const _Tp&,
const _Up&) {
return false; }
1408 template<
typename... _TElements,
typename... _UElements>
1410 operator==(
const tuple<_TElements...>& __t,
1411 const tuple<_UElements...>& __u)
1413 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1414 "tuple objects can only be compared if they have equal sizes.");
1415 using __compare = __tuple_compare<tuple<_TElements...>,
1416 tuple<_UElements...>,
1417 0,
sizeof...(_TElements)>;
1418 return __compare::__eq(__t, __u);
1421 #if __cpp_lib_three_way_comparison
1422 template<
typename _Cat,
typename _Tp,
typename _Up>
1424 __tuple_cmp(
const _Tp&,
const _Up&, index_sequence<>)
1425 {
return _Cat::equivalent; }
1427 template<
typename _Cat,
typename _Tp,
typename _Up,
1428 size_t _Idx0,
size_t... _Idxs>
1430 __tuple_cmp(
const _Tp& __t,
const _Up& __u,
1431 index_sequence<_Idx0, _Idxs...>)
1434 = __detail::__synth3way(std::get<_Idx0>(__t), std::get<_Idx0>(__u));
1437 return std::__tuple_cmp<_Cat>(__t, __u, index_sequence<_Idxs...>());
1440 template<
typename... _Tps,
typename... _Ups>
1442 common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>
1443 operator<=>(
const tuple<_Tps...>& __t,
const tuple<_Ups...>& __u)
1446 = common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>;
1447 return std::__tuple_cmp<_Cat>(__t, __u, index_sequence_for<_Tps...>());
1450 template<
typename... _TElements,
typename... _UElements>
1452 operator<(
const tuple<_TElements...>& __t,
1453 const tuple<_UElements...>& __u)
1455 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1456 "tuple objects can only be compared if they have equal sizes.");
1457 using __compare = __tuple_compare<tuple<_TElements...>,
1458 tuple<_UElements...>,
1459 0,
sizeof...(_TElements)>;
1460 return __compare::__less(__t, __u);
1463 template<
typename... _TElements,
typename... _UElements>
1465 operator!=(
const tuple<_TElements...>& __t,
1466 const tuple<_UElements...>& __u)
1467 {
return !(__t == __u); }
1469 template<
typename... _TElements,
typename... _UElements>
1471 operator>(
const tuple<_TElements...>& __t,
1472 const tuple<_UElements...>& __u)
1473 {
return __u < __t; }
1475 template<
typename... _TElements,
typename... _UElements>
1477 operator<=(
const tuple<_TElements...>& __t,
1478 const tuple<_UElements...>& __u)
1479 {
return !(__u < __t); }
1481 template<
typename... _TElements,
typename... _UElements>
1483 operator>=(
const tuple<_TElements...>& __t,
1484 const tuple<_UElements...>& __u)
1485 {
return !(__t < __u); }
1489 template<
typename... _Elements>
1490 constexpr tuple<typename __decay_and_strip<_Elements>::__type...>
1491 make_tuple(_Elements&&... __args)
1493 typedef tuple<typename __decay_and_strip<_Elements>::__type...>
1495 return __result_type(std::forward<_Elements>(__args)...);
1501 template<
typename... _Elements>
1502 constexpr tuple<_Elements&&...>
1504 {
return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
1506 template<
size_t,
typename,
typename,
size_t>
1507 struct __make_tuple_impl;
1509 template<
size_t _Idx,
typename _Tuple,
typename... _Tp,
size_t _Nm>
1510 struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
1511 : __make_tuple_impl<_Idx + 1,
1512 tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
1516 template<std::size_t _Nm,
typename _Tuple,
typename... _Tp>
1517 struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
1519 typedef tuple<_Tp...> __type;
1522 template<
typename _Tuple>
1523 struct __do_make_tuple
1524 : __make_tuple_impl<0, tuple<>, _Tuple, std::tuple_size<_Tuple>::value>
1528 template<
typename _Tuple>
1530 :
public __do_make_tuple<__remove_cvref_t<_Tuple>>
1534 template<
typename...>
1535 struct __combine_tuples;
1538 struct __combine_tuples<>
1540 typedef tuple<> __type;
1543 template<
typename... _Ts>
1544 struct __combine_tuples<tuple<_Ts...>>
1546 typedef tuple<_Ts...> __type;
1549 template<
typename... _T1s,
typename... _T2s,
typename... _Rem>
1550 struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
1552 typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
1553 _Rem...>::__type __type;
1557 template<
typename... _Tpls>
1558 struct __tuple_cat_result
1560 typedef typename __combine_tuples
1561 <
typename __make_tuple<_Tpls>::__type...>::__type __type;
1566 template<
typename...>
1567 struct __make_1st_indices;
1570 struct __make_1st_indices<>
1572 typedef std::_Index_tuple<> __type;
1575 template<
typename _Tp,
typename... _Tpls>
1576 struct __make_1st_indices<_Tp, _Tpls...>
1579 typename std::remove_reference<_Tp>::type>::value>::__type __type;
1585 template<
typename _Ret,
typename _Indices,
typename... _Tpls>
1586 struct __tuple_concater;
1588 template<
typename _Ret, std::size_t... _Is,
typename _Tp,
typename... _Tpls>
1589 struct __tuple_concater<_Ret,
std::_Index_tuple<_Is...>, _Tp, _Tpls...>
1591 template<
typename... _Us>
1592 static constexpr _Ret
1593 _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
1595 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1596 typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
1597 return __next::_S_do(std::forward<_Tpls>(__tps)...,
1598 std::forward<_Us>(__us)...,
1599 std::get<_Is>(std::forward<_Tp>(__tp))...);
1603 template<
typename _Ret>
1604 struct __tuple_concater<_Ret,
std::_Index_tuple<>>
1606 template<
typename... _Us>
1607 static constexpr _Ret
1608 _S_do(_Us&&... __us)
1610 return _Ret(std::forward<_Us>(__us)...);
1615 template<
typename... _Tpls,
typename =
typename
1616 enable_if<__and_<__is_tuple_like<_Tpls>...>::value>::type>
1619 ->
typename __tuple_cat_result<_Tpls...>::__type
1621 typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
1622 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1623 typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
1624 return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
1630 template<
typename... _Elements>
1631 constexpr tuple<_Elements&...>
1632 tie(_Elements&... __args) noexcept
1633 {
return tuple<_Elements&...>(__args...); }
1636 template<
typename... _Elements>
1637 _GLIBCXX20_CONSTEXPR
1639 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
1641 typename enable_if<__and_<__is_swappable<_Elements>...>::value
1647 noexcept(noexcept(__x.swap(__y)))
1650 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
1651 template<
typename... _Elements>
1652 _GLIBCXX20_CONSTEXPR
1653 typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type
1654 swap(tuple<_Elements...>&, tuple<_Elements...>&) =
delete;
1661 struct _Swallow_assign
1664 _GLIBCXX14_CONSTEXPR
const _Swallow_assign&
1665 operator=(
const _Tp&)
const
1671 _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
1674 template<
typename... _Types,
typename _Alloc>
1686 template<
class _T1,
class _T2>
1687 template<
typename... _Args1,
typename... _Args2>
1688 _GLIBCXX20_CONSTEXPR
1693 :
pair(__first, __second,
1694 typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
1695 typename _Build_index_tuple<sizeof...(_Args2)>::__type())
1698 template<
class _T1,
class _T2>
1699 template<
typename... _Args1, std::size_t... _Indexes1,
1700 typename... _Args2, std::size_t... _Indexes2>
1701 _GLIBCXX20_CONSTEXPR
inline
1704 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
1705 : first(
std::
forward<_Args1>(
std::get<_Indexes1>(__tuple1))...),
1706 second(
std::
forward<_Args2>(
std::get<_Indexes2>(__tuple2))...)
1709 #if __cplusplus >= 201703L
1715 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _Tuple>
1716 inline constexpr
bool __unpack_std_tuple =
false;
1718 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1719 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>>
1720 = _Trait<_Tp, _Up...>::value;
1722 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1723 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>&>
1724 = _Trait<_Tp, _Up&...>::value;
1726 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1727 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>>
1728 = _Trait<_Tp,
const _Up...>::value;
1730 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1731 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>&>
1732 = _Trait<_Tp,
const _Up&...>::value;
1734 # define __cpp_lib_apply 201603
1736 template <
typename _Fn,
typename _Tuple,
size_t... _Idx>
1737 constexpr decltype(
auto)
1741 std::get<_Idx>(std::forward<_Tuple>(__t))...);
1744 template <
typename _Fn,
typename _Tuple>
1745 constexpr decltype(
auto)
1746 apply(_Fn&& __f, _Tuple&& __t)
1747 noexcept(__unpack_std_tuple<is_nothrow_invocable, _Fn, _Tuple>)
1750 = make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>;
1751 return std::__apply_impl(std::forward<_Fn>(__f),
1752 std::forward<_Tuple>(__t),
1756 #define __cpp_lib_make_from_tuple 201606
1758 template <
typename _Tp,
typename _Tuple,
size_t... _Idx>
1760 __make_from_tuple_impl(_Tuple&& __t, index_sequence<_Idx...>)
1761 {
return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); }
1763 template <
typename _Tp,
typename _Tuple>
1765 make_from_tuple(_Tuple&& __t)
1766 noexcept(__unpack_std_tuple<is_nothrow_constructible, _Tp, _Tuple>)
1768 return __make_from_tuple_impl<_Tp>(
1769 std::forward<_Tuple>(__t),
1776 _GLIBCXX_END_NAMESPACE_VERSION
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
constexpr auto tuple_cat(_Tpls &&... __tpls) -> typename __tuple_cat_result< _Tpls... >::__type
tuple_cat
constexpr tuple< _Elements &... > tie(_Elements &... __args) noexcept
tie
constexpr __invoke_result< _Callable, _Args... >::type __invoke(_Callable &&__fn, _Args &&... __args) noexcept(__is_nothrow_invocable< _Callable, _Args... >::value)
Invoke a callable object.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr tuple< _Elements &&... > forward_as_tuple(_Elements &&... __args) noexcept
std::forward_as_tuple
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.
make_integer_sequence< size_t, _Num > make_index_sequence
Alias template make_index_sequence.
integer_sequence< size_t, _Idx... > index_sequence
Alias template index_sequence.
Primary class template, tuple.
Partial specialization, 2-element tuple. Includes construction and assignment from a pair.
Define a member typedef type to one of two argument types.
is_nothrow_default_constructible
is_nothrow_move_constructible
Define a member typedef type only if a boolean constant is true.
Declare uses_allocator so it can be specialized in <queue> etc.
Tag type for piecewise construction of std::pair objects.
Struct holding two objects of arbitrary type.