30#define _GLIBCXX_TUPLE 1
32#pragma GCC system_header
34#if __cplusplus < 201103L
39#include <bits/uses_allocator.h>
42#if __cplusplus > 201703L
44# define __cpp_lib_constexpr_tuple 201811L
47namespace std _GLIBCXX_VISIBILITY(default)
49_GLIBCXX_BEGIN_NAMESPACE_VERSION
56 template<
typename... _Elements>
59 template<
typename _Tp>
60 struct __is_empty_non_tuple : is_empty<_Tp> { };
63 template<
typename _El0,
typename... _El>
64 struct __is_empty_non_tuple<tuple<_El0, _El...>> :
false_type { };
67 template<
typename _Tp>
68 using __empty_not_final
70 __is_empty_non_tuple<_Tp>>;
72 template<
size_t _Idx,
typename _Head,
73 bool = __empty_not_final<_Head>::value>
76#if __has_cpp_attribute(__no_unique_address__)
77 template<
size_t _Idx,
typename _Head>
78 struct _Head_base<_Idx, _Head, true>
80 constexpr _Head_base()
83 constexpr _Head_base(
const _Head& __h)
84 : _M_head_impl(__h) { }
86 constexpr _Head_base(
const _Head_base&) =
default;
87 constexpr _Head_base(_Head_base&&) =
default;
89 template<
typename _UHead>
90 constexpr _Head_base(_UHead&& __h)
94 _Head_base(allocator_arg_t, __uses_alloc0)
97 template<
typename _Alloc>
99 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
100 : _M_head_impl(allocator_arg, *__a._M_a) { }
102 template<
typename _Alloc>
104 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
105 : _M_head_impl(*__a._M_a) { }
107 template<
typename _UHead>
109 _Head_base(__uses_alloc0, _UHead&& __uhead)
110 : _M_head_impl(
std::
forward<_UHead>(__uhead)) { }
112 template<
typename _Alloc,
typename _UHead>
114 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
115 : _M_head_impl(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead))
118 template<
typename _Alloc,
typename _UHead>
120 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
121 : _M_head_impl(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
123 static constexpr _Head&
124 _M_head(_Head_base& __b)
noexcept {
return __b._M_head_impl; }
126 static constexpr const _Head&
127 _M_head(
const _Head_base& __b)
noexcept {
return __b._M_head_impl; }
129 [[__no_unique_address__]] _Head _M_head_impl;
132 template<
size_t _Idx,
typename _Head>
133 struct _Head_base<_Idx, _Head, true>
136 constexpr _Head_base()
139 constexpr _Head_base(
const _Head& __h)
142 constexpr _Head_base(
const _Head_base&) =
default;
143 constexpr _Head_base(_Head_base&&) =
default;
145 template<
typename _UHead>
146 constexpr _Head_base(_UHead&& __h)
150 _Head_base(allocator_arg_t, __uses_alloc0)
153 template<
typename _Alloc>
155 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
156 : _Head(allocator_arg, *__a._M_a) { }
158 template<
typename _Alloc>
160 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
161 : _Head(*__a._M_a) { }
163 template<
typename _UHead>
165 _Head_base(__uses_alloc0, _UHead&& __uhead)
168 template<
typename _Alloc,
typename _UHead>
170 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
171 : _Head(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead)) { }
173 template<
typename _Alloc,
typename _UHead>
175 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
176 : _Head(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
178 static constexpr _Head&
179 _M_head(_Head_base& __b)
noexcept {
return __b; }
181 static constexpr const _Head&
182 _M_head(
const _Head_base& __b)
noexcept {
return __b; }
186 template<
size_t _Idx,
typename _Head>
187 struct _Head_base<_Idx, _Head, false>
189 constexpr _Head_base()
192 constexpr _Head_base(
const _Head& __h)
193 : _M_head_impl(__h) { }
195 constexpr _Head_base(
const _Head_base&) =
default;
196 constexpr _Head_base(_Head_base&&) =
default;
198 template<
typename _UHead>
199 constexpr _Head_base(_UHead&& __h)
203 _Head_base(allocator_arg_t, __uses_alloc0)
206 template<
typename _Alloc>
208 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
209 : _M_head_impl(allocator_arg, *__a._M_a) { }
211 template<
typename _Alloc>
213 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
214 : _M_head_impl(*__a._M_a) { }
216 template<
typename _UHead>
218 _Head_base(__uses_alloc0, _UHead&& __uhead)
219 : _M_head_impl(
std::
forward<_UHead>(__uhead)) { }
221 template<
typename _Alloc,
typename _UHead>
223 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
224 : _M_head_impl(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead))
227 template<
typename _Alloc,
typename _UHead>
229 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
230 : _M_head_impl(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
232 static constexpr _Head&
233 _M_head(_Head_base& __b)
noexcept {
return __b._M_head_impl; }
235 static constexpr const _Head&
236 _M_head(
const _Head_base& __b)
noexcept {
return __b._M_head_impl; }
249 template<
size_t _Idx,
typename... _Elements>
257 template<
size_t _Idx,
typename _Head,
typename... _Tail>
260 private _Head_base<_Idx, _Head>
262 template<size_t,
typename...>
friend struct _Tuple_impl;
265 typedef _Head_base<_Idx, _Head> _Base;
267 static constexpr _Head&
268 _M_head(
_Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
270 static constexpr const _Head&
271 _M_head(
const _Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
277 _M_tail(
const _Tuple_impl& __t)
noexcept {
return __t; }
283 _Tuple_impl(
const _Head& __head,
const _Tail&... __tail)
287 template<
typename _UHead,
typename... _UTail,
288 typename = __enable_if_t<
sizeof...(_Tail) ==
sizeof...(_UTail)>>
291 :
_Inherited(std::forward<_UTail>(__tail)...),
292 _Base(std::forward<_UHead>(__head))
303 template<
typename... _UElements>
310 template<
typename _UHead,
typename... _UTails>
315 _Base(std::forward<_UHead>
319#if __cplusplus > 202002L
320 template<
typename... _UElements>
327 template<
typename _UHead,
typename... _UTails>
332 _Base(std::forward<const _UHead>
337 template<
typename _Alloc>
339 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a)
341 _Base(__tag, __use_alloc<_Head>(__a))
344 template<
typename _Alloc>
346 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
347 const _Head& __head,
const _Tail&... __tail)
349 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head)
352 template<
typename _Alloc,
typename _UHead,
typename... _UTail,
353 typename = __enable_if_t<
sizeof...(_Tail) ==
sizeof...(_UTail)>>
355 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
356 _UHead&& __head, _UTail&&... __tail)
357 :
_Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
358 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
359 std::forward<_UHead>(__head))
362 template<
typename _Alloc>
364 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
367 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in))
370 template<
typename _Alloc>
372 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
375 _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
376 std::forward<_Head>(_M_head(__in)))
379 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
381 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
385 _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
389 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
391 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
395 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
400#if __cplusplus > 202002L
401 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
403 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
407 _Base(__use_alloc<_Head, _Alloc, _UHead&>(__a),
411 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
413 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
417 _Base(__use_alloc<_Head, _Alloc, const _UHead>(__a),
418 std::forward<const _UHead>
423 template<
typename... _UElements>
429 _M_tail(*this)._M_assign(
433 template<
typename _UHead,
typename... _UTails>
438 _M_head(*
this) = std::forward<_UHead>
440 _M_tail(*this)._M_assign(
444#if __cplusplus > 202002L
445 template<
typename... _UElements>
450 _M_tail(*this)._M_assign(
454 template<
typename _UHead,
typename... _UTails>
458 _M_head(*
this) = std::forward<_UHead>
460 _M_tail(*this)._M_assign(
471 swap(_M_head(*
this), _M_head(__in));
472 _Inherited::_M_swap(_M_tail(__in));
475#if __cplusplus > 202002L
480 swap(_M_head(*
this), _M_head(__in));
481 _Inherited::_M_swap(_M_tail(__in));
487 template<
size_t _Idx,
typename _Head>
489 :
private _Head_base<_Idx, _Head>
491 template<size_t,
typename...>
friend struct _Tuple_impl;
493 typedef _Head_base<_Idx, _Head> _Base;
495 static constexpr _Head&
496 _M_head(
_Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
498 static constexpr const _Head&
499 _M_head(
const _Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
506 _Tuple_impl(
const _Head& __head)
510 template<
typename _UHead>
512 _Tuple_impl(_UHead&& __head)
516 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
520 _Tuple_impl& operator=(
const _Tuple_impl&) =
delete;
522#if _GLIBCXX_INLINE_VERSION
523 _Tuple_impl(_Tuple_impl&&) =
default;
526 _Tuple_impl(_Tuple_impl&& __in)
527 noexcept(is_nothrow_move_constructible<_Head>::value)
528 : _Base(
static_cast<_Base&&
>(__in))
532 template<
typename _UHead>
534 _Tuple_impl(
const _Tuple_impl<_Idx, _UHead>& __in)
535 : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in))
538 template<
typename _UHead>
540 _Tuple_impl(_Tuple_impl<_Idx, _UHead>&& __in)
541 : _Base(
std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
544#if __cplusplus > 202002L
545 template<
typename _UHead>
547 _Tuple_impl(_Tuple_impl<_Idx, _UHead>& __in)
548 : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in))
551 template<
typename _UHead>
553 _Tuple_impl(
const _Tuple_impl<_Idx, _UHead>&& __in)
554 : _Base(
std::
forward<const _UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
558 template<
typename _Alloc>
560 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a)
561 : _Base(__tag, __use_alloc<_Head>(__a))
564 template<
typename _Alloc>
566 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
568 : _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), __head)
571 template<
typename _Alloc,
typename _UHead>
573 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
575 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
579 template<
typename _Alloc>
581 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
582 const _Tuple_impl& __in)
583 : _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), _M_head(__in))
586 template<
typename _Alloc>
588 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
590 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
594 template<
typename _Alloc,
typename _UHead>
596 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
597 const _Tuple_impl<_Idx, _UHead>& __in)
598 : _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
599 _Tuple_impl<_Idx, _UHead>::_M_head(__in))
602 template<
typename _Alloc,
typename _UHead>
604 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
605 _Tuple_impl<_Idx, _UHead>&& __in)
606 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
607 std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
610#if __cplusplus > 202002L
611 template<
typename _Alloc,
typename _UHead>
613 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
614 _Tuple_impl<_Idx, _UHead>& __in)
615 : _Base(__use_alloc<_Head, _Alloc, _UHead&>(__a),
616 _Tuple_impl<_Idx, _UHead>::_M_head(__in))
619 template<
typename _Alloc,
typename _UHead>
621 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
622 const _Tuple_impl<_Idx, _UHead>&& __in)
623 : _Base(__use_alloc<_Head, _Alloc, const _UHead>(__a),
624 std::
forward<const _UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
628 template<
typename _UHead>
631 _M_assign(
const _Tuple_impl<_Idx, _UHead>& __in)
633 _M_head(*
this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in);
636 template<
typename _UHead>
639 _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
642 = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
645#if __cplusplus > 202002L
646 template<
typename _UHead>
648 _M_assign(
const _Tuple_impl<_Idx, _UHead>& __in)
const
650 _M_head(*
this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in);
653 template<
typename _UHead>
655 _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
const
658 = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
665 _M_swap(_Tuple_impl& __in)
668 swap(_M_head(*
this), _M_head(__in));
671#if __cplusplus > 202002L
673 _M_swap(
const _Tuple_impl& __in)
const
676 swap(_M_head(*
this), _M_head(__in));
683 template<bool,
typename... _Types>
684 struct _TupleConstraints
686 template<
typename... _UTypes>
687 using __constructible = __and_<is_constructible<_Types, _UTypes>...>;
689 template<
typename... _UTypes>
690 using __convertible = __and_<is_convertible<_UTypes, _Types>...>;
695 template<
typename... _UTypes>
696 static constexpr bool __is_implicitly_constructible()
698 return __and_<__constructible<_UTypes...>,
699 __convertible<_UTypes...>
706 template<
typename... _UTypes>
707 static constexpr bool __is_explicitly_constructible()
709 return __and_<__constructible<_UTypes...>,
710 __not_<__convertible<_UTypes...>>
714 static constexpr bool __is_implicitly_default_constructible()
716 return __and_<std::__is_implicitly_default_constructible<_Types>...
720 static constexpr bool __is_explicitly_default_constructible()
722 return __and_<is_default_constructible<_Types>...,
724 std::__is_implicitly_default_constructible<_Types>...>
731 template<
typename... _Types>
732 struct _TupleConstraints<false, _Types...>
734 template<
typename... _UTypes>
735 static constexpr bool __is_implicitly_constructible()
738 template<
typename... _UTypes>
739 static constexpr bool __is_explicitly_constructible()
744 template<
typename... _Elements>
750 using _TCC = _TupleConstraints<_Cond, _Elements...>;
753 template<
bool _Dummy>
754 using _ImplicitDefaultCtor = __enable_if_t<
755 _TCC<_Dummy>::__is_implicitly_default_constructible(),
759 template<
bool _Dummy>
760 using _ExplicitDefaultCtor = __enable_if_t<
761 _TCC<_Dummy>::__is_explicitly_default_constructible(),
765 template<
bool _Cond,
typename... _Args>
766 using _ImplicitCtor = __enable_if_t<
767 _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(),
771 template<
bool _Cond,
typename... _Args>
772 using _ExplicitCtor = __enable_if_t<
773 _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(),
776 template<
typename... _UElements>
778 __enable_if_t<
sizeof...(_UElements) ==
sizeof...(_Elements),
bool>
780 {
return __and_<is_assignable<_Elements&, _UElements>...>::value; }
783 template<
typename... _UElements>
784 static constexpr bool __nothrow_assignable()
787 __and_<is_nothrow_assignable<_Elements&, _UElements>...>::value;
791 template<
typename... _UElements>
792 static constexpr bool __nothrow_constructible()
795 __and_<is_nothrow_constructible<_Elements, _UElements>...>::value;
799 template<
typename _Up>
800 static constexpr bool __valid_args()
802 return sizeof...(_Elements) == 1
807 template<
typename,
typename,
typename... _Tail>
808 static constexpr bool __valid_args()
809 {
return (
sizeof...(_Tail) + 2) ==
sizeof...(_Elements); }
820 template<
typename _Tuple,
typename =
tuple,
821 typename = __remove_cvref_t<_Tuple>>
827 template<
typename _Tuple,
typename _Tp,
typename _Up>
828 struct _UseOtherCtor<_Tuple,
tuple<_Tp>,
tuple<_Up>>
829 : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>::type
833 template<
typename _Tuple,
typename _Tp>
834 struct _UseOtherCtor<_Tuple,
tuple<_Tp>,
tuple<_Tp>>
841 template<
typename _Tuple>
842 static constexpr bool __use_other_ctor()
843 {
return _UseOtherCtor<_Tuple>::value; }
845#if __cplusplus > 202002L
846 template<
typename... _Args>
847 static constexpr bool __constructible
848 = _TCC<true>::template __constructible<_Args...>::value;
850 template<
typename... _Args>
851 static constexpr bool __convertible
852 = _TCC<true>::template __convertible<_Args...>::value;
856 template<
typename _Dummy = void,
857 _ImplicitDefaultCtor<is_void<_Dummy>::value> =
true>
860 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
863 template<
typename _Dummy = void,
864 _ExplicitDefaultCtor<is_void<_Dummy>::value> =
false>
867 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
870 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
871 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
873 tuple(
const _Elements&... __elements)
874 noexcept(__nothrow_constructible<
const _Elements&...>())
877 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
878 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
880 tuple(
const _Elements&... __elements)
881 noexcept(__nothrow_constructible<
const _Elements&...>())
884 template<
typename... _UElements,
885 bool _Valid = __valid_args<_UElements...>(),
886 _ImplicitCtor<_Valid, _UElements...> =
true>
888 tuple(_UElements&&... __elements)
889 noexcept(__nothrow_constructible<_UElements...>())
890 :
_Inherited(std::forward<_UElements>(__elements)...) { }
892 template<
typename... _UElements,
893 bool _Valid = __valid_args<_UElements...>(),
894 _ExplicitCtor<_Valid, _UElements...> =
false>
896 tuple(_UElements&&... __elements)
897 noexcept(__nothrow_constructible<_UElements...>())
898 :
_Inherited(std::forward<_UElements>(__elements)...) { }
904 template<
typename... _UElements,
905 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
907 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
910 noexcept(__nothrow_constructible<
const _UElements&...>())
914 template<
typename... _UElements,
915 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
917 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
920 noexcept(__nothrow_constructible<
const _UElements&...>())
924 template<
typename... _UElements,
925 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
927 _ImplicitCtor<_Valid, _UElements...> =
true>
930 noexcept(__nothrow_constructible<_UElements...>())
933 template<
typename... _UElements,
934 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
936 _ExplicitCtor<_Valid, _UElements...> =
false>
939 noexcept(__nothrow_constructible<_UElements...>())
942#if __cplusplus > 202002L
943 template<
typename... _UElements>
944 requires (
sizeof...(_Elements) ==
sizeof...(_UElements))
946 && __constructible<_UElements&...>
947 explicit(!__convertible<_UElements&...>)
950 noexcept(__nothrow_constructible<_UElements&...>())
954 template<
typename... _UElements>
955 requires (
sizeof...(_Elements) ==
sizeof...(_UElements))
957 && __constructible<const _UElements...>
958 explicit(!__convertible<const _UElements...>)
961 noexcept(__nothrow_constructible<
const _UElements...>())
967 template<
typename _Alloc,
968 _ImplicitDefaultCtor<is_object<_Alloc>::value> =
true>
970 tuple(allocator_arg_t __tag,
const _Alloc& __a)
973 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
974 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
976 tuple(allocator_arg_t __tag,
const _Alloc& __a,
977 const _Elements&... __elements)
980 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
981 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
984 tuple(allocator_arg_t __tag,
const _Alloc& __a,
985 const _Elements&... __elements)
988 template<
typename _Alloc,
typename... _UElements,
989 bool _Valid = __valid_args<_UElements...>(),
990 _ImplicitCtor<_Valid, _UElements...> =
true>
992 tuple(allocator_arg_t __tag,
const _Alloc& __a,
993 _UElements&&... __elements)
994 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
997 template<
typename _Alloc,
typename... _UElements,
998 bool _Valid = __valid_args<_UElements...>(),
999 _ExplicitCtor<_Valid, _UElements...> =
false>
1000 _GLIBCXX20_CONSTEXPR
1002 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1003 _UElements&&... __elements)
1004 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
1007 template<
typename _Alloc>
1008 _GLIBCXX20_CONSTEXPR
1009 tuple(allocator_arg_t __tag,
const _Alloc& __a,
const tuple& __in)
1012 template<
typename _Alloc>
1013 _GLIBCXX20_CONSTEXPR
1014 tuple(allocator_arg_t __tag,
const _Alloc& __a,
tuple&& __in)
1017 template<
typename _Alloc,
typename... _UElements,
1018 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1020 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
1021 _GLIBCXX20_CONSTEXPR
1022 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1025 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
1028 template<
typename _Alloc,
typename... _UElements,
1029 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1031 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
1032 _GLIBCXX20_CONSTEXPR
1034 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1037 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
1040 template<
typename _Alloc,
typename... _UElements,
1041 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1043 _ImplicitCtor<_Valid, _UElements...> =
true>
1044 _GLIBCXX20_CONSTEXPR
1045 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1048 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
1051 template<
typename _Alloc,
typename... _UElements,
1052 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1054 _ExplicitCtor<_Valid, _UElements...> =
false>
1055 _GLIBCXX20_CONSTEXPR
1057 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1060 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
1063#if __cplusplus > 202002L
1064 template<
typename _Alloc,
typename... _UElements>
1065 requires (
sizeof...(_Elements) ==
sizeof...(_UElements))
1067 && __constructible<_UElements&...>
1068 explicit(!__convertible<_UElements&...>)
1070 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1073 static_cast<_Tuple_impl<0, _UElements...
>&>(__in))
1076 template<
typename _Alloc,
typename... _UElements>
1077 requires (
sizeof...(_Elements) ==
sizeof...(_UElements))
1079 && __constructible<const _UElements...>
1080 explicit(!__convertible<const _UElements...>)
1082 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1085 static_cast<const _Tuple_impl<0, _UElements...
>&&>(__in))
1091 _GLIBCXX20_CONSTEXPR
1093 operator=(__conditional_t<__assignable<const _Elements&...>(),
1095 const __nonesuch&> __in)
1096 noexcept(__nothrow_assignable<
const _Elements&...>())
1098 this->_M_assign(__in);
1102 _GLIBCXX20_CONSTEXPR
1104 operator=(__conditional_t<__assignable<_Elements...>(),
1107 noexcept(__nothrow_assignable<_Elements...>())
1113 template<
typename... _UElements>
1114 _GLIBCXX20_CONSTEXPR
1115 __enable_if_t<__assignable<
const _UElements&...>(),
tuple&>
1117 noexcept(__nothrow_assignable<
const _UElements&...>())
1119 this->_M_assign(__in);
1123 template<
typename... _UElements>
1124 _GLIBCXX20_CONSTEXPR
1125 __enable_if_t<__assignable<_UElements...>(),
tuple&>
1127 noexcept(__nothrow_assignable<_UElements...>())
1133#if __cplusplus > 202002L
1134 constexpr const tuple&
1135 operator=(
const tuple& __in)
const
1136 requires (is_copy_assignable_v<const _Elements> && ...)
1138 this->_M_assign(__in);
1142 constexpr const tuple&
1143 operator=(
tuple&& __in)
const
1144 requires (is_assignable_v<const _Elements&, _Elements> && ...)
1150 template<
typename... _UElements>
1151 constexpr const tuple&
1153 requires (
sizeof...(_Elements) ==
sizeof...(_UElements))
1154 && (is_assignable_v<const _Elements&, const _UElements&> && ...)
1156 this->_M_assign(__in);
1160 template<
typename... _UElements>
1161 constexpr const tuple&
1163 requires (
sizeof...(_Elements) ==
sizeof...(_UElements))
1164 && (is_assignable_v<const _Elements&, _UElements> && ...)
1172 _GLIBCXX20_CONSTEXPR
1175 noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value)
1176 { _Inherited::_M_swap(__in); }
1178#if __cplusplus > 202002L
1186 swap(
const tuple& __in)
const
1187 noexcept(__and_v<__is_nothrow_swappable<const _Elements>...>)
1188 requires (is_swappable_v<const _Elements> && ...)
1189 { _Inherited::_M_swap(__in); }
1193#if __cpp_deduction_guides >= 201606
1194 template<
typename... _UTypes>
1196 template<
typename _T1,
typename _T2>
1198 template<
typename _Alloc,
typename... _UTypes>
1199 tuple(allocator_arg_t, _Alloc, _UTypes...) ->
tuple<_UTypes...>;
1200 template<
typename _Alloc,
typename _T1,
typename _T2>
1202 template<
typename _Alloc,
typename... _UTypes>
1211 _GLIBCXX20_CONSTEXPR
1212 void swap(
tuple&)
noexcept { }
1213#if __cplusplus > 202002L
1214 constexpr void swap(
const tuple&)
const noexcept { }
1220 template<
typename _Alloc>
1221 _GLIBCXX20_CONSTEXPR
1222 tuple(allocator_arg_t,
const _Alloc&)
noexcept { }
1223 template<
typename _Alloc>
1224 _GLIBCXX20_CONSTEXPR
1225 tuple(allocator_arg_t,
const _Alloc&,
const tuple&)
noexcept { }
1230 template<
typename _T1,
typename _T2>
1236 template<
bool _Dummy,
typename _U1,
typename _U2>
1237 using _ImplicitDefaultCtor = __enable_if_t<
1238 _TupleConstraints<_Dummy, _U1, _U2>::
1239 __is_implicitly_default_constructible(),
1243 template<
bool _Dummy,
typename _U1,
typename _U2>
1244 using _ExplicitDefaultCtor = __enable_if_t<
1245 _TupleConstraints<_Dummy, _U1, _U2>::
1246 __is_explicitly_default_constructible(),
1249 template<
bool _Dummy>
1250 using _TCC = _TupleConstraints<_Dummy, _T1, _T2>;
1253 template<
bool _Cond,
typename _U1,
typename _U2>
1254 using _ImplicitCtor = __enable_if_t<
1255 _TCC<_Cond>::template __is_implicitly_constructible<_U1, _U2>(),
1259 template<
bool _Cond,
typename _U1,
typename _U2>
1260 using _ExplicitCtor = __enable_if_t<
1261 _TCC<_Cond>::template __is_explicitly_constructible<_U1, _U2>(),
1264 template<
typename _U1,
typename _U2>
1265 static constexpr bool __assignable()
1267 return __and_<is_assignable<_T1&, _U1>,
1271 template<
typename _U1,
typename _U2>
1272 static constexpr bool __nothrow_assignable()
1274 return __and_<is_nothrow_assignable<_T1&, _U1>,
1278 template<
typename _U1,
typename _U2>
1279 static constexpr bool __nothrow_constructible()
1281 return __and_<is_nothrow_constructible<_T1, _U1>,
1285 static constexpr bool __nothrow_default_constructible()
1287 return __and_<is_nothrow_default_constructible<_T1>,
1291 template<
typename _U1>
1292 static constexpr bool __is_alloc_arg()
1295#if __cplusplus > 202002L
1296 template<
typename _U1,
typename _U2>
1297 static constexpr bool __constructible
1298 = _TCC<true>::template __constructible<_U1, _U2>::value;
1300 template<
typename _U1,
typename _U2>
1301 static constexpr bool __convertible
1302 = _TCC<true>::template __convertible<_U1, _U2>::value;
1306 template<
bool _Dummy =
true,
1307 _ImplicitDefaultCtor<_Dummy, _T1, _T2> =
true>
1310 noexcept(__nothrow_default_constructible())
1313 template<
bool _Dummy =
true,
1314 _ExplicitDefaultCtor<_Dummy, _T1, _T2> =
false>
1317 noexcept(__nothrow_default_constructible())
1320 template<
bool _Dummy =
true,
1321 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1323 tuple(
const _T1& __a1,
const _T2& __a2)
1324 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
1327 template<
bool _Dummy =
true,
1328 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1330 tuple(
const _T1& __a1,
const _T2& __a2)
1331 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
1334 template<
typename _U1,
typename _U2,
1335 _ImplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
true>
1337 tuple(_U1&& __a1, _U2&& __a2)
1338 noexcept(__nothrow_constructible<_U1, _U2>())
1339 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
1341 template<
typename _U1,
typename _U2,
1342 _ExplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
false>
1344 tuple(_U1&& __a1, _U2&& __a2)
1345 noexcept(__nothrow_constructible<_U1, _U2>())
1346 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
1352 template<
typename _U1,
typename _U2,
1353 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1356 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1359 template<
typename _U1,
typename _U2,
1360 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1363 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1366 template<
typename _U1,
typename _U2,
1367 _ImplicitCtor<true, _U1, _U2> =
true>
1370 noexcept(__nothrow_constructible<_U1, _U2>())
1373 template<
typename _U1,
typename _U2,
1374 _ExplicitCtor<true, _U1, _U2> =
false>
1377 noexcept(__nothrow_constructible<_U1, _U2>())
1380#if __cplusplus > 202002L
1381 template<
typename _U1,
typename _U2>
1382 requires __constructible<_U1&, _U2&>
1383 explicit(!__convertible<_U1&, _U2&>)
1386 noexcept(__nothrow_constructible<_U1&, _U2&>())
1389 template<
typename _U1,
typename _U2>
1390 requires __constructible<const _U1, const _U2>
1391 explicit(!__convertible<const _U1, const _U2>)
1394 noexcept(__nothrow_constructible<const _U1, const _U2>())
1398 template<
typename _U1,
typename _U2,
1399 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1402 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1405 template<
typename _U1,
typename _U2,
1406 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1409 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1412 template<
typename _U1,
typename _U2,
1413 _ImplicitCtor<true, _U1, _U2> =
true>
1416 noexcept(__nothrow_constructible<_U1, _U2>())
1418 std::forward<_U2>(__in.second)) { }
1420 template<
typename _U1,
typename _U2,
1421 _ExplicitCtor<true, _U1, _U2> =
false>
1424 noexcept(__nothrow_constructible<_U1, _U2>())
1426 std::forward<_U2>(__in.second)) { }
1428#if __cplusplus > 202002L
1429 template<
typename _U1,
typename _U2>
1430 requires __constructible<_U1&, _U2&>
1431 explicit(!__convertible<_U1&, _U2&>)
1434 noexcept(__nothrow_constructible<_U1&, _U2&>())
1437 template<
typename _U1,
typename _U2>
1438 requires __constructible<const _U1, const _U2>
1439 explicit(!__convertible<const _U1, const _U2>)
1442 noexcept(__nothrow_constructible<const _U1, const _U2>())
1443 :
_Inherited(std::forward<const _U1>(__in.first),
1444 std::forward<const _U2>(__in.second)) { }
1449 template<
typename _Alloc,
1450 _ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> =
true>
1451 _GLIBCXX20_CONSTEXPR
1452 tuple(allocator_arg_t __tag,
const _Alloc& __a)
1455 template<
typename _Alloc,
bool _Dummy =
true,
1456 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1457 _GLIBCXX20_CONSTEXPR
1458 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1459 const _T1& __a1,
const _T2& __a2)
1462 template<
typename _Alloc,
bool _Dummy =
true,
1463 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1465 _GLIBCXX20_CONSTEXPR
1466 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1467 const _T1& __a1,
const _T2& __a2)
1470 template<
typename _Alloc,
typename _U1,
typename _U2,
1471 _ImplicitCtor<true, _U1, _U2> =
true>
1472 _GLIBCXX20_CONSTEXPR
1473 tuple(allocator_arg_t __tag,
const _Alloc& __a, _U1&& __a1, _U2&& __a2)
1474 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1475 std::forward<_U2>(__a2)) { }
1477 template<
typename _Alloc,
typename _U1,
typename _U2,
1478 _ExplicitCtor<true, _U1, _U2> =
false>
1480 _GLIBCXX20_CONSTEXPR
1481 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1482 _U1&& __a1, _U2&& __a2)
1483 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1484 std::forward<_U2>(__a2)) { }
1486 template<
typename _Alloc>
1487 _GLIBCXX20_CONSTEXPR
1488 tuple(allocator_arg_t __tag,
const _Alloc& __a,
const tuple& __in)
1491 template<
typename _Alloc>
1492 _GLIBCXX20_CONSTEXPR
1493 tuple(allocator_arg_t __tag,
const _Alloc& __a,
tuple&& __in)
1496 template<
typename _Alloc,
typename _U1,
typename _U2,
1497 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1498 _GLIBCXX20_CONSTEXPR
1499 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1505 template<
typename _Alloc,
typename _U1,
typename _U2,
1506 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1508 _GLIBCXX20_CONSTEXPR
1509 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1515 template<
typename _Alloc,
typename _U1,
typename _U2,
1516 _ImplicitCtor<true, _U1, _U2> =
true>
1517 _GLIBCXX20_CONSTEXPR
1522 template<
typename _Alloc,
typename _U1,
typename _U2,
1523 _ExplicitCtor<true, _U1, _U2> =
false>
1525 _GLIBCXX20_CONSTEXPR
1530#if __cplusplus > 202002L
1531 template<
typename _Alloc,
typename _U1,
typename _U2>
1532 requires __constructible<_U1&, _U2&>
1533 explicit(!__convertible<_U1&, _U2&>)
1535 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1541 template<
typename _Alloc,
typename _U1,
typename _U2>
1542 requires __constructible<const _U1, const _U2>
1543 explicit(!__convertible<const _U1, const _U2>)
1545 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1552 template<
typename _Alloc,
typename _U1,
typename _U2,
1553 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1554 _GLIBCXX20_CONSTEXPR
1555 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1557 :
_Inherited(__tag, __a, __in.first, __in.second) { }
1559 template<
typename _Alloc,
typename _U1,
typename _U2,
1560 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1562 _GLIBCXX20_CONSTEXPR
1563 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1565 :
_Inherited(__tag, __a, __in.first, __in.second) { }
1567 template<
typename _Alloc,
typename _U1,
typename _U2,
1568 _ImplicitCtor<true, _U1, _U2> =
true>
1569 _GLIBCXX20_CONSTEXPR
1571 :
_Inherited(__tag, __a, std::forward<_U1>(__in.first),
1572 std::forward<_U2>(__in.second)) { }
1574 template<
typename _Alloc,
typename _U1,
typename _U2,
1575 _ExplicitCtor<true, _U1, _U2> =
false>
1577 _GLIBCXX20_CONSTEXPR
1579 :
_Inherited(__tag, __a, std::forward<_U1>(__in.first),
1580 std::forward<_U2>(__in.second)) { }
1582#if __cplusplus > 202002L
1583 template<
typename _Alloc,
typename _U1,
typename _U2>
1584 requires __constructible<_U1&, _U2&>
1585 explicit(!__convertible<_U1&, _U2&>)
1587 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1589 :
_Inherited(__tag, __a, __in.first, __in.second) { }
1591 template<
typename _Alloc,
typename _U1,
typename _U2>
1592 requires __constructible<const _U1, const _U2>
1593 explicit(!__convertible<const _U1, const _U2>)
1596 :
_Inherited(__tag, __a, std::forward<const _U1>(__in.first),
1597 std::forward<const _U2>(__in.second)) { }
1602 _GLIBCXX20_CONSTEXPR
1604 operator=(__conditional_t<__assignable<const _T1&, const _T2&>(),
1606 const __nonesuch&> __in)
1607 noexcept(__nothrow_assignable<const _T1&, const _T2&>())
1609 this->_M_assign(__in);
1613 _GLIBCXX20_CONSTEXPR
1615 operator=(__conditional_t<__assignable<_T1, _T2>(),
1618 noexcept(__nothrow_assignable<_T1, _T2>())
1624 template<
typename _U1,
typename _U2>
1625 _GLIBCXX20_CONSTEXPR
1626 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
1628 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1630 this->_M_assign(__in);
1634 template<
typename _U1,
typename _U2>
1635 _GLIBCXX20_CONSTEXPR
1636 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
1638 noexcept(__nothrow_assignable<_U1, _U2>())
1644#if __cplusplus > 202002L
1645 constexpr const tuple&
1646 operator=(
const tuple& __in)
const
1647 requires is_copy_assignable_v<const _T1> && is_copy_assignable_v<const _T2>
1649 this->_M_assign(__in);
1653 constexpr const tuple&
1654 operator=(
tuple&& __in)
const
1655 requires is_assignable_v<const _T1&, _T1> && is_assignable_v<const _T2, _T2>
1661 template<
typename _U1,
typename _U2>
1662 constexpr const tuple&
1664 requires is_assignable_v<const _T1&, const _U1&>
1665 && is_assignable_v<const _T2&, const _U2&>
1667 this->_M_assign(__in);
1671 template<
typename _U1,
typename _U2>
1672 constexpr const tuple&
1674 requires is_assignable_v<const _T1&, _U1>
1675 && is_assignable_v<const _T2&, _U2>
1682 template<
typename _U1,
typename _U2>
1683 _GLIBCXX20_CONSTEXPR
1684 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
1686 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1688 this->_M_head(*
this) = __in.first;
1689 this->_M_tail(*this)._M_head(*
this) = __in.second;
1693 template<
typename _U1,
typename _U2>
1694 _GLIBCXX20_CONSTEXPR
1695 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
1697 noexcept(__nothrow_assignable<_U1, _U2>())
1699 this->_M_head(*
this) = std::forward<_U1>(__in.first);
1700 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.second);
1704#if __cplusplus > 202002L
1705 template<
typename _U1,
typename _U2>
1706 constexpr const tuple&
1708 requires is_assignable_v<const _T1&, const _U1&>
1709 && is_assignable_v<const _T2&, const _U2&>
1711 this->_M_head(*
this) = __in.first;
1712 this->_M_tail(*this)._M_head(*
this) = __in.second;
1716 template<
typename _U1,
typename _U2>
1717 constexpr const tuple&
1719 requires is_assignable_v<const _T1&, _U1>
1720 && is_assignable_v<const _T2&, _U2>
1722 this->_M_head(*
this) = std::forward<_U1>(__in.first);
1723 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.second);
1728 _GLIBCXX20_CONSTEXPR
1731 noexcept(__and_<__is_nothrow_swappable<_T1>,
1732 __is_nothrow_swappable<_T2>>::value)
1733 { _Inherited::_M_swap(__in); }
1735#if __cplusplus > 202002L
1737 swap(
const tuple& __in)
const
1738 noexcept(__and_v<__is_nothrow_swappable<const _T1>,
1739 __is_nothrow_swappable<const _T2>>)
1740 requires is_swappable_v<const _T1> && is_swappable_v<const _T2>
1741 { _Inherited::_M_swap(__in); }
1747 template<
typename... _Elements>
1751#if __cplusplus >= 201703L
1752 template<
typename... _Types>
1753 inline constexpr size_t tuple_size_v<
tuple<_Types...>>
1754 =
sizeof...(_Types);
1756 template<
typename... _Types>
1757 inline constexpr size_t tuple_size_v<
const tuple<_Types...>>
1758 =
sizeof...(_Types);
1762 template<
size_t __i,
typename... _Types>
1765 static_assert(__i <
sizeof...(_Types),
"tuple index must be in range");
1767 using type =
typename _Nth_type<__i, _Types...>::type;
1770 template<
size_t __i,
typename _Head,
typename... _Tail>
1775 template<
size_t __i,
typename _Head,
typename... _Tail>
1776 constexpr const _Head&
1777 __get_helper(
const _Tuple_impl<__i, _Head, _Tail...>& __t)
noexcept
1778 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1781 template<
size_t __i,
typename... _Types>
1782 __enable_if_t<(__i >=
sizeof...(_Types))>
1783 __get_helper(
const tuple<_Types...>&) =
delete;
1786 template<
size_t __i,
typename... _Elements>
1787 constexpr __tuple_element_t<__i, tuple<_Elements...>>&
1789 {
return std::__get_helper<__i>(__t); }
1792 template<
size_t __i,
typename... _Elements>
1793 constexpr const __tuple_element_t<__i, tuple<_Elements...>>&
1795 {
return std::__get_helper<__i>(__t); }
1798 template<
size_t __i,
typename... _Elements>
1799 constexpr __tuple_element_t<__i, tuple<_Elements...>>&&
1802 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1803 return std::forward<__element_type>(std::__get_helper<__i>(__t));
1807 template<
size_t __i,
typename... _Elements>
1808 constexpr const __tuple_element_t<__i, tuple<_Elements...>>&&
1811 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1812 return std::forward<const __element_type>(std::__get_helper<__i>(__t));
1817 template<
size_t __i,
typename... _Elements>
1818 constexpr __enable_if_t<(__i >=
sizeof...(_Elements))>
1819 get(
const tuple<_Elements...>&) =
delete;
1822#if __cplusplus >= 201402L
1824#define __cpp_lib_tuples_by_type 201304L
1827 template <
typename _Tp,
typename... _Types>
1831 constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1832 static_assert(__idx <
sizeof...(_Types),
1833 "the type T in std::get<T> must occur exactly once in the tuple");
1834 return std::__get_helper<__idx>(__t);
1838 template <
typename _Tp,
typename... _Types>
1842 constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1843 static_assert(__idx <
sizeof...(_Types),
1844 "the type T in std::get<T> must occur exactly once in the tuple");
1845 return std::forward<_Tp>(std::__get_helper<__idx>(__t));
1849 template <
typename _Tp,
typename... _Types>
1850 constexpr const _Tp&
1853 constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1854 static_assert(__idx <
sizeof...(_Types),
1855 "the type T in std::get<T> must occur exactly once in the tuple");
1856 return std::__get_helper<__idx>(__t);
1861 template <
typename _Tp,
typename... _Types>
1862 constexpr const _Tp&&
1865 constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1866 static_assert(__idx <
sizeof...(_Types),
1867 "the type T in std::get<T> must occur exactly once in the tuple");
1868 return std::forward<const _Tp>(std::__get_helper<__idx>(__t));
1873 template<
typename _Tp,
typename _Up,
size_t __i,
size_t __size>
1874 struct __tuple_compare
1876 static constexpr bool
1877 __eq(
const _Tp& __t,
const _Up& __u)
1879 return bool(std::get<__i>(__t) == std::get<__i>(__u))
1880 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u);
1883 static constexpr bool
1884 __less(
const _Tp& __t,
const _Up& __u)
1886 return bool(std::get<__i>(__t) < std::get<__i>(__u))
1887 || (!bool(std::get<__i>(__u) < std::get<__i>(__t))
1888 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u));
1892 template<
typename _Tp,
typename _Up,
size_t __size>
1893 struct __tuple_compare<_Tp, _Up, __size, __size>
1895 static constexpr bool
1896 __eq(
const _Tp&,
const _Up&) {
return true; }
1898 static constexpr bool
1899 __less(
const _Tp&,
const _Up&) {
return false; }
1902 template<
typename... _TElements,
typename... _UElements>
1904 operator==(
const tuple<_TElements...>& __t,
1905 const tuple<_UElements...>& __u)
1907 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1908 "tuple objects can only be compared if they have equal sizes.");
1909 using __compare = __tuple_compare<tuple<_TElements...>,
1910 tuple<_UElements...>,
1911 0,
sizeof...(_TElements)>;
1912 return __compare::__eq(__t, __u);
1915#if __cpp_lib_three_way_comparison
1916 template<
typename _Cat,
typename _Tp,
typename _Up>
1918 __tuple_cmp(
const _Tp&,
const _Up&, index_sequence<>)
1919 {
return _Cat::equivalent; }
1921 template<
typename _Cat,
typename _Tp,
typename _Up,
1922 size_t _Idx0,
size_t... _Idxs>
1924 __tuple_cmp(
const _Tp& __t,
const _Up& __u,
1925 index_sequence<_Idx0, _Idxs...>)
1928 = __detail::__synth3way(std::get<_Idx0>(__t), std::get<_Idx0>(__u));
1931 return std::__tuple_cmp<_Cat>(__t, __u, index_sequence<_Idxs...>());
1934 template<
typename... _Tps,
typename... _Ups>
1936 common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>
1937 operator<=>(
const tuple<_Tps...>& __t,
const tuple<_Ups...>& __u)
1940 = common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>;
1941 return std::__tuple_cmp<_Cat>(__t, __u, index_sequence_for<_Tps...>());
1944 template<
typename... _TElements,
typename... _UElements>
1946 operator<(
const tuple<_TElements...>& __t,
1947 const tuple<_UElements...>& __u)
1949 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1950 "tuple objects can only be compared if they have equal sizes.");
1951 using __compare = __tuple_compare<tuple<_TElements...>,
1952 tuple<_UElements...>,
1953 0,
sizeof...(_TElements)>;
1954 return __compare::__less(__t, __u);
1957 template<
typename... _TElements,
typename... _UElements>
1959 operator!=(
const tuple<_TElements...>& __t,
1960 const tuple<_UElements...>& __u)
1961 {
return !(__t == __u); }
1963 template<
typename... _TElements,
typename... _UElements>
1965 operator>(
const tuple<_TElements...>& __t,
1966 const tuple<_UElements...>& __u)
1967 {
return __u < __t; }
1969 template<
typename... _TElements,
typename... _UElements>
1971 operator<=(
const tuple<_TElements...>& __t,
1972 const tuple<_UElements...>& __u)
1973 {
return !(__u < __t); }
1975 template<
typename... _TElements,
typename... _UElements>
1977 operator>=(
const tuple<_TElements...>& __t,
1978 const tuple<_UElements...>& __u)
1979 {
return !(__t < __u); }
1983 template<
typename... _Elements>
1984 constexpr tuple<typename __decay_and_strip<_Elements>::__type...>
1985 make_tuple(_Elements&&... __args)
1987 typedef tuple<typename __decay_and_strip<_Elements>::__type...>
1989 return __result_type(std::forward<_Elements>(__args)...);
1995 template<
typename... _Elements>
1996 constexpr tuple<_Elements&&...>
1998 {
return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
2003 template<
typename _Tp,
size_t _Nm>
struct array;
2005 template<
size_t _Int,
typename _Tp,
size_t _Nm>
2007 get(array<_Tp, _Nm>&)
noexcept;
2009 template<
size_t _Int,
typename _Tp,
size_t _Nm>
2011 get(array<_Tp, _Nm>&&) noexcept;
2013 template<
size_t _Int, typename _Tp,
size_t _Nm>
2014 constexpr const _Tp&
2015 get(const array<_Tp, _Nm>&) noexcept;
2017 template<
size_t _Int, typename _Tp,
size_t _Nm>
2018 constexpr const _Tp&&
2019 get(const array<_Tp, _Nm>&&) noexcept;
2022 template<
size_t, typename, typename,
size_t>
2023 struct __make_tuple_impl;
2025 template<
size_t _Idx, typename _Tuple, typename... _Tp,
size_t _Nm>
2026 struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
2027 : __make_tuple_impl<_Idx + 1,
2028 tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
2032 template<
size_t _Nm,
typename _Tuple,
typename... _Tp>
2033 struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
2035 typedef tuple<_Tp...> __type;
2038 template<
typename _Tuple>
2039 struct __do_make_tuple
2040 : __make_tuple_impl<0, tuple<>, _Tuple, tuple_size<_Tuple>::value>
2044 template<
typename _Tuple>
2046 :
public __do_make_tuple<__remove_cvref_t<_Tuple>>
2050 template<
typename...>
2051 struct __combine_tuples;
2054 struct __combine_tuples<>
2056 typedef tuple<> __type;
2059 template<
typename... _Ts>
2060 struct __combine_tuples<tuple<_Ts...>>
2062 typedef tuple<_Ts...> __type;
2065 template<
typename... _T1s,
typename... _T2s,
typename... _Rem>
2066 struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
2068 typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
2069 _Rem...>::__type __type;
2073 template<
typename... _Tpls>
2074 struct __tuple_cat_result
2076 typedef typename __combine_tuples
2077 <
typename __make_tuple<_Tpls>::__type...>::__type __type;
2082 template<
typename...>
2083 struct __make_1st_indices;
2086 struct __make_1st_indices<>
2088 typedef _Index_tuple<> __type;
2091 template<
typename _Tp,
typename... _Tpls>
2092 struct __make_1st_indices<_Tp, _Tpls...>
2094 typedef typename _Build_index_tuple<tuple_size<
2095 typename remove_reference<_Tp>::type>::value>::__type __type;
2101 template<
typename _Ret,
typename _Indices,
typename... _Tpls>
2102 struct __tuple_concater;
2104 template<
typename _Ret,
size_t... _Is,
typename _Tp,
typename... _Tpls>
2105 struct __tuple_concater<_Ret, _Index_tuple<_Is...>, _Tp, _Tpls...>
2107 template<
typename... _Us>
2108 static constexpr _Ret
2109 _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
2111 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
2112 typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
2113 return __next::_S_do(std::forward<_Tpls>(__tps)...,
2114 std::forward<_Us>(__us)...,
2115 std::get<_Is>(std::forward<_Tp>(__tp))...);
2119 template<
typename _Ret>
2120 struct __tuple_concater<_Ret, _Index_tuple<>>
2122 template<
typename... _Us>
2123 static constexpr _Ret
2124 _S_do(_Us&&... __us)
2126 return _Ret(std::forward<_Us>(__us)...);
2130 template<
typename... _Tps>
2131 struct __is_tuple_like_impl<tuple<_Tps...>> :
true_type
2135 template<
typename... _Tpls,
typename =
typename
2136 enable_if<__and_<__is_tuple_like<_Tpls>...>::value>::type>
2139 ->
typename __tuple_cat_result<_Tpls...>::__type
2141 typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
2142 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
2143 typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
2144 return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
2150 template<
typename... _Elements>
2151 constexpr tuple<_Elements&...>
2152 tie(_Elements&... __args)
noexcept
2153 {
return tuple<_Elements&...>(__args...); }
2156 template<
typename... _Elements>
2157 _GLIBCXX20_CONSTEXPR
2159#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
2161 typename enable_if<__and_<__is_swappable<_Elements>...>::value
2167 noexcept(
noexcept(__x.swap(__y)))
2170#if __cplusplus > 202002L
2171 template<
typename... _Elements>
2172 requires (is_swappable_v<const _Elements> && ...)
2174 swap(
const tuple<_Elements...>& __x,
const tuple<_Elements...>& __y)
2175 noexcept(
noexcept(__x.swap(__y)))
2179#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
2180 template<
typename... _Elements>
2181 _GLIBCXX20_CONSTEXPR
2182 typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type
2183 swap(tuple<_Elements...>&, tuple<_Elements...>&) =
delete;
2190 struct _Swallow_assign
2193 _GLIBCXX14_CONSTEXPR
const _Swallow_assign&
2194 operator=(
const _Tp&)
const
2200 _GLIBCXX17_INLINE
constexpr _Swallow_assign ignore{};
2203 template<
typename... _Types,
typename _Alloc>
2215 template<
class _T1,
class _T2>
2216 template<
typename... _Args1,
typename... _Args2>
2217 _GLIBCXX20_CONSTEXPR
2222 :
pair(__first, __second,
2223 typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
2224 typename _Build_index_tuple<sizeof...(_Args2)>::__type())
2227 template<
class _T1,
class _T2>
2228 template<
typename... _Args1,
size_t... _Indexes1,
2229 typename... _Args2,
size_t... _Indexes2>
2230 _GLIBCXX20_CONSTEXPR
inline
2233 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
2234 : first(
std::
forward<_Args1>(
std::get<_Indexes1>(__tuple1))...),
2235 second(
std::
forward<_Args2>(
std::get<_Indexes2>(__tuple2))...)
2238#if __cplusplus >= 201703L
2244 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _Tuple>
2245 inline constexpr bool __unpack_std_tuple =
false;
2247 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
2248 inline constexpr bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>>
2249 = _Trait<_Tp, _Up...>::value;
2251 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
2252 inline constexpr bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>&>
2253 = _Trait<_Tp, _Up&...>::value;
2255 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
2256 inline constexpr bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>>
2257 = _Trait<_Tp,
const _Up...>::value;
2259 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
2260 inline constexpr bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>&>
2261 = _Trait<_Tp,
const _Up&...>::value;
2263# define __cpp_lib_apply 201603L
2265 template <
typename _Fn,
typename _Tuple,
size_t... _Idx>
2266 constexpr decltype(
auto)
2267 __apply_impl(_Fn&& __f, _Tuple&& __t, index_sequence<_Idx...>)
2270 std::get<_Idx>(std::forward<_Tuple>(__t))...);
2273 template <
typename _Fn,
typename _Tuple>
2274 constexpr decltype(
auto)
2275 apply(_Fn&& __f, _Tuple&& __t)
2276 noexcept(__unpack_std_tuple<is_nothrow_invocable, _Fn, _Tuple>)
2279 = make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>;
2280 return std::__apply_impl(std::forward<_Fn>(__f),
2281 std::forward<_Tuple>(__t),
2285#define __cpp_lib_make_from_tuple 201606L
2287 template <
typename _Tp,
typename _Tuple,
size_t... _Idx>
2289 __make_from_tuple_impl(_Tuple&& __t, index_sequence<_Idx...>)
2290 {
return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); }
2292 template <
typename _Tp,
typename _Tuple>
2294 make_from_tuple(_Tuple&& __t)
2295 noexcept(__unpack_std_tuple<is_nothrow_constructible, _Tp, _Tuple>)
2297 return __make_from_tuple_impl<_Tp>(
2298 std::forward<_Tuple>(__t),
2303#if __cplusplus > 202002L
2304 template<
typename... _TTypes,
typename... _UTypes,
2305 template<
typename>
class TQual,
template<
typename>
class UQual>
2306 requires requires {
typename tuple<common_reference_t<TQual<_TTypes>, UQual<_UTypes>>...>; }
2307 struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, TQual, UQual>
2308 {
using type = tuple<common_reference_t<TQual<_TTypes>, UQual<_UTypes>>...>; };
2310 template<
typename... _TTypes,
typename... _UTypes>
2311 requires requires {
typename tuple<common_type_t<_TTypes, _UTypes>...>; }
2312 struct common_type<tuple<_TTypes...>, tuple<_UTypes...>>
2313 {
using type = tuple<common_type_t<_TTypes, _UTypes>...>; };
2318_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
tuple_cat
constexpr tuple< _Elements &&... > forward_as_tuple(_Elements &&... __args) noexcept
std::forward_as_tuple
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 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
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.
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.
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.