29 #ifndef _GLIBCXX_TUPLE
30 #define _GLIBCXX_TUPLE 1
32 #pragma GCC system_header
34 #if __cplusplus < 201103L
40 #include <bits/uses_allocator.h>
42 #if __cplusplus > 201703L
44 # define __cpp_lib_constexpr_tuple 201811L
47 namespace std _GLIBCXX_VISIBILITY(default)
49 _GLIBCXX_BEGIN_NAMESPACE_VERSION
56 template<
typename... _Elements>
59 template<
typename _Tp>
60 struct __is_empty_non_tuple :
is_empty<_Tp> { };
63 template<
typename _El0,
typename... _El>
67 template<
typename _Tp>
68 using __empty_not_final
69 =
typename conditional<__is_final(_Tp),
false_type,
70 __is_empty_non_tuple<_Tp>>::type;
72 template<
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)
91 : _M_head_impl(std::
forward<_UHead>(__h)) { }
94 _Head_base(allocator_arg_t, __uses_alloc0)
97 template<
typename _Alloc>
98 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
99 : _M_head_impl(allocator_arg, *__a._M_a) { }
101 template<
typename _Alloc>
102 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
103 : _M_head_impl(*__a._M_a) { }
105 template<
typename _UHead>
107 _Head_base(__uses_alloc0, _UHead&& __uhead)
108 : _M_head_impl(std::
forward<_UHead>(__uhead)) { }
110 template<
typename _Alloc,
typename _UHead>
111 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
112 : _M_head_impl(allocator_arg, *__a._M_a, std::
forward<_UHead>(__uhead))
115 template<
typename _Alloc,
typename _UHead>
116 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
117 : _M_head_impl(std::
forward<_UHead>(__uhead), *__a._M_a) { }
119 static constexpr _Head&
120 _M_head(_Head_base& __b) noexcept {
return __b._M_head_impl; }
122 static constexpr
const _Head&
123 _M_head(
const _Head_base& __b) noexcept {
return __b._M_head_impl; }
125 [[__no_unique_address__]] _Head _M_head_impl;
128 template<
size_t _Idx,
typename _Head>
129 struct _Head_base<_Idx, _Head, true>
132 constexpr _Head_base()
135 constexpr _Head_base(
const _Head& __h)
138 constexpr _Head_base(
const _Head_base&) =
default;
139 constexpr _Head_base(_Head_base&&) =
default;
141 template<
typename _UHead>
142 constexpr _Head_base(_UHead&& __h)
143 : _Head(std::
forward<_UHead>(__h)) { }
145 _Head_base(allocator_arg_t, __uses_alloc0)
148 template<
typename _Alloc>
149 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
150 : _Head(allocator_arg, *__a._M_a) { }
152 template<
typename _Alloc>
153 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
154 : _Head(*__a._M_a) { }
156 template<
typename _UHead>
157 _Head_base(__uses_alloc0, _UHead&& __uhead)
158 : _Head(std::
forward<_UHead>(__uhead)) { }
160 template<
typename _Alloc,
typename _UHead>
161 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
162 : _Head(allocator_arg, *__a._M_a, std::
forward<_UHead>(__uhead)) { }
164 template<
typename _Alloc,
typename _UHead>
165 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
166 : _Head(std::
forward<_UHead>(__uhead), *__a._M_a) { }
168 static constexpr _Head&
169 _M_head(_Head_base& __b) noexcept {
return __b; }
171 static constexpr
const _Head&
172 _M_head(
const _Head_base& __b) noexcept {
return __b; }
176 template<
size_t _Idx,
typename _Head>
177 struct _Head_base<_Idx, _Head, false>
179 constexpr _Head_base()
182 constexpr _Head_base(
const _Head& __h)
183 : _M_head_impl(__h) { }
185 constexpr _Head_base(
const _Head_base&) =
default;
186 constexpr _Head_base(_Head_base&&) =
default;
188 template<
typename _UHead>
189 constexpr _Head_base(_UHead&& __h)
190 : _M_head_impl(std::
forward<_UHead>(__h)) { }
193 _Head_base(allocator_arg_t, __uses_alloc0)
196 template<
typename _Alloc>
197 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
198 : _M_head_impl(allocator_arg, *__a._M_a) { }
200 template<
typename _Alloc>
201 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
202 : _M_head_impl(*__a._M_a) { }
204 template<
typename _UHead>
206 _Head_base(__uses_alloc0, _UHead&& __uhead)
207 : _M_head_impl(std::
forward<_UHead>(__uhead)) { }
209 template<
typename _Alloc,
typename _UHead>
210 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
211 : _M_head_impl(allocator_arg, *__a._M_a, std::
forward<_UHead>(__uhead))
214 template<
typename _Alloc,
typename _UHead>
215 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
216 : _M_head_impl(std::
forward<_UHead>(__uhead), *__a._M_a) { }
218 static constexpr _Head&
219 _M_head(_Head_base& __b) noexcept {
return __b._M_head_impl; }
221 static constexpr
const _Head&
222 _M_head(
const _Head_base& __b) noexcept {
return __b._M_head_impl; }
235 template<
size_t _Idx,
typename... _Elements>
243 template<
size_t _Idx,
typename _Head,
typename... _Tail>
246 private _Head_base<_Idx, _Head>
248 template<size_t,
typename...>
friend struct _Tuple_impl;
251 typedef _Head_base<_Idx, _Head> _Base;
253 static constexpr _Head&
254 _M_head(
_Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
256 static constexpr
const _Head&
257 _M_head(
const _Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
263 _M_tail(
const _Tuple_impl& __t) noexcept {
return __t; }
269 _Tuple_impl(
const _Head& __head,
const _Tail&... __tail)
273 template<
typename _UHead,
typename... _UTail,
274 typename = __enable_if_t<
sizeof...(_Tail) ==
sizeof...(_UTail)>>
276 _Tuple_impl(_UHead&& __head, _UTail&&... __tail)
277 :
_Inherited(std::forward<_UTail>(__tail)...),
278 _Base(std::forward<_UHead>(__head))
281 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
285 _Tuple_impl&
operator=(
const _Tuple_impl&) =
delete;
288 _Tuple_impl(_Tuple_impl&& __in)
292 _Base(std::forward<_Head>(_M_head(__in)))
295 template<
typename... _UElements>
302 template<
typename _UHead,
typename... _UTails>
307 _Base(std::forward<_UHead>
311 template<
typename _Alloc>
315 _Base(__tag, __use_alloc<_Head>(__a))
318 template<
typename _Alloc>
320 const _Head& __head,
const _Tail&... __tail)
322 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head)
325 template<
typename _Alloc,
typename _UHead,
typename... _UTail,
326 typename = __enable_if_t<
sizeof...(_Tail) ==
sizeof...(_UTail)>>
329 _UHead&& __head, _UTail&&... __tail)
330 :
_Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
331 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
332 std::forward<_UHead>(__head))
335 template<
typename _Alloc>
338 const _Tuple_impl& __in)
340 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in))
343 template<
typename _Alloc>
348 _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
349 std::forward<_Head>(_M_head(__in)))
352 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
358 _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
362 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
368 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
373 template<
typename... _UElements>
379 _M_tail(*this)._M_assign(
383 template<
typename _UHead,
typename... _UTails>
388 _M_head(*
this) = std::forward<_UHead>
390 _M_tail(*this)._M_assign(
397 _M_swap(_Tuple_impl& __in)
400 swap(_M_head(*
this), _M_head(__in));
401 _Inherited::_M_swap(_M_tail(__in));
406 template<
size_t _Idx,
typename _Head>
408 :
private _Head_base<_Idx, _Head>
410 template<size_t,
typename...>
friend struct _Tuple_impl;
412 typedef _Head_base<_Idx, _Head> _Base;
414 static constexpr _Head&
415 _M_head(
_Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
417 static constexpr
const _Head&
418 _M_head(
const _Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
425 _Tuple_impl(
const _Head& __head)
429 template<
typename _UHead>
431 _Tuple_impl(_UHead&& __head)
432 : _Base(std::
forward<_UHead>(__head))
435 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
439 _Tuple_impl&
operator=(
const _Tuple_impl&) =
delete;
442 _Tuple_impl(_Tuple_impl&& __in)
443 noexcept(is_nothrow_move_constructible<_Head>::value)
444 : _Base(std::
forward<_Head>(_M_head(__in)))
447 template<
typename _UHead>
449 _Tuple_impl(
const _Tuple_impl<_Idx, _UHead>& __in)
450 : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in))
453 template<
typename _UHead>
455 _Tuple_impl(_Tuple_impl<_Idx, _UHead>&& __in)
456 : _Base(std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
459 template<
typename _Alloc>
461 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a)
462 : _Base(__tag, __use_alloc<_Head>(__a))
465 template<
typename _Alloc>
466 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
468 : _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), __head)
471 template<
typename _Alloc,
typename _UHead>
473 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
475 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
479 template<
typename _Alloc>
481 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
482 const _Tuple_impl& __in)
483 : _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), _M_head(__in))
486 template<
typename _Alloc>
488 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
490 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
491 std::
forward<_Head>(_M_head(__in)))
494 template<
typename _Alloc,
typename _UHead>
496 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
497 const _Tuple_impl<_Idx, _UHead>& __in)
498 : _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
499 _Tuple_impl<_Idx, _UHead>::_M_head(__in))
502 template<
typename _Alloc,
typename _UHead>
504 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
505 _Tuple_impl<_Idx, _UHead>&& __in)
506 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
507 std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
510 template<
typename _UHead>
513 _M_assign(
const _Tuple_impl<_Idx, _UHead>& __in)
515 _M_head(*
this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in);
518 template<
typename _UHead>
521 _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
524 = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
530 _M_swap(_Tuple_impl& __in)
533 swap(_M_head(*
this), _M_head(__in));
539 template<bool,
typename... _Types>
540 struct _TupleConstraints
542 template<
typename _Tp,
typename _Up>
543 using is_constructible
544 = __bool_constant<__is_constructible(_Tp, _Up)>;
549 template<
typename... _UTypes>
550 static constexpr
bool __is_implicitly_constructible()
552 return __and_<is_constructible<_Types, _UTypes>...,
553 is_convertible<_UTypes, _Types>...
560 template<
typename... _UTypes>
561 static constexpr
bool __is_explicitly_constructible()
563 return __and_<is_constructible<_Types, _UTypes>...,
564 __not_<__and_<is_convertible<_UTypes, _Types>...>>
568 static constexpr
bool __is_implicitly_default_constructible()
570 return __and_<std::__is_implicitly_default_constructible<_Types>...
574 static constexpr
bool __is_explicitly_default_constructible()
576 return __and_<is_default_constructible<_Types>...,
578 std::__is_implicitly_default_constructible<_Types>...>
585 template<
typename... _Types>
586 struct _TupleConstraints<false, _Types...>
588 template<
typename... _UTypes>
589 static constexpr
bool __is_implicitly_constructible()
592 template<
typename... _UTypes>
593 static constexpr
bool __is_explicitly_constructible()
598 template<
typename... _Elements>
599 class tuple :
public _Tuple_impl<0, _Elements...>
601 typedef _Tuple_impl<0, _Elements...> _Inherited;
604 using _TCC = _TupleConstraints<_Cond, _Elements...>;
607 template<
bool _Dummy>
608 using _ImplicitDefaultCtor = __enable_if_t<
609 _TCC<_Dummy>::__is_implicitly_default_constructible(),
613 template<
bool _Dummy>
614 using _ExplicitDefaultCtor = __enable_if_t<
615 _TCC<_Dummy>::__is_explicitly_default_constructible(),
619 template<
bool _Cond,
typename... _Args>
620 using _ImplicitCtor = __enable_if_t<
621 _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(),
625 template<
bool _Cond,
typename... _Args>
626 using _ExplicitCtor = __enable_if_t<
627 _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(),
630 template<
typename... _UElements>
632 __enable_if_t<
sizeof...(_UElements) ==
sizeof...(_Elements),
bool>
634 {
return __and_<is_assignable<_Elements&, _UElements>...>::value; }
637 template<
typename... _UElements>
638 static constexpr
bool __nothrow_assignable()
641 __and_<is_nothrow_assignable<_Elements&, _UElements>...>::value;
645 template<
typename... _UElements>
646 static constexpr
bool __nothrow_constructible()
649 __and_<is_nothrow_constructible<_Elements, _UElements>...>::value;
653 template<
typename _Up>
654 static constexpr
bool __valid_args()
656 return sizeof...(_Elements) == 1
657 && !is_same<tuple, __remove_cvref_t<_Up>>::value;
661 template<
typename,
typename,
typename... _Tail>
662 static constexpr
bool __valid_args()
663 {
return (
sizeof...(_Tail) + 2) ==
sizeof...(_Elements); }
674 template<
typename _Tuple,
typename = tuple,
675 typename = __remove_cvref_t<_Tuple>>
681 template<
typename _Tuple,
typename _Tp,
typename _Up>
682 struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Up>>
683 : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>
687 template<
typename _Tuple,
typename _Tp>
688 struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Tp>>
695 template<
typename _Tuple>
696 static constexpr
bool __use_other_ctor()
697 {
return _UseOtherCtor<_Tuple>::value; }
700 template<
typename _Dummy = void,
701 _ImplicitDefaultCtor<is_void<_Dummy>::value> =
true>
704 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
707 template<
typename _Dummy = void,
708 _ExplicitDefaultCtor<is_void<_Dummy>::value> =
false>
711 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
714 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
715 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
717 tuple(
const _Elements&... __elements)
718 noexcept(__nothrow_constructible<const _Elements&...>())
719 : _Inherited(__elements...) { }
721 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
722 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
724 tuple(
const _Elements&... __elements)
725 noexcept(__nothrow_constructible<const _Elements&...>())
726 : _Inherited(__elements...) { }
728 template<
typename... _UElements,
729 bool _Valid = __valid_args<_UElements...>(),
730 _ImplicitCtor<_Valid, _UElements...> =
true>
732 tuple(_UElements&&... __elements)
733 noexcept(__nothrow_constructible<_UElements...>())
734 : _Inherited(std::
forward<_UElements>(__elements)...) { }
736 template<
typename... _UElements,
737 bool _Valid = __valid_args<_UElements...>(),
738 _ExplicitCtor<_Valid, _UElements...> =
false>
740 tuple(_UElements&&... __elements)
741 noexcept(__nothrow_constructible<_UElements...>())
742 : _Inherited(std::
forward<_UElements>(__elements)...) { }
744 constexpr tuple(
const tuple&) =
default;
746 constexpr tuple(tuple&&) =
default;
748 template<
typename... _UElements,
749 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
750 && !__use_other_ctor<
const tuple<_UElements...>&>(),
751 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
753 tuple(
const tuple<_UElements...>& __in)
754 noexcept(__nothrow_constructible<const _UElements&...>())
755 : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
758 template<
typename... _UElements,
759 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
760 && !__use_other_ctor<
const tuple<_UElements...>&>(),
761 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
763 tuple(
const tuple<_UElements...>& __in)
764 noexcept(__nothrow_constructible<const _UElements&...>())
765 : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
768 template<
typename... _UElements,
769 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
770 && !__use_other_ctor<tuple<_UElements...>&&>(),
771 _ImplicitCtor<_Valid, _UElements...> =
true>
773 tuple(tuple<_UElements...>&& __in)
774 noexcept(__nothrow_constructible<_UElements...>())
775 : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
777 template<
typename... _UElements,
778 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
779 && !__use_other_ctor<tuple<_UElements...>&&>(),
780 _ExplicitCtor<_Valid, _UElements...> =
false>
782 tuple(tuple<_UElements...>&& __in)
783 noexcept(__nothrow_constructible<_UElements...>())
784 : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
788 template<
typename _Alloc,
789 _ImplicitDefaultCtor<is_object<_Alloc>::value> =
true>
791 tuple(allocator_arg_t __tag,
const _Alloc& __a)
792 : _Inherited(__tag, __a) { }
794 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
795 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
797 tuple(allocator_arg_t __tag,
const _Alloc& __a,
798 const _Elements&... __elements)
799 : _Inherited(__tag, __a, __elements...) { }
801 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
802 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
805 tuple(allocator_arg_t __tag,
const _Alloc& __a,
806 const _Elements&... __elements)
807 : _Inherited(__tag, __a, __elements...) { }
809 template<
typename _Alloc,
typename... _UElements,
810 bool _Valid = __valid_args<_UElements...>(),
811 _ImplicitCtor<_Valid, _UElements...> =
true>
813 tuple(allocator_arg_t __tag,
const _Alloc& __a,
814 _UElements&&... __elements)
815 : _Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
818 template<
typename _Alloc,
typename... _UElements,
819 bool _Valid = __valid_args<_UElements...>(),
820 _ExplicitCtor<_Valid, _UElements...> =
false>
823 tuple(allocator_arg_t __tag,
const _Alloc& __a,
824 _UElements&&... __elements)
825 : _Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
828 template<
typename _Alloc>
830 tuple(allocator_arg_t __tag,
const _Alloc& __a,
const tuple& __in)
831 : _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
833 template<
typename _Alloc>
835 tuple(allocator_arg_t __tag,
const _Alloc& __a, tuple&& __in)
836 : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
838 template<
typename _Alloc,
typename... _UElements,
839 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
840 && !__use_other_ctor<
const tuple<_UElements...>&>(),
841 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
843 tuple(allocator_arg_t __tag,
const _Alloc& __a,
844 const tuple<_UElements...>& __in)
845 : _Inherited(__tag, __a,
846 static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
849 template<
typename _Alloc,
typename... _UElements,
850 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
851 && !__use_other_ctor<
const tuple<_UElements...>&>(),
852 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
855 tuple(allocator_arg_t __tag,
const _Alloc& __a,
856 const tuple<_UElements...>& __in)
857 : _Inherited(__tag, __a,
858 static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
861 template<
typename _Alloc,
typename... _UElements,
862 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
863 && !__use_other_ctor<tuple<_UElements...>&&>(),
864 _ImplicitCtor<_Valid, _UElements...> =
true>
866 tuple(allocator_arg_t __tag,
const _Alloc& __a,
867 tuple<_UElements...>&& __in)
868 : _Inherited(__tag, __a,
869 static_cast<_Tuple_impl<0, _UElements...>&&>(__in))
872 template<
typename _Alloc,
typename... _UElements,
873 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
874 && !__use_other_ctor<tuple<_UElements...>&&>(),
875 _ExplicitCtor<_Valid, _UElements...> =
false>
878 tuple(allocator_arg_t __tag,
const _Alloc& __a,
879 tuple<_UElements...>&& __in)
880 : _Inherited(__tag, __a,
881 static_cast<_Tuple_impl<0, _UElements...>&&>(__in))
888 operator=(
typename conditional<__assignable<const _Elements&...>(),
890 const __nonesuch&>::type __in)
891 noexcept(__nothrow_assignable<const _Elements&...>())
893 this->_M_assign(__in);
899 operator=(
typename conditional<__assignable<_Elements...>(),
901 __nonesuch&&>::type __in)
902 noexcept(__nothrow_assignable<_Elements...>())
908 template<
typename... _UElements>
910 __enable_if_t<__assignable<
const _UElements&...>(), tuple&>
911 operator=(
const tuple<_UElements...>& __in)
912 noexcept(__nothrow_assignable<const _UElements&...>())
914 this->_M_assign(__in);
918 template<
typename... _UElements>
920 __enable_if_t<__assignable<_UElements...>(), tuple&>
921 operator=(tuple<_UElements...>&& __in)
922 noexcept(__nothrow_assignable<_UElements...>())
932 noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value)
933 { _Inherited::_M_swap(__in); }
936 #if __cpp_deduction_guides >= 201606
937 template<
typename... _UTypes>
938 tuple(_UTypes...) -> tuple<_UTypes...>;
939 template<
typename _T1,
typename _T2>
940 tuple(pair<_T1, _T2>) -> tuple<_T1, _T2>;
941 template<
typename _Alloc,
typename... _UTypes>
942 tuple(allocator_arg_t, _Alloc, _UTypes...) -> tuple<_UTypes...>;
943 template<
typename _Alloc,
typename _T1,
typename _T2>
944 tuple(allocator_arg_t, _Alloc, pair<_T1, _T2>) -> tuple<_T1, _T2>;
945 template<
typename _Alloc,
typename... _UTypes>
946 tuple(allocator_arg_t, _Alloc, tuple<_UTypes...>) -> tuple<_UTypes...>;
954 void swap(tuple&) noexcept { }
959 template<
typename _Alloc>
961 tuple(allocator_arg_t,
const _Alloc&) noexcept { }
962 template<
typename _Alloc>
964 tuple(allocator_arg_t,
const _Alloc&,
const tuple&) noexcept { }
969 template<
typename _T1,
typename _T2>
975 template<
bool _Dummy,
typename _U1,
typename _U2>
976 using _ImplicitDefaultCtor = __enable_if_t<
977 _TupleConstraints<_Dummy, _U1, _U2>::
978 __is_implicitly_default_constructible(),
982 template<
bool _Dummy,
typename _U1,
typename _U2>
983 using _ExplicitDefaultCtor = __enable_if_t<
984 _TupleConstraints<_Dummy, _U1, _U2>::
985 __is_explicitly_default_constructible(),
988 template<
bool _Dummy>
989 using _TCC = _TupleConstraints<_Dummy, _T1, _T2>;
992 template<
bool _Cond,
typename _U1,
typename _U2>
993 using _ImplicitCtor = __enable_if_t<
994 _TCC<_Cond>::template __is_implicitly_constructible<_U1, _U2>(),
998 template<
bool _Cond,
typename _U1,
typename _U2>
999 using _ExplicitCtor = __enable_if_t<
1000 _TCC<_Cond>::template __is_explicitly_constructible<_U1, _U2>(),
1003 template<
typename _U1,
typename _U2>
1004 static constexpr
bool __assignable()
1006 return __and_<is_assignable<_T1&, _U1>,
1010 template<
typename _U1,
typename _U2>
1011 static constexpr
bool __nothrow_assignable()
1013 return __and_<is_nothrow_assignable<_T1&, _U1>,
1017 template<
typename _U1,
typename _U2>
1018 static constexpr
bool __nothrow_constructible()
1020 return __and_<is_nothrow_constructible<_T1, _U1>,
1024 static constexpr
bool __nothrow_default_constructible()
1026 return __and_<is_nothrow_default_constructible<_T1>,
1030 template<
typename _U1>
1031 static constexpr
bool __is_alloc_arg()
1035 template<
bool _Dummy =
true,
1036 _ImplicitDefaultCtor<_Dummy, _T1, _T2> =
true>
1039 noexcept(__nothrow_default_constructible())
1042 template<
bool _Dummy =
true,
1043 _ExplicitDefaultCtor<_Dummy, _T1, _T2> =
false>
1046 noexcept(__nothrow_default_constructible())
1049 template<
bool _Dummy =
true,
1050 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1052 tuple(
const _T1& __a1,
const _T2& __a2)
1053 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
1056 template<
bool _Dummy =
true,
1057 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1059 tuple(
const _T1& __a1,
const _T2& __a2)
1060 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
1063 template<
typename _U1,
typename _U2,
1064 _ImplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
true>
1066 tuple(_U1&& __a1, _U2&& __a2)
1067 noexcept(__nothrow_constructible<_U1, _U2>())
1068 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
1070 template<
typename _U1,
typename _U2,
1071 _ExplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
false>
1073 tuple(_U1&& __a1, _U2&& __a2)
1074 noexcept(__nothrow_constructible<_U1, _U2>())
1075 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
1081 template<
typename _U1,
typename _U2,
1082 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1085 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1088 template<
typename _U1,
typename _U2,
1089 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1092 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1095 template<
typename _U1,
typename _U2,
1096 _ImplicitCtor<true, _U1, _U2> =
true>
1099 noexcept(__nothrow_constructible<_U1, _U2>())
1102 template<
typename _U1,
typename _U2,
1103 _ExplicitCtor<true, _U1, _U2> =
false>
1106 noexcept(__nothrow_constructible<_U1, _U2>())
1109 template<
typename _U1,
typename _U2,
1110 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1113 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1116 template<
typename _U1,
typename _U2,
1117 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1120 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1123 template<
typename _U1,
typename _U2,
1124 _ImplicitCtor<true, _U1, _U2> =
true>
1127 noexcept(__nothrow_constructible<_U1, _U2>())
1129 std::forward<_U2>(__in.
second)) { }
1131 template<
typename _U1,
typename _U2,
1132 _ExplicitCtor<true, _U1, _U2> =
false>
1135 noexcept(__nothrow_constructible<_U1, _U2>())
1137 std::forward<_U2>(__in.
second)) { }
1141 template<
typename _Alloc,
1142 _ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> =
true>
1143 _GLIBCXX20_CONSTEXPR
1147 template<
typename _Alloc,
bool _Dummy =
true,
1148 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1149 _GLIBCXX20_CONSTEXPR
1151 const _T1& __a1,
const _T2& __a2)
1154 template<
typename _Alloc,
bool _Dummy =
true,
1155 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1157 _GLIBCXX20_CONSTEXPR
1159 const _T1& __a1,
const _T2& __a2)
1162 template<
typename _Alloc,
typename _U1,
typename _U2,
1163 _ImplicitCtor<true, _U1, _U2> =
true>
1164 _GLIBCXX20_CONSTEXPR
1165 tuple(
allocator_arg_t __tag,
const _Alloc& __a, _U1&& __a1, _U2&& __a2)
1166 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1167 std::forward<_U2>(__a2)) { }
1169 template<
typename _Alloc,
typename _U1,
typename _U2,
1170 _ExplicitCtor<true, _U1, _U2> =
false>
1172 _GLIBCXX20_CONSTEXPR
1174 _U1&& __a1, _U2&& __a2)
1175 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1176 std::forward<_U2>(__a2)) { }
1178 template<
typename _Alloc>
1179 _GLIBCXX20_CONSTEXPR
1181 :
_Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
1183 template<
typename _Alloc>
1184 _GLIBCXX20_CONSTEXPR
1186 :
_Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
1188 template<
typename _Alloc,
typename _U1,
typename _U2,
1189 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1190 _GLIBCXX20_CONSTEXPR
1197 template<
typename _Alloc,
typename _U1,
typename _U2,
1198 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1200 _GLIBCXX20_CONSTEXPR
1207 template<
typename _Alloc,
typename _U1,
typename _U2,
1208 _ImplicitCtor<true, _U1, _U2> =
true>
1209 _GLIBCXX20_CONSTEXPR
1214 template<
typename _Alloc,
typename _U1,
typename _U2,
1215 _ExplicitCtor<true, _U1, _U2> =
false>
1217 _GLIBCXX20_CONSTEXPR
1222 template<
typename _Alloc,
typename _U1,
typename _U2,
1223 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1224 _GLIBCXX20_CONSTEXPR
1229 template<
typename _Alloc,
typename _U1,
typename _U2,
1230 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1232 _GLIBCXX20_CONSTEXPR
1237 template<
typename _Alloc,
typename _U1,
typename _U2,
1238 _ImplicitCtor<true, _U1, _U2> =
true>
1239 _GLIBCXX20_CONSTEXPR
1242 std::forward<_U2>(__in.
second)) { }
1244 template<
typename _Alloc,
typename _U1,
typename _U2,
1245 _ExplicitCtor<true, _U1, _U2> =
false>
1247 _GLIBCXX20_CONSTEXPR
1250 std::forward<_U2>(__in.
second)) { }
1254 _GLIBCXX20_CONSTEXPR
1258 const __nonesuch&>::type __in)
1259 noexcept(__nothrow_assignable<const _T1&, const _T2&>())
1261 this->_M_assign(__in);
1265 _GLIBCXX20_CONSTEXPR
1269 __nonesuch&&>::type __in)
1270 noexcept(__nothrow_assignable<_T1, _T2>())
1276 template<
typename _U1,
typename _U2>
1277 _GLIBCXX20_CONSTEXPR
1278 __enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&>
1280 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1282 this->_M_assign(__in);
1286 template<
typename _U1,
typename _U2>
1287 _GLIBCXX20_CONSTEXPR
1288 __enable_if_t<__assignable<_U1, _U2>(), tuple&>
1290 noexcept(__nothrow_assignable<_U1, _U2>())
1296 template<
typename _U1,
typename _U2>
1297 _GLIBCXX20_CONSTEXPR
1298 __enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&>
1300 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1302 this->_M_head(*
this) = __in.
first;
1303 this->_M_tail(*this)._M_head(*
this) = __in.
second;
1307 template<
typename _U1,
typename _U2>
1308 _GLIBCXX20_CONSTEXPR
1309 __enable_if_t<__assignable<_U1, _U2>(), tuple&>
1311 noexcept(__nothrow_assignable<_U1, _U2>())
1313 this->_M_head(*
this) = std::forward<_U1>(__in.
first);
1314 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.
second);
1318 _GLIBCXX20_CONSTEXPR
1321 noexcept(__and_<__is_nothrow_swappable<_T1>,
1322 __is_nothrow_swappable<_T2>>::value)
1323 { _Inherited::_M_swap(__in); }
1328 template<
typename... _Elements>
1332 #if __cplusplus > 201402L
1333 template <
typename _Tp>
1341 template<
size_t __i,
typename _Head,
typename... _Tail>
1348 template<
typename _Head,
typename... _Tail>
1357 template<
size_t __i>
1361 "tuple index must be in range");
1364 template<
size_t __i,
typename _Head,
typename... _Tail>
1369 template<
size_t __i,
typename _Head,
typename... _Tail>
1370 constexpr
const _Head&
1371 __get_helper(
const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
1372 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1375 template<
size_t __i,
typename... _Types>
1376 __enable_if_t<(__i >=
sizeof...(_Types))>
1377 __get_helper(
const tuple<_Types...>&) =
delete;
1380 template<
size_t __i,
typename... _Elements>
1381 constexpr __tuple_element_t<__i, tuple<_Elements...>>&
1383 {
return std::__get_helper<__i>(__t); }
1386 template<
size_t __i,
typename... _Elements>
1387 constexpr
const __tuple_element_t<__i, tuple<_Elements...>>&
1388 get(
const tuple<_Elements...>& __t) noexcept
1389 {
return std::__get_helper<__i>(__t); }
1392 template<
size_t __i,
typename... _Elements>
1393 constexpr __tuple_element_t<__i, tuple<_Elements...>>&&
1396 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1397 return std::forward<__element_type>(std::__get_helper<__i>(__t));
1401 template<
size_t __i,
typename... _Elements>
1402 constexpr
const __tuple_element_t<__i, tuple<_Elements...>>&&
1403 get(
const tuple<_Elements...>&& __t) noexcept
1405 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1406 return std::forward<const __element_type>(std::__get_helper<__i>(__t));
1409 #if __cplusplus >= 201402L
1411 #define __cpp_lib_tuples_by_type 201304
1416 template<
typename _Tp,
typename... _Types>
1418 __find_uniq_type_in_pack()
1420 constexpr
size_t __sz =
sizeof...(_Types);
1421 constexpr
bool __found[__sz] = { __is_same(_Tp, _Types) ... };
1423 for (
size_t __i = 0; __i < __sz; ++__i)
1436 template <
typename _Tp,
typename... _Types>
1440 constexpr
size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1441 static_assert(__idx <
sizeof...(_Types),
1442 "the type T in std::get<T> must occur exactly once in the tuple");
1443 return std::__get_helper<__idx>(__t);
1447 template <
typename _Tp,
typename... _Types>
1451 constexpr
size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1452 static_assert(__idx <
sizeof...(_Types),
1453 "the type T in std::get<T> must occur exactly once in the tuple");
1454 return std::forward<_Tp>(std::__get_helper<__idx>(__t));
1458 template <
typename _Tp,
typename... _Types>
1459 constexpr
const _Tp&
1460 get(
const tuple<_Types...>& __t) noexcept
1462 constexpr
size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1463 static_assert(__idx <
sizeof...(_Types),
1464 "the type T in std::get<T> must occur exactly once in the tuple");
1465 return std::__get_helper<__idx>(__t);
1470 template <
typename _Tp,
typename... _Types>
1471 constexpr
const _Tp&&
1472 get(
const tuple<_Types...>&& __t) noexcept
1474 constexpr
size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1475 static_assert(__idx <
sizeof...(_Types),
1476 "the type T in std::get<T> must occur exactly once in the tuple");
1477 return std::forward<const _Tp>(std::__get_helper<__idx>(__t));
1482 template<
typename _Tp,
typename _Up,
size_t __i,
size_t __size>
1483 struct __tuple_compare
1485 static constexpr
bool
1486 __eq(
const _Tp& __t,
const _Up& __u)
1488 return bool(std::get<__i>(__t) == std::get<__i>(__u))
1489 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u);
1492 static constexpr
bool
1493 __less(
const _Tp& __t,
const _Up& __u)
1495 return bool(std::get<__i>(__t) < std::get<__i>(__u))
1496 || (!bool(std::get<__i>(__u) < std::get<__i>(__t))
1497 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u));
1501 template<
typename _Tp,
typename _Up,
size_t __size>
1502 struct __tuple_compare<_Tp, _Up, __size, __size>
1504 static constexpr
bool
1505 __eq(
const _Tp&,
const _Up&) {
return true; }
1507 static constexpr
bool
1508 __less(
const _Tp&,
const _Up&) {
return false; }
1511 template<
typename... _TElements,
typename... _UElements>
1513 operator==(
const tuple<_TElements...>& __t,
1514 const tuple<_UElements...>& __u)
1516 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1517 "tuple objects can only be compared if they have equal sizes.");
1518 using __compare = __tuple_compare<tuple<_TElements...>,
1519 tuple<_UElements...>,
1520 0,
sizeof...(_TElements)>;
1521 return __compare::__eq(__t, __u);
1524 #if __cpp_lib_three_way_comparison
1525 template<
typename _Cat,
typename _Tp,
typename _Up>
1527 __tuple_cmp(
const _Tp&,
const _Up&, index_sequence<>)
1528 {
return _Cat::equivalent; }
1530 template<
typename _Cat,
typename _Tp,
typename _Up,
1531 size_t _Idx0,
size_t... _Idxs>
1533 __tuple_cmp(
const _Tp& __t,
const _Up& __u,
1534 index_sequence<_Idx0, _Idxs...>)
1537 = __detail::__synth3way(std::get<_Idx0>(__t), std::get<_Idx0>(__u));
1540 return std::__tuple_cmp<_Cat>(__t, __u,
index_sequence<_Idxs...>());
1543 template<
typename... _Tps,
typename... _Ups>
1545 common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>
1546 operator<=>(
const tuple<_Tps...>& __t,
const tuple<_Ups...>& __u)
1549 = common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>;
1553 template<
typename... _TElements,
typename... _UElements>
1555 operator<(
const tuple<_TElements...>& __t,
1556 const tuple<_UElements...>& __u)
1558 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1559 "tuple objects can only be compared if they have equal sizes.");
1560 using __compare = __tuple_compare<tuple<_TElements...>,
1561 tuple<_UElements...>,
1562 0,
sizeof...(_TElements)>;
1563 return __compare::__less(__t, __u);
1566 template<
typename... _TElements,
typename... _UElements>
1568 operator!=(
const tuple<_TElements...>& __t,
1569 const tuple<_UElements...>& __u)
1570 {
return !(__t == __u); }
1572 template<
typename... _TElements,
typename... _UElements>
1574 operator>(
const tuple<_TElements...>& __t,
1575 const tuple<_UElements...>& __u)
1576 {
return __u < __t; }
1578 template<
typename... _TElements,
typename... _UElements>
1580 operator<=(
const tuple<_TElements...>& __t,
1581 const tuple<_UElements...>& __u)
1582 {
return !(__u < __t); }
1584 template<
typename... _TElements,
typename... _UElements>
1586 operator>=(
const tuple<_TElements...>& __t,
1587 const tuple<_UElements...>& __u)
1588 {
return !(__t < __u); }
1589 #endif // three_way_comparison
1592 template<
typename... _Elements>
1593 constexpr tuple<typename __decay_and_strip<_Elements>::__type...>
1594 make_tuple(_Elements&&... __args)
1596 typedef tuple<typename __decay_and_strip<_Elements>::__type...>
1598 return __result_type(std::forward<_Elements>(__args)...);
1604 template<
typename... _Elements>
1605 constexpr tuple<_Elements&&...>
1607 {
return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
1609 template<
size_t,
typename,
typename,
size_t>
1610 struct __make_tuple_impl;
1612 template<
size_t _Idx,
typename _Tuple,
typename... _Tp,
size_t _Nm>
1613 struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
1614 : __make_tuple_impl<_Idx + 1,
1615 tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
1619 template<
size_t _Nm,
typename _Tuple,
typename... _Tp>
1620 struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
1622 typedef tuple<_Tp...> __type;
1625 template<
typename _Tuple>
1626 struct __do_make_tuple
1627 : __make_tuple_impl<0, tuple<>, _Tuple, tuple_size<_Tuple>::value>
1631 template<
typename _Tuple>
1633 :
public __do_make_tuple<__remove_cvref_t<_Tuple>>
1637 template<
typename...>
1638 struct __combine_tuples;
1641 struct __combine_tuples<>
1643 typedef tuple<> __type;
1646 template<
typename... _Ts>
1647 struct __combine_tuples<tuple<_Ts...>>
1649 typedef tuple<_Ts...> __type;
1652 template<
typename... _T1s,
typename... _T2s,
typename... _Rem>
1653 struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
1655 typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
1656 _Rem...>::__type __type;
1660 template<
typename... _Tpls>
1661 struct __tuple_cat_result
1663 typedef typename __combine_tuples
1669 template<
typename...>
1670 struct __make_1st_indices;
1673 struct __make_1st_indices<>
1675 typedef _Index_tuple<> __type;
1678 template<
typename _Tp,
typename... _Tpls>
1679 struct __make_1st_indices<_Tp, _Tpls...>
1681 typedef typename _Build_index_tuple<tuple_size<
1682 typename remove_reference<_Tp>::type>::value>::__type __type;
1688 template<
typename _Ret,
typename _Indices,
typename... _Tpls>
1689 struct __tuple_concater;
1691 template<
typename _Ret,
size_t... _Is,
typename _Tp,
typename... _Tpls>
1692 struct __tuple_concater<_Ret, _Index_tuple<_Is...>, _Tp, _Tpls...>
1694 template<
typename... _Us>
1695 static constexpr _Ret
1696 _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
1698 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1699 typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
1700 return __next::_S_do(std::forward<_Tpls>(__tps)...,
1701 std::forward<_Us>(__us)...,
1702 std::get<_Is>(std::forward<_Tp>(__tp))...);
1706 template<
typename _Ret>
1707 struct __tuple_concater<_Ret, _Index_tuple<>>
1709 template<
typename... _Us>
1710 static constexpr _Ret
1711 _S_do(_Us&&... __us)
1713 return _Ret(std::forward<_Us>(__us)...);
1718 template<
typename... _Tpls,
typename =
typename
1719 enable_if<__and_<__is_tuple_like<_Tpls>...>::value>::type>
1721 tuple_cat(_Tpls&&... __tpls)
1722 ->
typename __tuple_cat_result<_Tpls...>::__type
1724 typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
1725 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1726 typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
1727 return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
1733 template<
typename... _Elements>
1734 constexpr tuple<_Elements&...>
1735 tie(_Elements&... __args) noexcept
1736 {
return tuple<_Elements&...>(__args...); }
1739 template<
typename... _Elements>
1740 _GLIBCXX20_CONSTEXPR
1742 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
1744 typename enable_if<__and_<__is_swappable<_Elements>...>::value
1749 swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
1750 noexcept(noexcept(__x.swap(__y)))
1753 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
1754 template<
typename... _Elements>
1755 _GLIBCXX20_CONSTEXPR
1756 typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type
1757 swap(tuple<_Elements...>&, tuple<_Elements...>&) =
delete;
1764 struct _Swallow_assign
1767 _GLIBCXX14_CONSTEXPR
const _Swallow_assign&
1774 _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
1777 template<
typename... _Types,
typename _Alloc>
1789 template<
class _T1,
class _T2>
1790 template<
typename... _Args1,
typename... _Args2>
1791 _GLIBCXX20_CONSTEXPR
1796 :
pair(__first, __second,
1797 typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
1798 typename _Build_index_tuple<sizeof...(_Args2)>::__type())
1801 template<
class _T1,
class _T2>
1802 template<
typename... _Args1,
size_t... _Indexes1,
1803 typename... _Args2,
size_t... _Indexes2>
1804 _GLIBCXX20_CONSTEXPR
inline
1807 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
1808 : first(std::
forward<_Args1>(std::get<_Indexes1>(__tuple1))...),
1809 second(std::
forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
1812 #if __cplusplus >= 201703L
1818 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _Tuple>
1819 inline constexpr
bool __unpack_std_tuple =
false;
1821 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1822 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>>
1823 = _Trait<_Tp, _Up...>::value;
1825 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1826 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>&>
1827 = _Trait<_Tp, _Up&...>::value;
1829 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1830 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>>
1831 = _Trait<_Tp,
const _Up...>::value;
1833 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1834 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>&>
1835 = _Trait<_Tp,
const _Up&...>::value;
1837 # define __cpp_lib_apply 201603
1839 template <
typename _Fn,
typename _Tuple,
size_t... _Idx>
1840 constexpr decltype(
auto)
1843 return std::__invoke(std::forward<_Fn>(__f),
1844 std::get<_Idx>(std::forward<_Tuple>(__t))...);
1847 template <
typename _Fn,
typename _Tuple>
1848 constexpr decltype(
auto)
1849 apply(_Fn&& __f, _Tuple&& __t)
1850 noexcept(__unpack_std_tuple<is_nothrow_invocable, _Fn, _Tuple>)
1853 = make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>;
1854 return std::__apply_impl(std::forward<_Fn>(__f),
1855 std::forward<_Tuple>(__t),
1859 #define __cpp_lib_make_from_tuple 201606
1861 template <
typename _Tp,
typename _Tuple,
size_t... _Idx>
1863 __make_from_tuple_impl(_Tuple&& __t, index_sequence<_Idx...>)
1864 {
return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); }
1866 template <
typename _Tp,
typename _Tuple>
1868 make_from_tuple(_Tuple&& __t)
1869 noexcept(__unpack_std_tuple<is_nothrow_constructible, _Tp, _Tuple>)
1871 return __make_from_tuple_impl<_Tp>(
1872 std::forward<_Tuple>(__t),
1879 _GLIBCXX_END_NAMESPACE_VERSION
1884 #endif // _GLIBCXX_TUPLE
constexpr tuple< _Elements &&...> forward_as_tuple(_Elements &&...__args) noexcept
std::forward_as_tuple
constexpr tuple< _Elements &...> tie(_Elements &...__args) noexcept
tie
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
is_nothrow_default_constructible
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
Struct holding two objects of arbitrary type.
__combine_tuples< typename __make_tuple< _Tpls >::__type...>::__type __type
tuple_cat
Declare uses_allocator so it can be specialized in <queue> etc.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
Define a member typedef type to one of two argument types.
is_nothrow_move_constructible
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
make_integer_sequence< size_t, _Num > make_index_sequence
Alias template make_index_sequence.
make_index_sequence< sizeof...(_Types)> index_sequence_for
Alias template index_sequence_for.
_T2 second
The second member.
_T1 first
The first member.
Primary class template, tuple.
Tag type for piecewise construction of std::pair objects.
integer_sequence< size_t, _Idx...> index_sequence
Alias template index_sequence.
auto_ptr & operator=(auto_ptr &__a)
auto_ptr assignment operator.