30#define _GLIBCXX_TUPLE 1
32#pragma GCC system_header
34#if __cplusplus < 201103L
40#include <bits/uses_allocator.h>
42#if __cplusplus > 201703L
46namespace std _GLIBCXX_VISIBILITY(default)
48_GLIBCXX_BEGIN_NAMESPACE_VERSION
55 template<
typename... _Elements>
58 template<
typename _Tp>
59 struct __is_empty_non_tuple : is_empty<_Tp> { };
62 template<
typename _El0,
typename... _El>
63 struct __is_empty_non_tuple<tuple<_El0, _El...>> :
false_type { };
66 template<
typename _Tp>
67 using __empty_not_final
68 =
typename conditional<__is_final(_Tp),
false_type,
69 __is_empty_non_tuple<_Tp>>::type;
71 template<std::size_t _Idx,
typename _Head,
72 bool = __empty_not_final<_Head>::value>
75 template<std::
size_t _Idx,
typename _Head>
76 struct _Head_base<_Idx, _Head, true>
79 constexpr _Head_base()
82 constexpr _Head_base(
const _Head& __h)
85 constexpr _Head_base(
const _Head_base&) =
default;
86 constexpr _Head_base(_Head_base&&) =
default;
88 template<
typename _UHead>
89 constexpr _Head_base(_UHead&& __h)
92 _Head_base(allocator_arg_t, __uses_alloc0)
95 template<
typename _Alloc>
96 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
97 : _Head(allocator_arg, *__a._M_a) { }
99 template<
typename _Alloc>
100 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
101 : _Head(*__a._M_a) { }
103 template<
typename _UHead>
104 _Head_base(__uses_alloc0, _UHead&& __uhead)
107 template<
typename _Alloc,
typename _UHead>
108 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
109 : _Head(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead)) { }
111 template<
typename _Alloc,
typename _UHead>
112 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
113 : _Head(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
115 static constexpr _Head&
116 _M_head(_Head_base& __b)
noexcept {
return __b; }
118 static constexpr const _Head&
119 _M_head(
const _Head_base& __b)
noexcept {
return __b; }
122 template<std::
size_t _Idx,
typename _Head>
123 struct _Head_base<_Idx, _Head, false>
125 constexpr _Head_base()
128 constexpr _Head_base(
const _Head& __h)
129 : _M_head_impl(__h) { }
131 constexpr _Head_base(
const _Head_base&) =
default;
132 constexpr _Head_base(_Head_base&&) =
default;
134 template<
typename _UHead>
135 constexpr _Head_base(_UHead&& __h)
139 _Head_base(allocator_arg_t, __uses_alloc0)
142 template<
typename _Alloc>
143 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
144 : _M_head_impl(allocator_arg, *__a._M_a) { }
146 template<
typename _Alloc>
147 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
148 : _M_head_impl(*__a._M_a) { }
150 template<
typename _UHead>
152 _Head_base(__uses_alloc0, _UHead&& __uhead)
153 : _M_head_impl(
std::
forward<_UHead>(__uhead)) { }
155 template<
typename _Alloc,
typename _UHead>
156 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
157 : _M_head_impl(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead))
160 template<
typename _Alloc,
typename _UHead>
161 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
162 : _M_head_impl(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
164 static constexpr _Head&
165 _M_head(_Head_base& __b)
noexcept {
return __b._M_head_impl; }
167 static constexpr const _Head&
168 _M_head(
const _Head_base& __b)
noexcept {
return __b._M_head_impl; }
181 template<std::size_t _Idx,
typename... _Elements>
189 template<std::size_t _Idx,
typename _Head,
typename... _Tail>
192 private _Head_base<_Idx, _Head>
194 template<std::size_t,
typename...>
friend class _Tuple_impl;
197 typedef _Head_base<_Idx, _Head> _Base;
199 static constexpr _Head&
200 _M_head(
_Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
202 static constexpr const _Head&
203 _M_head(
const _Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
209 _M_tail(
const _Tuple_impl& __t)
noexcept {
return __t; }
215 constexpr _Tuple_impl(
const _Head& __head,
const _Tail&... __tail)
218 template<
typename _UHead,
typename... _UTail,
typename =
typename
219 enable_if<
sizeof...(_Tail) ==
sizeof...(_UTail)>::type>
221 constexpr _Tuple_impl(_UHead&& __head, _UTail&&... __tail)
222 :
_Inherited(std::forward<_UTail>(__tail)...),
223 _Base(std::forward<_UHead>(__head)) { }
233 noexcept(__and_<is_nothrow_move_constructible<_Head>,
236 _Base(std::forward<_Head>(_M_head(__in))) { }
238 template<
typename... _UElements>
243 template<
typename _UHead,
typename... _UTails>
247 _Base(std::forward<_UHead>
250 template<
typename _Alloc>
254 _Base(__tag, __use_alloc<_Head>(__a)) { }
256 template<
typename _Alloc>
258 const _Head& __head,
const _Tail&... __tail)
260 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
262 template<
typename _Alloc,
typename _UHead,
typename... _UTail,
263 typename =
typename enable_if<
sizeof...(_Tail)
264 ==
sizeof...(_UTail)>::type>
267 _UHead&& __head, _UTail&&... __tail)
268 :
_Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
269 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
270 std::forward<_UHead>(__head)) { }
272 template<
typename _Alloc>
277 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
279 template<
typename _Alloc>
284 _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
285 std::forward<_Head>(_M_head(__in))) { }
287 template<
typename _Alloc,
typename... _UElements>
293 _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
296 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
302 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
306 template<
typename... _UElements>
312 _M_tail(*this)._M_assign(
316 template<
typename _UHead,
typename... _UTails>
321 _M_head(*
this) = std::forward<_UHead>
323 _M_tail(*this)._M_assign(
333 swap(_M_head(*
this), _M_head(__in));
334 _Inherited::_M_swap(_M_tail(__in));
339 template<std::
size_t _Idx,
typename _Head>
341 :
private _Head_base<_Idx, _Head>
343 template<std::size_t,
typename...>
friend class _Tuple_impl;
345 typedef _Head_base<_Idx, _Head> _Base;
347 static constexpr _Head&
348 _M_head(
_Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
350 static constexpr const _Head&
351 _M_head(
const _Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
353 constexpr _Tuple_impl()
357 constexpr _Tuple_impl(
const _Head& __head)
360 template<
typename _UHead>
362 constexpr _Tuple_impl(_UHead&& __head)
365 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
369 _Tuple_impl& operator=(
const _Tuple_impl&) =
delete;
372 _Tuple_impl(_Tuple_impl&& __in)
373 noexcept(is_nothrow_move_constructible<_Head>::value)
374 : _Base(std::forward<_Head>(_M_head(__in))) { }
376 template<
typename _UHead>
377 constexpr _Tuple_impl(
const _Tuple_impl<_Idx, _UHead>& __in)
378 : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in)) { }
380 template<
typename _UHead>
381 constexpr _Tuple_impl(_Tuple_impl<_Idx, _UHead>&& __in)
382 : _Base(
std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
385 template<
typename _Alloc>
388 : _Base(__tag, __use_alloc<_Head>(__a)) { }
390 template<
typename _Alloc>
393 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
395 template<
typename _Alloc,
typename _UHead>
397 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
399 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
402 template<
typename _Alloc>
404 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
405 const _Tuple_impl& __in)
406 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
408 template<
typename _Alloc>
410 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
412 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
415 template<
typename _Alloc,
typename _UHead>
417 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
418 const _Tuple_impl<_Idx, _UHead>& __in)
419 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
420 _Tuple_impl<_Idx, _UHead>::_M_head(__in)) { }
422 template<
typename _Alloc,
typename _UHead>
424 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
425 _Tuple_impl<_Idx, _UHead>&& __in)
426 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
427 std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
430 template<
typename _UHead>
433 _M_assign(
const _Tuple_impl<_Idx, _UHead>& __in)
435 _M_head(*
this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in);
438 template<
typename _UHead>
441 _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
444 = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
450 _M_swap(_Tuple_impl& __in)
453 swap(_M_head(*
this), _M_head(__in));
459 template<bool,
typename... _Types>
460 struct _TupleConstraints
465 template<
typename... _UTypes>
466 static constexpr bool __is_implicitly_constructible()
468 return __and_<is_constructible<_Types, _UTypes>...,
469 is_convertible<_UTypes, _Types>...
476 template<
typename... _UTypes>
477 static constexpr bool __is_explicitly_constructible()
479 return __and_<is_constructible<_Types, _UTypes>...,
480 __not_<__and_<is_convertible<_UTypes, _Types>...>>
484 static constexpr bool __is_implicitly_default_constructible()
486 return __and_<std::__is_implicitly_default_constructible<_Types>...
490 static constexpr bool __is_explicitly_default_constructible()
492 return __and_<is_default_constructible<_Types>...,
494 std::__is_implicitly_default_constructible<_Types>...>
501 template<
typename... _Types>
502 struct _TupleConstraints<false, _Types...>
504 template<
typename... _UTypes>
505 static constexpr bool __is_implicitly_constructible()
508 template<
typename... _UTypes>
509 static constexpr bool __is_explicitly_constructible()
514 template<
typename... _Elements>
520 using _TCC = _TupleConstraints<_Cond, _Elements...>;
523 template<
bool _Dummy>
524 using _ImplicitDefaultCtor = __enable_if_t<
525 _TCC<_Dummy>::__is_implicitly_default_constructible(),
529 template<
bool _Dummy>
530 using _ExplicitDefaultCtor = __enable_if_t<
531 _TCC<_Dummy>::__is_explicitly_default_constructible(),
535 template<
bool _Cond,
typename... _Args>
536 using _ImplicitCtor = __enable_if_t<
537 _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(),
541 template<
bool _Cond,
typename... _Args>
542 using _ExplicitCtor = __enable_if_t<
543 _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(),
546 template<
typename... _UElements>
548 __enable_if_t<
sizeof...(_UElements) ==
sizeof...(_Elements),
bool>
550 {
return __and_<is_assignable<_Elements&, _UElements>...>::value; }
553 template<
typename... _UElements>
554 static constexpr bool __nothrow_assignable()
557 __and_<is_nothrow_assignable<_Elements&, _UElements>...>::value;
561 template<
typename... _UElements>
562 static constexpr bool __nothrow_constructible()
565 __and_<is_nothrow_constructible<_Elements, _UElements>...>::value;
569 template<
typename _Up>
570 static constexpr bool __valid_args()
572 return sizeof...(_Elements) == 1
577 template<
typename,
typename,
typename... _Tail>
578 static constexpr bool __valid_args()
579 {
return (
sizeof...(_Tail) + 2) ==
sizeof...(_Elements); }
590 template<
typename _Tuple,
typename =
tuple,
591 typename = __remove_cvref_t<_Tuple>>
597 template<
typename _Tuple,
typename _Tp,
typename _Up>
598 struct _UseOtherCtor<_Tuple,
tuple<_Tp>,
tuple<_Up>>
599 : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>
603 template<
typename _Tuple,
typename _Tp>
604 struct _UseOtherCtor<_Tuple,
tuple<_Tp>,
tuple<_Tp>>
611 template<
typename _Tuple>
612 static constexpr bool __use_other_ctor()
613 {
return _UseOtherCtor<_Tuple>::value; }
616 template<
typename _Dummy = void,
617 _ImplicitDefaultCtor<is_void<_Dummy>::value> =
true>
620 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
623 template<
typename _Dummy = void,
624 _ExplicitDefaultCtor<is_void<_Dummy>::value> =
false>
627 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
630 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
631 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
633 tuple(
const _Elements&... __elements)
634 noexcept(__nothrow_constructible<
const _Elements&...>())
637 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
638 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
640 tuple(
const _Elements&... __elements)
641 noexcept(__nothrow_constructible<
const _Elements&...>())
644 template<
typename... _UElements,
645 bool _Valid = __valid_args<_UElements...>(),
646 _ImplicitCtor<_Valid, _UElements...> =
true>
648 tuple(_UElements&&... __elements)
649 noexcept(__nothrow_constructible<_UElements...>())
650 :
_Inherited(std::forward<_UElements>(__elements)...) { }
652 template<
typename... _UElements,
653 bool _Valid = __valid_args<_UElements...>(),
654 _ExplicitCtor<_Valid, _UElements...> =
false>
656 tuple(_UElements&&... __elements)
657 noexcept(__nothrow_constructible<_UElements...>())
658 :
_Inherited(std::forward<_UElements>(__elements)...) { }
664 template<
typename... _UElements,
665 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
667 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
670 noexcept(__nothrow_constructible<
const _UElements&...>())
674 template<
typename... _UElements,
675 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
677 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
680 noexcept(__nothrow_constructible<
const _UElements&...>())
684 template<
typename... _UElements,
685 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
687 _ImplicitCtor<_Valid, _UElements...> =
true>
690 noexcept(__nothrow_constructible<_UElements...>())
693 template<
typename... _UElements,
694 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
696 _ExplicitCtor<_Valid, _UElements...> =
false>
699 noexcept(__nothrow_constructible<_UElements...>())
704 template<
typename _Alloc,
705 _ImplicitDefaultCtor<is_object<_Alloc>::value> =
true>
710 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
711 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
714 const _Elements&... __elements)
717 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
718 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
722 const _Elements&... __elements)
725 template<
typename _Alloc,
typename... _UElements,
726 bool _Valid = __valid_args<_UElements...>(),
727 _ImplicitCtor<_Valid, _UElements...> =
true>
730 _UElements&&... __elements)
731 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
734 template<
typename _Alloc,
typename... _UElements,
735 bool _Valid = __valid_args<_UElements...>(),
736 _ExplicitCtor<_Valid, _UElements...> =
false>
740 _UElements&&... __elements)
741 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
744 template<
typename _Alloc>
749 template<
typename _Alloc>
754 template<
typename _Alloc,
typename... _UElements,
755 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
757 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
762 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
765 template<
typename _Alloc,
typename... _UElements,
766 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
768 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
774 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
777 template<
typename _Alloc,
typename... _UElements,
778 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
780 _ImplicitCtor<_Valid, _UElements...> =
true>
785 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
788 template<
typename _Alloc,
typename... _UElements,
789 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
791 _ExplicitCtor<_Valid, _UElements...> =
false>
797 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
804 operator=(
typename conditional<__assignable<const _Elements&...>(),
806 const __nonesuch&>::type __in)
807 noexcept(__nothrow_assignable<
const _Elements&...>())
809 this->_M_assign(__in);
815 operator=(
typename conditional<__assignable<_Elements...>(),
817 __nonesuch&&>::type __in)
818 noexcept(__nothrow_assignable<_Elements...>())
824 template<
typename... _UElements>
826 __enable_if_t<__assignable<
const _UElements&...>(),
tuple&>
828 noexcept(__nothrow_assignable<
const _UElements&...>())
830 this->_M_assign(__in);
834 template<
typename... _UElements>
836 __enable_if_t<__assignable<_UElements...>(),
tuple&>
838 noexcept(__nothrow_assignable<_UElements...>())
848 noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value)
849 { _Inherited::_M_swap(__in); }
852#if __cpp_deduction_guides >= 201606
853 template<
typename... _UTypes>
855 template<
typename _T1,
typename _T2>
857 template<
typename _Alloc,
typename... _UTypes>
859 template<
typename _Alloc,
typename _T1,
typename _T2>
861 template<
typename _Alloc,
typename... _UTypes>
870 void swap(
tuple&)
noexcept { }
875 template<
typename _Alloc>
877 tuple(allocator_arg_t,
const _Alloc&)
noexcept { }
878 template<
typename _Alloc>
880 tuple(allocator_arg_t,
const _Alloc&,
const tuple&)
noexcept { }
885 template<
typename _T1,
typename _T2>
891 template<
bool _Dummy,
typename _U1,
typename _U2>
892 using _ImplicitDefaultCtor = __enable_if_t<
893 _TupleConstraints<_Dummy, _U1, _U2>::
894 __is_implicitly_default_constructible(),
898 template<
bool _Dummy,
typename _U1,
typename _U2>
899 using _ExplicitDefaultCtor = __enable_if_t<
900 _TupleConstraints<_Dummy, _U1, _U2>::
901 __is_explicitly_default_constructible(),
904 template<
bool _Dummy>
905 using _TCC = _TupleConstraints<_Dummy, _T1, _T2>;
908 template<
bool _Cond,
typename _U1,
typename _U2>
909 using _ImplicitCtor = __enable_if_t<
910 _TCC<_Cond>::template __is_implicitly_constructible<_U1, _U2>(),
914 template<
bool _Cond,
typename _U1,
typename _U2>
915 using _ExplicitCtor = __enable_if_t<
916 _TCC<_Cond>::template __is_explicitly_constructible<_U1, _U2>(),
919 template<
typename _U1,
typename _U2>
920 static constexpr bool __assignable()
922 return __and_<is_assignable<_T1&, _U1>,
926 template<
typename _U1,
typename _U2>
927 static constexpr bool __nothrow_assignable()
929 return __and_<is_nothrow_assignable<_T1&, _U1>,
933 template<
typename _U1,
typename _U2>
934 static constexpr bool __nothrow_constructible()
936 return __and_<is_nothrow_constructible<_T1, _U1>,
940 static constexpr bool __nothrow_default_constructible()
942 return __and_<is_nothrow_default_constructible<_T1>,
946 template<
typename _U1>
947 static constexpr bool __is_alloc_arg()
951 template<
bool _Dummy =
true,
952 _ImplicitDefaultCtor<_Dummy, _T1, _T2> =
true>
955 noexcept(__nothrow_default_constructible())
958 template<
bool _Dummy =
true,
959 _ExplicitDefaultCtor<_Dummy, _T1, _T2> =
false>
962 noexcept(__nothrow_default_constructible())
965 template<
bool _Dummy =
true,
966 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
968 tuple(
const _T1& __a1,
const _T2& __a2)
969 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
972 template<
bool _Dummy =
true,
973 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
975 tuple(
const _T1& __a1,
const _T2& __a2)
976 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
979 template<
typename _U1,
typename _U2,
980 _ImplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
true>
982 tuple(_U1&& __a1, _U2&& __a2)
983 noexcept(__nothrow_constructible<_U1, _U2>())
984 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
986 template<
typename _U1,
typename _U2,
987 _ExplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
false>
989 tuple(_U1&& __a1, _U2&& __a2)
990 noexcept(__nothrow_constructible<_U1, _U2>())
991 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
997 template<
typename _U1,
typename _U2,
998 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1001 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1004 template<
typename _U1,
typename _U2,
1005 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1008 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1011 template<
typename _U1,
typename _U2,
1012 _ImplicitCtor<true, _U1, _U2> =
true>
1015 noexcept(__nothrow_constructible<_U1, _U2>())
1018 template<
typename _U1,
typename _U2,
1019 _ExplicitCtor<true, _U1, _U2> =
false>
1022 noexcept(__nothrow_constructible<_U1, _U2>())
1025 template<
typename _U1,
typename _U2,
1026 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1029 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1032 template<
typename _U1,
typename _U2,
1033 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1036 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1039 template<
typename _U1,
typename _U2,
1040 _ImplicitCtor<true, _U1, _U2> =
true>
1043 noexcept(__nothrow_constructible<_U1, _U2>())
1045 std::forward<_U2>(__in.second)) { }
1047 template<
typename _U1,
typename _U2,
1048 _ExplicitCtor<true, _U1, _U2> =
false>
1051 noexcept(__nothrow_constructible<_U1, _U2>())
1053 std::forward<_U2>(__in.second)) { }
1057 template<
typename _Alloc,
1058 _ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> =
true>
1059 _GLIBCXX20_CONSTEXPR
1063 template<
typename _Alloc,
bool _Dummy =
true,
1064 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1065 _GLIBCXX20_CONSTEXPR
1067 const _T1& __a1,
const _T2& __a2)
1070 template<
typename _Alloc,
bool _Dummy =
true,
1071 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1073 _GLIBCXX20_CONSTEXPR
1075 const _T1& __a1,
const _T2& __a2)
1078 template<
typename _Alloc,
typename _U1,
typename _U2,
1079 _ImplicitCtor<true, _U1, _U2> =
true>
1080 _GLIBCXX20_CONSTEXPR
1082 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1083 std::forward<_U2>(__a2)) { }
1085 template<
typename _Alloc,
typename _U1,
typename _U2,
1086 _ExplicitCtor<true, _U1, _U2> =
false>
1088 _GLIBCXX20_CONSTEXPR
1090 _U1&& __a1, _U2&& __a2)
1091 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1092 std::forward<_U2>(__a2)) { }
1094 template<
typename _Alloc>
1095 _GLIBCXX20_CONSTEXPR
1099 template<
typename _Alloc>
1100 _GLIBCXX20_CONSTEXPR
1104 template<
typename _Alloc,
typename _U1,
typename _U2,
1105 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1106 _GLIBCXX20_CONSTEXPR
1113 template<
typename _Alloc,
typename _U1,
typename _U2,
1114 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1116 _GLIBCXX20_CONSTEXPR
1123 template<
typename _Alloc,
typename _U1,
typename _U2,
1124 _ImplicitCtor<true, _U1, _U2> =
true>
1125 _GLIBCXX20_CONSTEXPR
1130 template<
typename _Alloc,
typename _U1,
typename _U2,
1131 _ExplicitCtor<true, _U1, _U2> =
false>
1133 _GLIBCXX20_CONSTEXPR
1138 template<
typename _Alloc,
typename _U1,
typename _U2,
1139 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1140 _GLIBCXX20_CONSTEXPR
1143 :
_Inherited(__tag, __a, __in.first, __in.second) { }
1145 template<
typename _Alloc,
typename _U1,
typename _U2,
1146 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1148 _GLIBCXX20_CONSTEXPR
1151 :
_Inherited(__tag, __a, __in.first, __in.second) { }
1153 template<
typename _Alloc,
typename _U1,
typename _U2,
1154 _ImplicitCtor<true, _U1, _U2> =
true>
1155 _GLIBCXX20_CONSTEXPR
1157 :
_Inherited(__tag, __a, std::forward<_U1>(__in.first),
1158 std::forward<_U2>(__in.second)) { }
1160 template<
typename _Alloc,
typename _U1,
typename _U2,
1161 _ExplicitCtor<true, _U1, _U2> =
false>
1163 _GLIBCXX20_CONSTEXPR
1165 :
_Inherited(__tag, __a, std::forward<_U1>(__in.first),
1166 std::forward<_U2>(__in.second)) { }
1170 _GLIBCXX20_CONSTEXPR
1172 operator=(
typename conditional<__assignable<const _T1&, const _T2&>(),
1174 const __nonesuch&>::type __in)
1175 noexcept(__nothrow_assignable<const _T1&, const _T2&>())
1177 this->_M_assign(__in);
1181 _GLIBCXX20_CONSTEXPR
1183 operator=(
typename conditional<__assignable<_T1, _T2>(),
1185 __nonesuch&&>::type __in)
1186 noexcept(__nothrow_assignable<_T1, _T2>())
1192 template<
typename _U1,
typename _U2>
1193 _GLIBCXX20_CONSTEXPR
1194 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
1196 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1198 this->_M_assign(__in);
1202 template<
typename _U1,
typename _U2>
1203 _GLIBCXX20_CONSTEXPR
1204 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
1206 noexcept(__nothrow_assignable<_U1, _U2>())
1212 template<
typename _U1,
typename _U2>
1213 _GLIBCXX20_CONSTEXPR
1214 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
1216 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1218 this->_M_head(*
this) = __in.first;
1219 this->_M_tail(*this)._M_head(*
this) = __in.second;
1223 template<
typename _U1,
typename _U2>
1224 _GLIBCXX20_CONSTEXPR
1225 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
1227 noexcept(__nothrow_assignable<_U1, _U2>())
1229 this->_M_head(*
this) = std::forward<_U1>(__in.first);
1230 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.second);
1234 _GLIBCXX20_CONSTEXPR
1237 noexcept(__and_<__is_nothrow_swappable<_T1>,
1238 __is_nothrow_swappable<_T2>>::value)
1239 { _Inherited::_M_swap(__in); }
1244 template<
typename... _Elements>
1248#if __cplusplus > 201402L
1249 template <
typename _Tp>
1257 template<std::size_t __i,
typename _Head,
typename... _Tail>
1264 template<
typename _Head,
typename... _Tail>
1273 template<
size_t __i>
1276 static_assert(__i < tuple_size<tuple<>>::value,
1277 "tuple index is in range");
1280 template<std::size_t __i,
typename _Head,
typename... _Tail>
1285 template<std::size_t __i,
typename _Head,
typename... _Tail>
1286 constexpr const _Head&
1287 __get_helper(
const _Tuple_impl<__i, _Head, _Tail...>& __t)
noexcept
1288 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1291 template<std::size_t __i,
typename... _Elements>
1292 constexpr __tuple_element_t<__i, tuple<_Elements...>>&
1294 {
return std::__get_helper<__i>(__t); }
1297 template<std::size_t __i,
typename... _Elements>
1298 constexpr const __tuple_element_t<__i, tuple<_Elements...>>&
1300 {
return std::__get_helper<__i>(__t); }
1303 template<std::size_t __i,
typename... _Elements>
1304 constexpr __tuple_element_t<__i, tuple<_Elements...>>&&
1307 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1308 return std::forward<__element_type&&>(std::get<__i>(__t));
1312 template<std::size_t __i,
typename... _Elements>
1313 constexpr const __tuple_element_t<__i, tuple<_Elements...>>&&
1316 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1317 return std::forward<const __element_type&&>(std::get<__i>(__t));
1320#if __cplusplus >= 201402L
1322#define __cpp_lib_tuples_by_type 201304
1324 template<
typename _Head,
size_t __i,
typename... _Tail>
1326 __get_helper2(_Tuple_impl<__i, _Head, _Tail...>& __t)
noexcept
1327 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1329 template<
typename _Head,
size_t __i,
typename... _Tail>
1330 constexpr const _Head&
1331 __get_helper2(
const _Tuple_impl<__i, _Head, _Tail...>& __t)
noexcept
1332 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1335 template <
typename _Tp,
typename... _Types>
1338 {
return std::__get_helper2<_Tp>(__t); }
1341 template <
typename _Tp,
typename... _Types>
1344 {
return std::forward<_Tp&&>(std::__get_helper2<_Tp>(__t)); }
1347 template <
typename _Tp,
typename... _Types>
1348 constexpr const _Tp&
1350 {
return std::__get_helper2<_Tp>(__t); }
1354 template <
typename _Tp,
typename... _Types>
1355 constexpr const _Tp&&
1357 {
return std::forward<const _Tp&&>(std::__get_helper2<_Tp>(__t)); }
1361 template<
typename _Tp,
typename _Up,
size_t __i,
size_t __size>
1362 struct __tuple_compare
1364 static constexpr bool
1365 __eq(
const _Tp& __t,
const _Up& __u)
1367 return bool(std::get<__i>(__t) == std::get<__i>(__u))
1368 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u);
1371 static constexpr bool
1372 __less(
const _Tp& __t,
const _Up& __u)
1374 return bool(std::get<__i>(__t) < std::get<__i>(__u))
1375 || (!bool(std::get<__i>(__u) < std::get<__i>(__t))
1376 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u));
1380 template<
typename _Tp,
typename _Up,
size_t __size>
1381 struct __tuple_compare<_Tp, _Up, __size, __size>
1383 static constexpr bool
1384 __eq(
const _Tp&,
const _Up&) {
return true; }
1386 static constexpr bool
1387 __less(
const _Tp&,
const _Up&) {
return false; }
1390 template<
typename... _TElements,
typename... _UElements>
1392 operator==(
const tuple<_TElements...>& __t,
1393 const tuple<_UElements...>& __u)
1395 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1396 "tuple objects can only be compared if they have equal sizes.");
1397 using __compare = __tuple_compare<tuple<_TElements...>,
1398 tuple<_UElements...>,
1399 0,
sizeof...(_TElements)>;
1400 return __compare::__eq(__t, __u);
1403#if __cpp_lib_three_way_comparison
1404 template<
typename _Cat,
typename _Tp,
typename _Up>
1406 __tuple_cmp(
const _Tp&,
const _Up&, index_sequence<>)
1407 {
return _Cat::equivalent; }
1409 template<
typename _Cat,
typename _Tp,
typename _Up,
1410 size_t _Idx0,
size_t... _Idxs>
1412 __tuple_cmp(
const _Tp& __t,
const _Up& __u,
1413 index_sequence<_Idx0, _Idxs...>)
1416 = __detail::__synth3way(std::get<_Idx0>(__t), std::get<_Idx0>(__u));
1419 return std::__tuple_cmp<_Cat>(__t, __u, index_sequence<_Idxs...>());
1422 template<
typename... _Tps,
typename... _Ups>
1424 common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>
1425 operator<=>(
const tuple<_Tps...>& __t,
const tuple<_Ups...>& __u)
1428 = common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>;
1429 return std::__tuple_cmp<_Cat>(__t, __u, index_sequence_for<_Tps...>());
1432 template<
typename... _TElements,
typename... _UElements>
1434 operator<(
const tuple<_TElements...>& __t,
1435 const tuple<_UElements...>& __u)
1437 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1438 "tuple objects can only be compared if they have equal sizes.");
1439 using __compare = __tuple_compare<tuple<_TElements...>,
1440 tuple<_UElements...>,
1441 0,
sizeof...(_TElements)>;
1442 return __compare::__less(__t, __u);
1445 template<
typename... _TElements,
typename... _UElements>
1447 operator!=(
const tuple<_TElements...>& __t,
1448 const tuple<_UElements...>& __u)
1449 {
return !(__t == __u); }
1451 template<
typename... _TElements,
typename... _UElements>
1453 operator>(
const tuple<_TElements...>& __t,
1454 const tuple<_UElements...>& __u)
1455 {
return __u < __t; }
1457 template<
typename... _TElements,
typename... _UElements>
1459 operator<=(
const tuple<_TElements...>& __t,
1460 const tuple<_UElements...>& __u)
1461 {
return !(__u < __t); }
1463 template<
typename... _TElements,
typename... _UElements>
1465 operator>=(
const tuple<_TElements...>& __t,
1466 const tuple<_UElements...>& __u)
1467 {
return !(__t < __u); }
1471 template<
typename... _Elements>
1472 constexpr tuple<typename __decay_and_strip<_Elements>::__type...>
1473 make_tuple(_Elements&&... __args)
1475 typedef tuple<typename __decay_and_strip<_Elements>::__type...>
1477 return __result_type(std::forward<_Elements>(__args)...);
1483 template<
typename... _Elements>
1484 constexpr tuple<_Elements&&...>
1486 {
return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
1488 template<
size_t,
typename,
typename,
size_t>
1489 struct __make_tuple_impl;
1491 template<
size_t _Idx,
typename _Tuple,
typename... _Tp,
size_t _Nm>
1492 struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
1493 : __make_tuple_impl<_Idx + 1,
1494 tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
1498 template<std::size_t _Nm,
typename _Tuple,
typename... _Tp>
1499 struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
1501 typedef tuple<_Tp...> __type;
1504 template<
typename _Tuple>
1505 struct __do_make_tuple
1506 : __make_tuple_impl<0, tuple<>, _Tuple, std::tuple_size<_Tuple>::value>
1510 template<
typename _Tuple>
1512 :
public __do_make_tuple<__remove_cvref_t<_Tuple>>
1516 template<
typename...>
1517 struct __combine_tuples;
1520 struct __combine_tuples<>
1522 typedef tuple<> __type;
1525 template<
typename... _Ts>
1526 struct __combine_tuples<tuple<_Ts...>>
1528 typedef tuple<_Ts...> __type;
1531 template<
typename... _T1s,
typename... _T2s,
typename... _Rem>
1532 struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
1534 typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
1535 _Rem...>::__type __type;
1539 template<
typename... _Tpls>
1540 struct __tuple_cat_result
1542 typedef typename __combine_tuples
1543 <
typename __make_tuple<_Tpls>::__type...>::__type __type;
1548 template<
typename...>
1549 struct __make_1st_indices;
1552 struct __make_1st_indices<>
1554 typedef std::_Index_tuple<> __type;
1557 template<
typename _Tp,
typename... _Tpls>
1558 struct __make_1st_indices<_Tp, _Tpls...>
1561 typename std::remove_reference<_Tp>::type>::value>::__type __type;
1567 template<
typename _Ret,
typename _Indices,
typename... _Tpls>
1568 struct __tuple_concater;
1570 template<
typename _Ret, std::size_t... _Is,
typename _Tp,
typename... _Tpls>
1571 struct __tuple_concater<_Ret,
std::_Index_tuple<_Is...>, _Tp, _Tpls...>
1573 template<
typename... _Us>
1574 static constexpr _Ret
1575 _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
1577 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1578 typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
1579 return __next::_S_do(std::forward<_Tpls>(__tps)...,
1580 std::forward<_Us>(__us)...,
1581 std::get<_Is>(std::forward<_Tp>(__tp))...);
1585 template<
typename _Ret>
1586 struct __tuple_concater<_Ret,
std::_Index_tuple<>>
1588 template<
typename... _Us>
1589 static constexpr _Ret
1590 _S_do(_Us&&... __us)
1592 return _Ret(std::forward<_Us>(__us)...);
1597 template<
typename... _Tpls,
typename =
typename
1598 enable_if<__and_<__is_tuple_like<_Tpls>...>::value>::type>
1601 ->
typename __tuple_cat_result<_Tpls...>::__type
1603 typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
1604 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1605 typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
1606 return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
1612 template<
typename... _Elements>
1613 constexpr tuple<_Elements&...>
1614 tie(_Elements&... __args)
noexcept
1615 {
return tuple<_Elements&...>(__args...); }
1618 template<
typename... _Elements>
1619 _GLIBCXX20_CONSTEXPR
1621#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
1623 typename enable_if<__and_<__is_swappable<_Elements>...>::value
1629 noexcept(
noexcept(__x.swap(__y)))
1632#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
1633 template<
typename... _Elements>
1634 _GLIBCXX20_CONSTEXPR
1635 typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type
1636 swap(tuple<_Elements...>&, tuple<_Elements...>&) =
delete;
1643 struct _Swallow_assign
1646 _GLIBCXX14_CONSTEXPR
const _Swallow_assign&
1647 operator=(
const _Tp&)
const
1653 _GLIBCXX17_INLINE
constexpr _Swallow_assign ignore{};
1656 template<
typename... _Types,
typename _Alloc>
1668 template<
class _T1,
class _T2>
1669 template<
typename... _Args1,
typename... _Args2>
1670 _GLIBCXX20_CONSTEXPR
1675 :
pair(__first, __second,
1676 typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
1677 typename _Build_index_tuple<sizeof...(_Args2)>::__type())
1680 template<
class _T1,
class _T2>
1681 template<
typename... _Args1, std::size_t... _Indexes1,
1682 typename... _Args2, std::size_t... _Indexes2>
1683 _GLIBCXX20_CONSTEXPR
inline
1686 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
1687 : first(
std::
forward<_Args1>(
std::get<_Indexes1>(__tuple1))...),
1688 second(
std::
forward<_Args2>(
std::get<_Indexes2>(__tuple2))...)
1691#if __cplusplus >= 201703L
1697 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _Tuple>
1698 inline constexpr bool __unpack_std_tuple =
false;
1700 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1701 inline constexpr bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>>
1702 = _Trait<_Tp, _Up...>::value;
1704 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1705 inline constexpr bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>&>
1706 = _Trait<_Tp, _Up&...>::value;
1708 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1709 inline constexpr bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>>
1710 = _Trait<_Tp,
const _Up...>::value;
1712 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1713 inline constexpr bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>&>
1714 = _Trait<_Tp,
const _Up&...>::value;
1716# define __cpp_lib_apply 201603
1718 template <
typename _Fn,
typename _Tuple,
size_t... _Idx>
1719 constexpr decltype(
auto)
1720 __apply_impl(_Fn&& __f, _Tuple&& __t, index_sequence<_Idx...>)
1723 std::get<_Idx>(std::forward<_Tuple>(__t))...);
1726 template <
typename _Fn,
typename _Tuple>
1727 constexpr decltype(
auto)
1728 apply(_Fn&& __f, _Tuple&& __t)
1729 noexcept(__unpack_std_tuple<is_nothrow_invocable, _Fn, _Tuple>)
1732 = make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>;
1733 return std::__apply_impl(std::forward<_Fn>(__f),
1734 std::forward<_Tuple>(__t),
1738#define __cpp_lib_make_from_tuple 201606
1740 template <
typename _Tp,
typename _Tuple,
size_t... _Idx>
1742 __make_from_tuple_impl(_Tuple&& __t, index_sequence<_Idx...>)
1743 {
return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); }
1745 template <
typename _Tp,
typename _Tuple>
1747 make_from_tuple(_Tuple&& __t)
1748 noexcept(__unpack_std_tuple<is_nothrow_constructible, _Tp, _Tuple>)
1750 return __make_from_tuple_impl<_Tp>(
1751 std::forward<_Tuple>(__t),
1758_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 &&... > forward_as_tuple(_Elements &&... __args) noexcept
std::forward_as_tuple
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr __invoke_result< _Callable, _Args... >::type __invoke(_Callable &&__fn, _Args &&... __args) noexcept(__is_nothrow_invocable< _Callable, _Args... >::value)
Invoke a callable object.
constexpr tuple< _Elements &... > tie(_Elements &... __args) noexcept
tie
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.
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.