30#define _GLIBCXX_TUPLE 1
32#pragma GCC system_header
34#if __cplusplus < 201103L
39#include <bits/uses_allocator.h>
42#if __cplusplus > 201703L
45# define __cpp_lib_constexpr_tuple 201811L
48namespace std _GLIBCXX_VISIBILITY(default)
50_GLIBCXX_BEGIN_NAMESPACE_VERSION
57 template<
typename... _Elements>
60 template<
typename _Tp>
61 struct __is_empty_non_tuple : is_empty<_Tp> { };
64 template<
typename _El0,
typename... _El>
65 struct __is_empty_non_tuple<tuple<_El0, _El...>> :
false_type { };
68 template<
typename _Tp>
69 using __empty_not_final
71 __is_empty_non_tuple<_Tp>>;
73 template<
size_t _Idx,
typename _Head,
74 bool = __empty_not_final<_Head>::value>
77#if __has_cpp_attribute(__no_unique_address__)
78 template<
size_t _Idx,
typename _Head>
79 struct _Head_base<_Idx, _Head, true>
81 constexpr _Head_base()
84 constexpr _Head_base(
const _Head& __h)
85 : _M_head_impl(__h) { }
87 constexpr _Head_base(
const _Head_base&) =
default;
88 constexpr _Head_base(_Head_base&&) =
default;
90 template<
typename _UHead>
91 constexpr _Head_base(_UHead&& __h)
95 _Head_base(allocator_arg_t, __uses_alloc0)
98 template<
typename _Alloc>
100 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
101 : _M_head_impl(allocator_arg, *__a._M_a) { }
103 template<
typename _Alloc>
105 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
106 : _M_head_impl(*__a._M_a) { }
108 template<
typename _UHead>
110 _Head_base(__uses_alloc0, _UHead&& __uhead)
111 : _M_head_impl(
std::
forward<_UHead>(__uhead)) { }
113 template<
typename _Alloc,
typename _UHead>
115 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
116 : _M_head_impl(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead))
119 template<
typename _Alloc,
typename _UHead>
121 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
122 : _M_head_impl(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
124 static constexpr _Head&
125 _M_head(_Head_base& __b)
noexcept {
return __b._M_head_impl; }
127 static constexpr const _Head&
128 _M_head(
const _Head_base& __b)
noexcept {
return __b._M_head_impl; }
130 [[__no_unique_address__]] _Head _M_head_impl;
133 template<
size_t _Idx,
typename _Head>
134 struct _Head_base<_Idx, _Head, true>
137 constexpr _Head_base()
140 constexpr _Head_base(
const _Head& __h)
143 constexpr _Head_base(
const _Head_base&) =
default;
144 constexpr _Head_base(_Head_base&&) =
default;
146 template<
typename _UHead>
147 constexpr _Head_base(_UHead&& __h)
151 _Head_base(allocator_arg_t, __uses_alloc0)
154 template<
typename _Alloc>
156 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
157 : _Head(allocator_arg, *__a._M_a) { }
159 template<
typename _Alloc>
161 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
162 : _Head(*__a._M_a) { }
164 template<
typename _UHead>
166 _Head_base(__uses_alloc0, _UHead&& __uhead)
169 template<
typename _Alloc,
typename _UHead>
171 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
172 : _Head(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead)) { }
174 template<
typename _Alloc,
typename _UHead>
176 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
177 : _Head(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
179 static constexpr _Head&
180 _M_head(_Head_base& __b)
noexcept {
return __b; }
182 static constexpr const _Head&
183 _M_head(
const _Head_base& __b)
noexcept {
return __b; }
187 template<
size_t _Idx,
typename _Head>
188 struct _Head_base<_Idx, _Head, false>
190 constexpr _Head_base()
193 constexpr _Head_base(
const _Head& __h)
194 : _M_head_impl(__h) { }
196 constexpr _Head_base(
const _Head_base&) =
default;
197 constexpr _Head_base(_Head_base&&) =
default;
199 template<
typename _UHead>
200 constexpr _Head_base(_UHead&& __h)
204 _Head_base(allocator_arg_t, __uses_alloc0)
207 template<
typename _Alloc>
209 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
210 : _M_head_impl(allocator_arg, *__a._M_a) { }
212 template<
typename _Alloc>
214 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
215 : _M_head_impl(*__a._M_a) { }
217 template<
typename _UHead>
219 _Head_base(__uses_alloc0, _UHead&& __uhead)
220 : _M_head_impl(
std::
forward<_UHead>(__uhead)) { }
222 template<
typename _Alloc,
typename _UHead>
224 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
225 : _M_head_impl(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead))
228 template<
typename _Alloc,
typename _UHead>
230 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
231 : _M_head_impl(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
233 static constexpr _Head&
234 _M_head(_Head_base& __b)
noexcept {
return __b._M_head_impl; }
236 static constexpr const _Head&
237 _M_head(
const _Head_base& __b)
noexcept {
return __b._M_head_impl; }
250 template<
size_t _Idx,
typename... _Elements>
258 template<
size_t _Idx,
typename _Head,
typename... _Tail>
261 private _Head_base<_Idx, _Head>
263 template<size_t,
typename...>
friend struct _Tuple_impl;
266 typedef _Head_base<_Idx, _Head> _Base;
268 static constexpr _Head&
269 _M_head(
_Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
271 static constexpr const _Head&
272 _M_head(
const _Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
278 _M_tail(
const _Tuple_impl& __t)
noexcept {
return __t; }
284 _Tuple_impl(
const _Head& __head,
const _Tail&... __tail)
288 template<
typename _UHead,
typename... _UTail,
289 typename = __enable_if_t<
sizeof...(_Tail) ==
sizeof...(_UTail)>>
292 :
_Inherited(std::forward<_UTail>(__tail)...),
293 _Base(std::forward<_UHead>(__head))
304 template<
typename... _UElements>
311 template<
typename _UHead,
typename... _UTails>
316 _Base(std::forward<_UHead>
320#if __cplusplus > 202002L
321 template<
typename... _UElements>
328 template<
typename _UHead,
typename... _UTails>
333 _Base(std::forward<const _UHead>
338 template<
typename _Alloc>
340 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a)
342 _Base(__tag, __use_alloc<_Head>(__a))
345 template<
typename _Alloc>
347 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
348 const _Head& __head,
const _Tail&... __tail)
350 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head)
353 template<
typename _Alloc,
typename _UHead,
typename... _UTail,
354 typename = __enable_if_t<
sizeof...(_Tail) ==
sizeof...(_UTail)>>
356 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
357 _UHead&& __head, _UTail&&... __tail)
358 :
_Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
359 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
360 std::forward<_UHead>(__head))
363 template<
typename _Alloc>
365 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
368 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in))
371 template<
typename _Alloc>
373 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
376 _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
377 std::forward<_Head>(_M_head(__in)))
380 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
382 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
386 _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
390 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
392 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
396 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
401#if __cplusplus > 202002L
402 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
404 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
408 _Base(__use_alloc<_Head, _Alloc, _UHead&>(__a),
412 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
414 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
418 _Base(__use_alloc<_Head, _Alloc, const _UHead>(__a),
419 std::forward<const _UHead>
424 template<
typename... _UElements>
430 _M_tail(*this)._M_assign(
434 template<
typename _UHead,
typename... _UTails>
439 _M_head(*
this) = std::forward<_UHead>
441 _M_tail(*this)._M_assign(
445#if __cplusplus > 202002L
446 template<
typename... _UElements>
451 _M_tail(*this)._M_assign(
455 template<
typename _UHead,
typename... _UTails>
459 _M_head(*
this) = std::forward<_UHead>
461 _M_tail(*this)._M_assign(
472 swap(_M_head(*
this), _M_head(__in));
473 _Inherited::_M_swap(_M_tail(__in));
476#if __cplusplus > 202002L
481 swap(_M_head(*
this), _M_head(__in));
482 _Inherited::_M_swap(_M_tail(__in));
488 template<
size_t _Idx,
typename _Head>
490 :
private _Head_base<_Idx, _Head>
492 template<size_t,
typename...>
friend struct _Tuple_impl;
494 typedef _Head_base<_Idx, _Head> _Base;
496 static constexpr _Head&
497 _M_head(
_Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
499 static constexpr const _Head&
500 _M_head(
const _Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
507 _Tuple_impl(
const _Head& __head)
511 template<
typename _UHead>
513 _Tuple_impl(_UHead&& __head)
517 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
521 _Tuple_impl& operator=(
const _Tuple_impl&) =
delete;
523#if _GLIBCXX_INLINE_VERSION
524 _Tuple_impl(_Tuple_impl&&) =
default;
527 _Tuple_impl(_Tuple_impl&& __in)
528 noexcept(is_nothrow_move_constructible<_Head>::value)
529 : _Base(
static_cast<_Base&&
>(__in))
533 template<
typename _UHead>
535 _Tuple_impl(
const _Tuple_impl<_Idx, _UHead>& __in)
536 : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in))
539 template<
typename _UHead>
541 _Tuple_impl(_Tuple_impl<_Idx, _UHead>&& __in)
542 : _Base(
std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
545#if __cplusplus > 202002L
546 template<
typename _UHead>
548 _Tuple_impl(_Tuple_impl<_Idx, _UHead>& __in)
549 : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in))
552 template<
typename _UHead>
554 _Tuple_impl(
const _Tuple_impl<_Idx, _UHead>&& __in)
555 : _Base(
std::
forward<const _UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
559 template<
typename _Alloc>
561 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a)
562 : _Base(__tag, __use_alloc<_Head>(__a))
565 template<
typename _Alloc>
567 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
569 : _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), __head)
572 template<
typename _Alloc,
typename _UHead>
574 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
576 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
580 template<
typename _Alloc>
582 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
583 const _Tuple_impl& __in)
584 : _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), _M_head(__in))
587 template<
typename _Alloc>
589 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
591 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
595 template<
typename _Alloc,
typename _UHead>
597 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
598 const _Tuple_impl<_Idx, _UHead>& __in)
599 : _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
600 _Tuple_impl<_Idx, _UHead>::_M_head(__in))
603 template<
typename _Alloc,
typename _UHead>
605 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
606 _Tuple_impl<_Idx, _UHead>&& __in)
607 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
608 std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
611#if __cplusplus > 202002L
612 template<
typename _Alloc,
typename _UHead>
614 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
615 _Tuple_impl<_Idx, _UHead>& __in)
616 : _Base(__use_alloc<_Head, _Alloc, _UHead&>(__a),
617 _Tuple_impl<_Idx, _UHead>::_M_head(__in))
620 template<
typename _Alloc,
typename _UHead>
622 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
623 const _Tuple_impl<_Idx, _UHead>&& __in)
624 : _Base(__use_alloc<_Head, _Alloc, const _UHead>(__a),
625 std::
forward<const _UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
629 template<
typename _UHead>
632 _M_assign(
const _Tuple_impl<_Idx, _UHead>& __in)
634 _M_head(*
this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in);
637 template<
typename _UHead>
640 _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
643 = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
646#if __cplusplus > 202002L
647 template<
typename _UHead>
649 _M_assign(
const _Tuple_impl<_Idx, _UHead>& __in)
const
651 _M_head(*
this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in);
654 template<
typename _UHead>
656 _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
const
659 = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
666 _M_swap(_Tuple_impl& __in)
669 swap(_M_head(*
this), _M_head(__in));
672#if __cplusplus > 202002L
674 _M_swap(
const _Tuple_impl& __in)
const
677 swap(_M_head(*
this), _M_head(__in));
684 template<bool,
typename... _Types>
685 struct _TupleConstraints
687 template<
typename... _UTypes>
688 using __constructible = __and_<is_constructible<_Types, _UTypes>...>;
690 template<
typename... _UTypes>
691 using __convertible = __and_<is_convertible<_UTypes, _Types>...>;
696 template<
typename... _UTypes>
697 static constexpr bool __is_implicitly_constructible()
699 return __and_<__constructible<_UTypes...>,
700 __convertible<_UTypes...>
707 template<
typename... _UTypes>
708 static constexpr bool __is_explicitly_constructible()
710 return __and_<__constructible<_UTypes...>,
711 __not_<__convertible<_UTypes...>>
715 static constexpr bool __is_implicitly_default_constructible()
717 return __and_<std::__is_implicitly_default_constructible<_Types>...
721 static constexpr bool __is_explicitly_default_constructible()
723 return __and_<is_default_constructible<_Types>...,
725 std::__is_implicitly_default_constructible<_Types>...>
732 template<
typename... _Types>
733 struct _TupleConstraints<false, _Types...>
735 template<
typename... _UTypes>
736 static constexpr bool __is_implicitly_constructible()
739 template<
typename... _UTypes>
740 static constexpr bool __is_explicitly_constructible()
745 template<
typename... _Elements>
751 using _TCC = _TupleConstraints<_Cond, _Elements...>;
754 template<
bool _Dummy>
755 using _ImplicitDefaultCtor = __enable_if_t<
756 _TCC<_Dummy>::__is_implicitly_default_constructible(),
760 template<
bool _Dummy>
761 using _ExplicitDefaultCtor = __enable_if_t<
762 _TCC<_Dummy>::__is_explicitly_default_constructible(),
766 template<
bool _Cond,
typename... _Args>
767 using _ImplicitCtor = __enable_if_t<
768 _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(),
772 template<
bool _Cond,
typename... _Args>
773 using _ExplicitCtor = __enable_if_t<
774 _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(),
777 template<
typename... _UElements>
779 __enable_if_t<
sizeof...(_UElements) ==
sizeof...(_Elements),
bool>
781 {
return __and_<is_assignable<_Elements&, _UElements>...>::value; }
784 template<
typename... _UElements>
785 static constexpr bool __nothrow_assignable()
788 __and_<is_nothrow_assignable<_Elements&, _UElements>...>::value;
792 template<
typename... _UElements>
793 static constexpr bool __nothrow_constructible()
796 __and_<is_nothrow_constructible<_Elements, _UElements>...>::value;
800 template<
typename _Up>
801 static constexpr bool __valid_args()
803 return sizeof...(_Elements) == 1
808 template<
typename,
typename,
typename... _Tail>
809 static constexpr bool __valid_args()
810 {
return (
sizeof...(_Tail) + 2) ==
sizeof...(_Elements); }
821 template<
typename _Tuple,
typename =
tuple,
822 typename = __remove_cvref_t<_Tuple>>
828 template<
typename _Tuple,
typename _Tp,
typename _Up>
829 struct _UseOtherCtor<_Tuple,
tuple<_Tp>,
tuple<_Up>>
830 : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>::type
834 template<
typename _Tuple,
typename _Tp>
835 struct _UseOtherCtor<_Tuple,
tuple<_Tp>,
tuple<_Tp>>
842 template<
typename _Tuple>
843 static constexpr bool __use_other_ctor()
844 {
return _UseOtherCtor<_Tuple>::value; }
846#if __cplusplus > 202002L
847 template<
typename... _Args>
848 static constexpr bool __constructible
849 = _TCC<true>::template __constructible<_Args...>::value;
851 template<
typename... _Args>
852 static constexpr bool __convertible
853 = _TCC<true>::template __convertible<_Args...>::value;
857 template<
typename _Dummy = void,
858 _ImplicitDefaultCtor<is_void<_Dummy>::value> =
true>
861 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
864 template<
typename _Dummy = void,
865 _ExplicitDefaultCtor<is_void<_Dummy>::value> =
false>
868 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
871 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
872 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
874 tuple(
const _Elements&... __elements)
875 noexcept(__nothrow_constructible<
const _Elements&...>())
878 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
879 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
881 tuple(
const _Elements&... __elements)
882 noexcept(__nothrow_constructible<
const _Elements&...>())
885 template<
typename... _UElements,
886 bool _Valid = __valid_args<_UElements...>(),
887 _ImplicitCtor<_Valid, _UElements...> =
true>
889 tuple(_UElements&&... __elements)
890 noexcept(__nothrow_constructible<_UElements...>())
891 :
_Inherited(std::forward<_UElements>(__elements)...) { }
893 template<
typename... _UElements,
894 bool _Valid = __valid_args<_UElements...>(),
895 _ExplicitCtor<_Valid, _UElements...> =
false>
897 tuple(_UElements&&... __elements)
898 noexcept(__nothrow_constructible<_UElements...>())
899 :
_Inherited(std::forward<_UElements>(__elements)...) { }
905 template<
typename... _UElements,
906 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
908 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
911 noexcept(__nothrow_constructible<
const _UElements&...>())
915 template<
typename... _UElements,
916 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
918 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
921 noexcept(__nothrow_constructible<
const _UElements&...>())
925 template<
typename... _UElements,
926 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
928 _ImplicitCtor<_Valid, _UElements...> =
true>
931 noexcept(__nothrow_constructible<_UElements...>())
934 template<
typename... _UElements,
935 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
937 _ExplicitCtor<_Valid, _UElements...> =
false>
940 noexcept(__nothrow_constructible<_UElements...>())
943#if __cplusplus > 202002L
944 template<
typename... _UElements>
945 requires (
sizeof...(_Elements) ==
sizeof...(_UElements))
947 && __constructible<_UElements&...>
948 explicit(!__convertible<_UElements&...>)
951 noexcept(__nothrow_constructible<_UElements&...>())
955 template<
typename... _UElements>
956 requires (
sizeof...(_Elements) ==
sizeof...(_UElements))
958 && __constructible<const _UElements...>
959 explicit(!__convertible<const _UElements...>)
962 noexcept(__nothrow_constructible<
const _UElements...>())
968 template<
typename _Alloc,
969 _ImplicitDefaultCtor<is_object<_Alloc>::value> =
true>
971 tuple(allocator_arg_t __tag,
const _Alloc& __a)
974 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
975 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
977 tuple(allocator_arg_t __tag,
const _Alloc& __a,
978 const _Elements&... __elements)
981 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
982 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
985 tuple(allocator_arg_t __tag,
const _Alloc& __a,
986 const _Elements&... __elements)
989 template<
typename _Alloc,
typename... _UElements,
990 bool _Valid = __valid_args<_UElements...>(),
991 _ImplicitCtor<_Valid, _UElements...> =
true>
993 tuple(allocator_arg_t __tag,
const _Alloc& __a,
994 _UElements&&... __elements)
995 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
998 template<
typename _Alloc,
typename... _UElements,
999 bool _Valid = __valid_args<_UElements...>(),
1000 _ExplicitCtor<_Valid, _UElements...> =
false>
1001 _GLIBCXX20_CONSTEXPR
1003 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1004 _UElements&&... __elements)
1005 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
1008 template<
typename _Alloc>
1009 _GLIBCXX20_CONSTEXPR
1010 tuple(allocator_arg_t __tag,
const _Alloc& __a,
const tuple& __in)
1013 template<
typename _Alloc>
1014 _GLIBCXX20_CONSTEXPR
1015 tuple(allocator_arg_t __tag,
const _Alloc& __a,
tuple&& __in)
1018 template<
typename _Alloc,
typename... _UElements,
1019 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1021 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
1022 _GLIBCXX20_CONSTEXPR
1023 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1026 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
1029 template<
typename _Alloc,
typename... _UElements,
1030 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1032 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
1033 _GLIBCXX20_CONSTEXPR
1035 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1038 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
1041 template<
typename _Alloc,
typename... _UElements,
1042 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1044 _ImplicitCtor<_Valid, _UElements...> =
true>
1045 _GLIBCXX20_CONSTEXPR
1046 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1049 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
1052 template<
typename _Alloc,
typename... _UElements,
1053 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1055 _ExplicitCtor<_Valid, _UElements...> =
false>
1056 _GLIBCXX20_CONSTEXPR
1058 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1061 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
1064#if __cplusplus > 202002L
1065 template<
typename _Alloc,
typename... _UElements>
1066 requires (
sizeof...(_Elements) ==
sizeof...(_UElements))
1068 && __constructible<_UElements&...>
1069 explicit(!__convertible<_UElements&...>)
1071 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1074 static_cast<_Tuple_impl<0, _UElements...
>&>(__in))
1077 template<
typename _Alloc,
typename... _UElements>
1078 requires (
sizeof...(_Elements) ==
sizeof...(_UElements))
1080 && __constructible<const _UElements...>
1081 explicit(!__convertible<const _UElements...>)
1083 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1086 static_cast<const _Tuple_impl<0, _UElements...
>&&>(__in))
1092 _GLIBCXX20_CONSTEXPR
1094 operator=(__conditional_t<__assignable<const _Elements&...>(),
1096 const __nonesuch&> __in)
1097 noexcept(__nothrow_assignable<
const _Elements&...>())
1099 this->_M_assign(__in);
1103 _GLIBCXX20_CONSTEXPR
1105 operator=(__conditional_t<__assignable<_Elements...>(),
1108 noexcept(__nothrow_assignable<_Elements...>())
1114 template<
typename... _UElements>
1115 _GLIBCXX20_CONSTEXPR
1116 __enable_if_t<__assignable<
const _UElements&...>(),
tuple&>
1118 noexcept(__nothrow_assignable<
const _UElements&...>())
1120 this->_M_assign(__in);
1124 template<
typename... _UElements>
1125 _GLIBCXX20_CONSTEXPR
1126 __enable_if_t<__assignable<_UElements...>(),
tuple&>
1128 noexcept(__nothrow_assignable<_UElements...>())
1134#if __cplusplus > 202002L
1135 constexpr const tuple&
1136 operator=(
const tuple& __in)
const
1137 requires (is_copy_assignable_v<const _Elements> && ...)
1139 this->_M_assign(__in);
1143 constexpr const tuple&
1144 operator=(
tuple&& __in)
const
1145 requires (is_assignable_v<const _Elements&, _Elements> && ...)
1151 template<
typename... _UElements>
1152 constexpr const tuple&
1154 requires (
sizeof...(_Elements) ==
sizeof...(_UElements))
1155 && (is_assignable_v<const _Elements&, const _UElements&> && ...)
1157 this->_M_assign(__in);
1161 template<
typename... _UElements>
1162 constexpr const tuple&
1164 requires (
sizeof...(_Elements) ==
sizeof...(_UElements))
1165 && (is_assignable_v<const _Elements&, _UElements> && ...)
1173 _GLIBCXX20_CONSTEXPR
1176 noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value)
1177 { _Inherited::_M_swap(__in); }
1179#if __cplusplus > 202002L
1187 swap(
const tuple& __in)
const
1188 noexcept(__and_v<__is_nothrow_swappable<const _Elements>...>)
1189 requires (is_swappable_v<const _Elements> && ...)
1190 { _Inherited::_M_swap(__in); }
1194#if __cpp_deduction_guides >= 201606
1195 template<
typename... _UTypes>
1197 template<
typename _T1,
typename _T2>
1199 template<
typename _Alloc,
typename... _UTypes>
1200 tuple(allocator_arg_t, _Alloc, _UTypes...) ->
tuple<_UTypes...>;
1201 template<
typename _Alloc,
typename _T1,
typename _T2>
1203 template<
typename _Alloc,
typename... _UTypes>
1212 _GLIBCXX20_CONSTEXPR
1213 void swap(
tuple&)
noexcept { }
1214#if __cplusplus > 202002L
1215 constexpr void swap(
const tuple&)
const noexcept { }
1221 template<
typename _Alloc>
1222 _GLIBCXX20_CONSTEXPR
1223 tuple(allocator_arg_t,
const _Alloc&)
noexcept { }
1224 template<
typename _Alloc>
1225 _GLIBCXX20_CONSTEXPR
1226 tuple(allocator_arg_t,
const _Alloc&,
const tuple&)
noexcept { }
1231 template<
typename _T1,
typename _T2>
1237 template<
bool _Dummy,
typename _U1,
typename _U2>
1238 using _ImplicitDefaultCtor = __enable_if_t<
1239 _TupleConstraints<_Dummy, _U1, _U2>::
1240 __is_implicitly_default_constructible(),
1244 template<
bool _Dummy,
typename _U1,
typename _U2>
1245 using _ExplicitDefaultCtor = __enable_if_t<
1246 _TupleConstraints<_Dummy, _U1, _U2>::
1247 __is_explicitly_default_constructible(),
1250 template<
bool _Dummy>
1251 using _TCC = _TupleConstraints<_Dummy, _T1, _T2>;
1254 template<
bool _Cond,
typename _U1,
typename _U2>
1255 using _ImplicitCtor = __enable_if_t<
1256 _TCC<_Cond>::template __is_implicitly_constructible<_U1, _U2>(),
1260 template<
bool _Cond,
typename _U1,
typename _U2>
1261 using _ExplicitCtor = __enable_if_t<
1262 _TCC<_Cond>::template __is_explicitly_constructible<_U1, _U2>(),
1265 template<
typename _U1,
typename _U2>
1266 static constexpr bool __assignable()
1268 return __and_<is_assignable<_T1&, _U1>,
1272 template<
typename _U1,
typename _U2>
1273 static constexpr bool __nothrow_assignable()
1275 return __and_<is_nothrow_assignable<_T1&, _U1>,
1279 template<
typename _U1,
typename _U2>
1280 static constexpr bool __nothrow_constructible()
1282 return __and_<is_nothrow_constructible<_T1, _U1>,
1286 static constexpr bool __nothrow_default_constructible()
1288 return __and_<is_nothrow_default_constructible<_T1>,
1292 template<
typename _U1>
1293 static constexpr bool __is_alloc_arg()
1296#if __cplusplus > 202002L
1297 template<
typename _U1,
typename _U2>
1298 static constexpr bool __constructible
1299 = _TCC<true>::template __constructible<_U1, _U2>::value;
1301 template<
typename _U1,
typename _U2>
1302 static constexpr bool __convertible
1303 = _TCC<true>::template __convertible<_U1, _U2>::value;
1307 template<
bool _Dummy =
true,
1308 _ImplicitDefaultCtor<_Dummy, _T1, _T2> =
true>
1311 noexcept(__nothrow_default_constructible())
1314 template<
bool _Dummy =
true,
1315 _ExplicitDefaultCtor<_Dummy, _T1, _T2> =
false>
1318 noexcept(__nothrow_default_constructible())
1321 template<
bool _Dummy =
true,
1322 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1324 tuple(
const _T1& __a1,
const _T2& __a2)
1325 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
1328 template<
bool _Dummy =
true,
1329 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1331 tuple(
const _T1& __a1,
const _T2& __a2)
1332 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
1335 template<
typename _U1,
typename _U2,
1336 _ImplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
true>
1338 tuple(_U1&& __a1, _U2&& __a2)
1339 noexcept(__nothrow_constructible<_U1, _U2>())
1340 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
1342 template<
typename _U1,
typename _U2,
1343 _ExplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
false>
1345 tuple(_U1&& __a1, _U2&& __a2)
1346 noexcept(__nothrow_constructible<_U1, _U2>())
1347 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
1353 template<
typename _U1,
typename _U2,
1354 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1357 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1360 template<
typename _U1,
typename _U2,
1361 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1364 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1367 template<
typename _U1,
typename _U2,
1368 _ImplicitCtor<true, _U1, _U2> =
true>
1371 noexcept(__nothrow_constructible<_U1, _U2>())
1374 template<
typename _U1,
typename _U2,
1375 _ExplicitCtor<true, _U1, _U2> =
false>
1378 noexcept(__nothrow_constructible<_U1, _U2>())
1381#if __cplusplus > 202002L
1382 template<
typename _U1,
typename _U2>
1383 requires __constructible<_U1&, _U2&>
1384 explicit(!__convertible<_U1&, _U2&>)
1387 noexcept(__nothrow_constructible<_U1&, _U2&>())
1390 template<
typename _U1,
typename _U2>
1391 requires __constructible<const _U1, const _U2>
1392 explicit(!__convertible<const _U1, const _U2>)
1395 noexcept(__nothrow_constructible<const _U1, const _U2>())
1399 template<
typename _U1,
typename _U2,
1400 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1403 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1406 template<
typename _U1,
typename _U2,
1407 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1410 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1413 template<
typename _U1,
typename _U2,
1414 _ImplicitCtor<true, _U1, _U2> =
true>
1417 noexcept(__nothrow_constructible<_U1, _U2>())
1419 std::forward<_U2>(__in.second)) { }
1421 template<
typename _U1,
typename _U2,
1422 _ExplicitCtor<true, _U1, _U2> =
false>
1425 noexcept(__nothrow_constructible<_U1, _U2>())
1427 std::forward<_U2>(__in.second)) { }
1429#if __cplusplus > 202002L
1430 template<
typename _U1,
typename _U2>
1431 requires __constructible<_U1&, _U2&>
1432 explicit(!__convertible<_U1&, _U2&>)
1435 noexcept(__nothrow_constructible<_U1&, _U2&>())
1438 template<
typename _U1,
typename _U2>
1439 requires __constructible<const _U1, const _U2>
1440 explicit(!__convertible<const _U1, const _U2>)
1443 noexcept(__nothrow_constructible<const _U1, const _U2>())
1444 :
_Inherited(std::forward<const _U1>(__in.first),
1445 std::forward<const _U2>(__in.second)) { }
1450 template<
typename _Alloc,
1451 _ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> =
true>
1452 _GLIBCXX20_CONSTEXPR
1453 tuple(allocator_arg_t __tag,
const _Alloc& __a)
1456 template<
typename _Alloc,
bool _Dummy =
true,
1457 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1458 _GLIBCXX20_CONSTEXPR
1459 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1460 const _T1& __a1,
const _T2& __a2)
1463 template<
typename _Alloc,
bool _Dummy =
true,
1464 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1466 _GLIBCXX20_CONSTEXPR
1467 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1468 const _T1& __a1,
const _T2& __a2)
1471 template<
typename _Alloc,
typename _U1,
typename _U2,
1472 _ImplicitCtor<true, _U1, _U2> =
true>
1473 _GLIBCXX20_CONSTEXPR
1474 tuple(allocator_arg_t __tag,
const _Alloc& __a, _U1&& __a1, _U2&& __a2)
1475 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1476 std::forward<_U2>(__a2)) { }
1478 template<
typename _Alloc,
typename _U1,
typename _U2,
1479 _ExplicitCtor<true, _U1, _U2> =
false>
1481 _GLIBCXX20_CONSTEXPR
1482 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1483 _U1&& __a1, _U2&& __a2)
1484 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1485 std::forward<_U2>(__a2)) { }
1487 template<
typename _Alloc>
1488 _GLIBCXX20_CONSTEXPR
1489 tuple(allocator_arg_t __tag,
const _Alloc& __a,
const tuple& __in)
1492 template<
typename _Alloc>
1493 _GLIBCXX20_CONSTEXPR
1494 tuple(allocator_arg_t __tag,
const _Alloc& __a,
tuple&& __in)
1497 template<
typename _Alloc,
typename _U1,
typename _U2,
1498 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1499 _GLIBCXX20_CONSTEXPR
1500 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1506 template<
typename _Alloc,
typename _U1,
typename _U2,
1507 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1509 _GLIBCXX20_CONSTEXPR
1510 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1516 template<
typename _Alloc,
typename _U1,
typename _U2,
1517 _ImplicitCtor<true, _U1, _U2> =
true>
1518 _GLIBCXX20_CONSTEXPR
1523 template<
typename _Alloc,
typename _U1,
typename _U2,
1524 _ExplicitCtor<true, _U1, _U2> =
false>
1526 _GLIBCXX20_CONSTEXPR
1531#if __cplusplus > 202002L
1532 template<
typename _Alloc,
typename _U1,
typename _U2>
1533 requires __constructible<_U1&, _U2&>
1534 explicit(!__convertible<_U1&, _U2&>)
1536 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1542 template<
typename _Alloc,
typename _U1,
typename _U2>
1543 requires __constructible<const _U1, const _U2>
1544 explicit(!__convertible<const _U1, const _U2>)
1546 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1553 template<
typename _Alloc,
typename _U1,
typename _U2,
1554 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1555 _GLIBCXX20_CONSTEXPR
1556 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1558 :
_Inherited(__tag, __a, __in.first, __in.second) { }
1560 template<
typename _Alloc,
typename _U1,
typename _U2,
1561 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1563 _GLIBCXX20_CONSTEXPR
1564 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1566 :
_Inherited(__tag, __a, __in.first, __in.second) { }
1568 template<
typename _Alloc,
typename _U1,
typename _U2,
1569 _ImplicitCtor<true, _U1, _U2> =
true>
1570 _GLIBCXX20_CONSTEXPR
1572 :
_Inherited(__tag, __a, std::forward<_U1>(__in.first),
1573 std::forward<_U2>(__in.second)) { }
1575 template<
typename _Alloc,
typename _U1,
typename _U2,
1576 _ExplicitCtor<true, _U1, _U2> =
false>
1578 _GLIBCXX20_CONSTEXPR
1580 :
_Inherited(__tag, __a, std::forward<_U1>(__in.first),
1581 std::forward<_U2>(__in.second)) { }
1583#if __cplusplus > 202002L
1584 template<
typename _Alloc,
typename _U1,
typename _U2>
1585 requires __constructible<_U1&, _U2&>
1586 explicit(!__convertible<_U1&, _U2&>)
1588 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1590 :
_Inherited(__tag, __a, __in.first, __in.second) { }
1592 template<
typename _Alloc,
typename _U1,
typename _U2>
1593 requires __constructible<const _U1, const _U2>
1594 explicit(!__convertible<const _U1, const _U2>)
1597 :
_Inherited(__tag, __a, std::forward<const _U1>(__in.first),
1598 std::forward<const _U2>(__in.second)) { }
1603 _GLIBCXX20_CONSTEXPR
1605 operator=(__conditional_t<__assignable<const _T1&, const _T2&>(),
1607 const __nonesuch&> __in)
1608 noexcept(__nothrow_assignable<const _T1&, const _T2&>())
1610 this->_M_assign(__in);
1614 _GLIBCXX20_CONSTEXPR
1616 operator=(__conditional_t<__assignable<_T1, _T2>(),
1619 noexcept(__nothrow_assignable<_T1, _T2>())
1625 template<
typename _U1,
typename _U2>
1626 _GLIBCXX20_CONSTEXPR
1627 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
1629 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1631 this->_M_assign(__in);
1635 template<
typename _U1,
typename _U2>
1636 _GLIBCXX20_CONSTEXPR
1637 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
1639 noexcept(__nothrow_assignable<_U1, _U2>())
1645#if __cplusplus > 202002L
1646 constexpr const tuple&
1647 operator=(
const tuple& __in)
const
1648 requires is_copy_assignable_v<const _T1> && is_copy_assignable_v<const _T2>
1650 this->_M_assign(__in);
1654 constexpr const tuple&
1655 operator=(
tuple&& __in)
const
1656 requires is_assignable_v<const _T1&, _T1> && is_assignable_v<const _T2, _T2>
1662 template<
typename _U1,
typename _U2>
1663 constexpr const tuple&
1665 requires is_assignable_v<const _T1&, const _U1&>
1666 && is_assignable_v<const _T2&, const _U2&>
1668 this->_M_assign(__in);
1672 template<
typename _U1,
typename _U2>
1673 constexpr const tuple&
1675 requires is_assignable_v<const _T1&, _U1>
1676 && is_assignable_v<const _T2&, _U2>
1683 template<
typename _U1,
typename _U2>
1684 _GLIBCXX20_CONSTEXPR
1685 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
1687 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1689 this->_M_head(*
this) = __in.first;
1690 this->_M_tail(*this)._M_head(*
this) = __in.second;
1694 template<
typename _U1,
typename _U2>
1695 _GLIBCXX20_CONSTEXPR
1696 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
1698 noexcept(__nothrow_assignable<_U1, _U2>())
1700 this->_M_head(*
this) = std::forward<_U1>(__in.first);
1701 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.second);
1705#if __cplusplus > 202002L
1706 template<
typename _U1,
typename _U2>
1707 constexpr const tuple&
1709 requires is_assignable_v<const _T1&, const _U1&>
1710 && is_assignable_v<const _T2&, const _U2&>
1712 this->_M_head(*
this) = __in.first;
1713 this->_M_tail(*this)._M_head(*
this) = __in.second;
1717 template<
typename _U1,
typename _U2>
1718 constexpr const tuple&
1720 requires is_assignable_v<const _T1&, _U1>
1721 && is_assignable_v<const _T2&, _U2>
1723 this->_M_head(*
this) = std::forward<_U1>(__in.first);
1724 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.second);
1729 _GLIBCXX20_CONSTEXPR
1732 noexcept(__and_<__is_nothrow_swappable<_T1>,
1733 __is_nothrow_swappable<_T2>>::value)
1734 { _Inherited::_M_swap(__in); }
1736#if __cplusplus > 202002L
1738 swap(
const tuple& __in)
const
1739 noexcept(__and_v<__is_nothrow_swappable<const _T1>,
1740 __is_nothrow_swappable<const _T2>>)
1741 requires is_swappable_v<const _T1> && is_swappable_v<const _T2>
1742 { _Inherited::_M_swap(__in); }
1748 template<
typename... _Elements>
1752#if __cplusplus >= 201703L
1753 template<
typename... _Types>
1754 inline constexpr size_t tuple_size_v<
tuple<_Types...>>
1755 =
sizeof...(_Types);
1757 template<
typename... _Types>
1758 inline constexpr size_t tuple_size_v<
const tuple<_Types...>>
1759 =
sizeof...(_Types);
1763 template<
size_t __i,
typename... _Types>
1766 static_assert(__i <
sizeof...(_Types),
"tuple index must be in range");
1768 using type =
typename _Nth_type<__i, _Types...>::type;
1771 template<
size_t __i,
typename _Head,
typename... _Tail>
1776 template<
size_t __i,
typename _Head,
typename... _Tail>
1777 constexpr const _Head&
1778 __get_helper(
const _Tuple_impl<__i, _Head, _Tail...>& __t)
noexcept
1779 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1782 template<
size_t __i,
typename... _Types>
1783 __enable_if_t<(__i >=
sizeof...(_Types))>
1784 __get_helper(
const tuple<_Types...>&) =
delete;
1787 template<
size_t __i,
typename... _Elements>
1788 constexpr __tuple_element_t<__i, tuple<_Elements...>>&
1790 {
return std::__get_helper<__i>(__t); }
1793 template<
size_t __i,
typename... _Elements>
1794 constexpr const __tuple_element_t<__i, tuple<_Elements...>>&
1796 {
return std::__get_helper<__i>(__t); }
1799 template<
size_t __i,
typename... _Elements>
1800 constexpr __tuple_element_t<__i, tuple<_Elements...>>&&
1803 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1804 return std::forward<__element_type>(std::__get_helper<__i>(__t));
1808 template<
size_t __i,
typename... _Elements>
1809 constexpr const __tuple_element_t<__i, tuple<_Elements...>>&&
1812 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1813 return std::forward<const __element_type>(std::__get_helper<__i>(__t));
1818 template<
size_t __i,
typename... _Elements>
1819 constexpr __enable_if_t<(__i >=
sizeof...(_Elements))>
1820 get(
const tuple<_Elements...>&) =
delete;
1823#if __cplusplus >= 201402L
1825#define __cpp_lib_tuples_by_type 201304L
1828 template <
typename _Tp,
typename... _Types>
1832 constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1833 static_assert(__idx <
sizeof...(_Types),
1834 "the type T in std::get<T> must occur exactly once in the tuple");
1835 return std::__get_helper<__idx>(__t);
1839 template <
typename _Tp,
typename... _Types>
1843 constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1844 static_assert(__idx <
sizeof...(_Types),
1845 "the type T in std::get<T> must occur exactly once in the tuple");
1846 return std::forward<_Tp>(std::__get_helper<__idx>(__t));
1850 template <
typename _Tp,
typename... _Types>
1851 constexpr const _Tp&
1854 constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1855 static_assert(__idx <
sizeof...(_Types),
1856 "the type T in std::get<T> must occur exactly once in the tuple");
1857 return std::__get_helper<__idx>(__t);
1862 template <
typename _Tp,
typename... _Types>
1863 constexpr const _Tp&&
1866 constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1867 static_assert(__idx <
sizeof...(_Types),
1868 "the type T in std::get<T> must occur exactly once in the tuple");
1869 return std::forward<const _Tp>(std::__get_helper<__idx>(__t));
1874 template<
typename _Tp,
typename _Up,
size_t __i,
size_t __size>
1875 struct __tuple_compare
1877 static constexpr bool
1878 __eq(
const _Tp& __t,
const _Up& __u)
1880 return bool(std::get<__i>(__t) == std::get<__i>(__u))
1881 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u);
1884 static constexpr bool
1885 __less(
const _Tp& __t,
const _Up& __u)
1887 return bool(std::get<__i>(__t) < std::get<__i>(__u))
1888 || (!bool(std::get<__i>(__u) < std::get<__i>(__t))
1889 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u));
1893 template<
typename _Tp,
typename _Up,
size_t __size>
1894 struct __tuple_compare<_Tp, _Up, __size, __size>
1896 static constexpr bool
1897 __eq(
const _Tp&,
const _Up&) {
return true; }
1899 static constexpr bool
1900 __less(
const _Tp&,
const _Up&) {
return false; }
1903 template<
typename... _TElements,
typename... _UElements>
1905 operator==(
const tuple<_TElements...>& __t,
1906 const tuple<_UElements...>& __u)
1908 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1909 "tuple objects can only be compared if they have equal sizes.");
1910 using __compare = __tuple_compare<tuple<_TElements...>,
1911 tuple<_UElements...>,
1912 0,
sizeof...(_TElements)>;
1913 return __compare::__eq(__t, __u);
1916#if __cpp_lib_three_way_comparison
1917 template<
typename _Cat,
typename _Tp,
typename _Up>
1919 __tuple_cmp(
const _Tp&,
const _Up&, index_sequence<>)
1920 {
return _Cat::equivalent; }
1922 template<
typename _Cat,
typename _Tp,
typename _Up,
1923 size_t _Idx0,
size_t... _Idxs>
1925 __tuple_cmp(
const _Tp& __t,
const _Up& __u,
1926 index_sequence<_Idx0, _Idxs...>)
1929 = __detail::__synth3way(std::get<_Idx0>(__t), std::get<_Idx0>(__u));
1932 return std::__tuple_cmp<_Cat>(__t, __u, index_sequence<_Idxs...>());
1935 template<
typename... _Tps,
typename... _Ups>
1937 common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>
1938 operator<=>(
const tuple<_Tps...>& __t,
const tuple<_Ups...>& __u)
1941 = common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>;
1942 return std::__tuple_cmp<_Cat>(__t, __u, index_sequence_for<_Tps...>());
1945 template<
typename... _TElements,
typename... _UElements>
1947 operator<(
const tuple<_TElements...>& __t,
1948 const tuple<_UElements...>& __u)
1950 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1951 "tuple objects can only be compared if they have equal sizes.");
1952 using __compare = __tuple_compare<tuple<_TElements...>,
1953 tuple<_UElements...>,
1954 0,
sizeof...(_TElements)>;
1955 return __compare::__less(__t, __u);
1958 template<
typename... _TElements,
typename... _UElements>
1960 operator!=(
const tuple<_TElements...>& __t,
1961 const tuple<_UElements...>& __u)
1962 {
return !(__t == __u); }
1964 template<
typename... _TElements,
typename... _UElements>
1966 operator>(
const tuple<_TElements...>& __t,
1967 const tuple<_UElements...>& __u)
1968 {
return __u < __t; }
1970 template<
typename... _TElements,
typename... _UElements>
1972 operator<=(
const tuple<_TElements...>& __t,
1973 const tuple<_UElements...>& __u)
1974 {
return !(__u < __t); }
1976 template<
typename... _TElements,
typename... _UElements>
1978 operator>=(
const tuple<_TElements...>& __t,
1979 const tuple<_UElements...>& __u)
1980 {
return !(__t < __u); }
1985 template<
typename... _Elements>
1986 constexpr tuple<typename __decay_and_strip<_Elements>::__type...>
1991 return __result_type(std::forward<_Elements>(__args)...);
1997 template<
typename... _Elements>
1998 constexpr tuple<_Elements&&...>
2000 {
return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
2005 template<
typename _Tp,
size_t _Nm>
struct array;
2007 template<
size_t _Int,
typename _Tp,
size_t _Nm>
2009 get(array<_Tp, _Nm>&)
noexcept;
2011 template<
size_t _Int,
typename _Tp,
size_t _Nm>
2013 get(array<_Tp, _Nm>&&) noexcept;
2015 template<
size_t _Int, typename _Tp,
size_t _Nm>
2016 constexpr const _Tp&
2017 get(const array<_Tp, _Nm>&) noexcept;
2019 template<
size_t _Int, typename _Tp,
size_t _Nm>
2020 constexpr const _Tp&&
2021 get(const array<_Tp, _Nm>&&) noexcept;
2024 template<
size_t, typename, typename,
size_t>
2025 struct __make_tuple_impl;
2027 template<
size_t _Idx, typename _Tuple, typename... _Tp,
size_t _Nm>
2028 struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
2029 : __make_tuple_impl<_Idx + 1,
2030 tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
2034 template<
size_t _Nm,
typename _Tuple,
typename... _Tp>
2035 struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
2037 typedef tuple<_Tp...> __type;
2040 template<
typename _Tuple>
2041 struct __do_make_tuple
2042 : __make_tuple_impl<0, tuple<>, _Tuple, tuple_size<_Tuple>::value>
2046 template<
typename _Tuple>
2048 :
public __do_make_tuple<__remove_cvref_t<_Tuple>>
2052 template<
typename...>
2053 struct __combine_tuples;
2056 struct __combine_tuples<>
2058 typedef tuple<> __type;
2061 template<
typename... _Ts>
2062 struct __combine_tuples<tuple<_Ts...>>
2064 typedef tuple<_Ts...> __type;
2067 template<
typename... _T1s,
typename... _T2s,
typename... _Rem>
2068 struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
2070 typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
2071 _Rem...>::__type __type;
2075 template<
typename... _Tpls>
2076 struct __tuple_cat_result
2078 typedef typename __combine_tuples
2079 <
typename __make_tuple<_Tpls>::__type...>::__type __type;
2084 template<
typename...>
2085 struct __make_1st_indices;
2088 struct __make_1st_indices<>
2090 typedef _Index_tuple<> __type;
2093 template<
typename _Tp,
typename... _Tpls>
2094 struct __make_1st_indices<_Tp, _Tpls...>
2096 typedef typename _Build_index_tuple<tuple_size<
2097 typename remove_reference<_Tp>::type>::value>::__type __type;
2103 template<
typename _Ret,
typename _Indices,
typename... _Tpls>
2104 struct __tuple_concater;
2106 template<
typename _Ret,
size_t... _Is,
typename _Tp,
typename... _Tpls>
2107 struct __tuple_concater<_Ret, _Index_tuple<_Is...>, _Tp, _Tpls...>
2109 template<
typename... _Us>
2110 static constexpr _Ret
2111 _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
2113 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
2114 typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
2115 return __next::_S_do(std::forward<_Tpls>(__tps)...,
2116 std::forward<_Us>(__us)...,
2117 std::get<_Is>(std::forward<_Tp>(__tp))...);
2121 template<
typename _Ret>
2122 struct __tuple_concater<_Ret, _Index_tuple<>>
2124 template<
typename... _Us>
2125 static constexpr _Ret
2126 _S_do(_Us&&... __us)
2128 return _Ret(std::forward<_Us>(__us)...);
2132 template<
typename... _Tps>
2133 struct __is_tuple_like_impl<tuple<_Tps...>> :
true_type
2138 template<
typename... _Tpls,
typename =
typename
2139 enable_if<__and_<__is_tuple_like<_Tpls>...>::value>::type>
2142 ->
typename __tuple_cat_result<_Tpls...>::__type
2144 typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
2145 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
2146 typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
2147 return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
2153 template<
typename... _Elements>
2154 constexpr tuple<_Elements&...>
2155 tie(_Elements&... __args)
noexcept
2156 {
return tuple<_Elements&...>(__args...); }
2159 template<
typename... _Elements>
2160 _GLIBCXX20_CONSTEXPR
2162#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
2164 typename enable_if<__and_<__is_swappable<_Elements>...>::value
2170 noexcept(
noexcept(__x.swap(__y)))
2173#if __cplusplus > 202002L
2174 template<
typename... _Elements>
2175 requires (is_swappable_v<const _Elements> && ...)
2177 swap(
const tuple<_Elements...>& __x,
const tuple<_Elements...>& __y)
2178 noexcept(
noexcept(__x.swap(__y)))
2182#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
2184 template<typename... _Elements>
2185 _GLIBCXX20_CONSTEXPR
2186 typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type
2187 swap(tuple<_Elements...>&, tuple<_Elements...>&) =
delete;
2194 struct _Swallow_assign
2197 _GLIBCXX14_CONSTEXPR
const _Swallow_assign&
2198 operator=(
const _Tp&)
const
2219 _GLIBCXX17_INLINE
constexpr _Swallow_assign
ignore{};
2222 template<
typename... _Types,
typename _Alloc>
2234 template<
class _T1,
class _T2>
2235 template<
typename... _Args1,
typename... _Args2>
2236 _GLIBCXX20_CONSTEXPR
2241 :
pair(__first, __second,
2242 typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
2243 typename _Build_index_tuple<sizeof...(_Args2)>::__type())
2246 template<
class _T1,
class _T2>
2247 template<
typename... _Args1,
size_t... _Indexes1,
2248 typename... _Args2,
size_t... _Indexes2>
2249 _GLIBCXX20_CONSTEXPR
inline
2252 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
2253 : first(
std::
forward<_Args1>(
std::get<_Indexes1>(__tuple1))...),
2254 second(
std::
forward<_Args2>(
std::get<_Indexes2>(__tuple2))...)
2257#if __cplusplus >= 201703L
2263 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _Tuple>
2264 inline constexpr bool __unpack_std_tuple =
false;
2266 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
2267 inline constexpr bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>>
2268 = _Trait<_Tp, _Up...>::value;
2270 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
2271 inline constexpr bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>&>
2272 = _Trait<_Tp, _Up&...>::value;
2274 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
2275 inline constexpr bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>>
2276 = _Trait<_Tp,
const _Up...>::value;
2278 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
2279 inline constexpr bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>&>
2280 = _Trait<_Tp,
const _Up&...>::value;
2282# define __cpp_lib_apply 201603L
2284 template <
typename _Fn,
typename _Tuple,
size_t... _Idx>
2285 constexpr decltype(
auto)
2286 __apply_impl(_Fn&& __f, _Tuple&& __t, index_sequence<_Idx...>)
2289 std::get<_Idx>(std::forward<_Tuple>(__t))...);
2292 template <
typename _Fn,
typename _Tuple>
2293 constexpr decltype(
auto)
2294 apply(_Fn&& __f, _Tuple&& __t)
2295 noexcept(__unpack_std_tuple<is_nothrow_invocable, _Fn, _Tuple>)
2298 = make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>;
2299 return std::__apply_impl(std::forward<_Fn>(__f),
2300 std::forward<_Tuple>(__t),
2304#define __cpp_lib_make_from_tuple 201606L
2306 template <
typename _Tp,
typename _Tuple,
size_t... _Idx>
2308 __make_from_tuple_impl(_Tuple&& __t, index_sequence<_Idx...>)
2309 {
return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); }
2311 template <
typename _Tp,
typename _Tuple>
2313 make_from_tuple(_Tuple&& __t)
2314 noexcept(__unpack_std_tuple<is_nothrow_constructible, _Tp, _Tuple>)
2316 constexpr size_t __n = tuple_size_v<remove_reference_t<_Tuple>>;
2317#if __has_builtin(__reference_constructs_from_temporary)
2318 if constexpr (__n == 1)
2320 using _Elt =
decltype(std::get<0>(std::declval<_Tuple>()));
2321 static_assert(!__reference_constructs_from_temporary(_Tp, _Elt));
2324 return __make_from_tuple_impl<_Tp>(std::forward<_Tuple>(__t),
2325 make_index_sequence<__n>{});
2329#if __cplusplus > 202002L
2330 template<
typename... _TTypes,
typename... _UTypes,
2331 template<
typename>
class _TQual,
template<
typename>
class _UQual>
2332 requires requires {
typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; }
2333 struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual>
2334 {
using type = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; };
2336 template<
typename... _TTypes,
typename... _UTypes>
2337 requires requires {
typename tuple<common_type_t<_TTypes, _UTypes>...>; }
2338 struct common_type<tuple<_TTypes...>, tuple<_UTypes...>>
2339 {
using type = tuple<common_type_t<_TTypes, _UTypes>...>; };
2344_GLIBCXX_END_NAMESPACE_VERSION
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
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
Create a tuple containing all elements from multiple tuple-like objects.
constexpr tuple< _Elements &&... > forward_as_tuple(_Elements &&... __args) noexcept
Create a tuple of lvalue or rvalue references to the arguments.
constexpr const _Tp && get(const tuple< _Types... > &&__t) noexcept
Return a const reference to the unique element of type _Tp of a const tuple rvalue.
constexpr tuple< typename __decay_and_strip< _Elements >::__type... > make_tuple(_Elements &&... __args)
Create a tuple containing copies of the arguments.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Swallow_assign ignore
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
Return a tuple of lvalue references bound to the arguments.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.
Primary class template, tuple.
Partial specialization, 2-element tuple. Includes construction and assignment from a pair.
is_nothrow_default_constructible
Declare uses_allocator so it can be specialized in <queue> etc.
Struct holding two objects of arbitrary type.
Tag type for piecewise construction of std::pair objects.
Finds the size of a given tuple type.
Gives the type of the ith element of a given tuple type.