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)
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 template<
typename _Alloc>
321 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a)
323 _Base(__tag, __use_alloc<_Head>(__a))
326 template<
typename _Alloc>
328 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
329 const _Head& __head,
const _Tail&... __tail)
331 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head)
334 template<
typename _Alloc,
typename _UHead,
typename... _UTail,
335 typename = __enable_if_t<
sizeof...(_Tail) ==
sizeof...(_UTail)>>
337 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
338 _UHead&& __head, _UTail&&... __tail)
339 :
_Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
340 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
341 std::forward<_UHead>(__head))
344 template<
typename _Alloc>
346 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
349 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in))
352 template<
typename _Alloc>
354 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
357 _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
358 std::forward<_Head>(_M_head(__in)))
361 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
363 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
367 _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
371 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
373 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
377 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
382 template<
typename... _UElements>
388 _M_tail(*this)._M_assign(
392 template<
typename _UHead,
typename... _UTails>
397 _M_head(*
this) = std::forward<_UHead>
399 _M_tail(*this)._M_assign(
409 swap(_M_head(*
this), _M_head(__in));
410 _Inherited::_M_swap(_M_tail(__in));
415 template<
size_t _Idx,
typename _Head>
417 :
private _Head_base<_Idx, _Head>
419 template<size_t,
typename...>
friend struct _Tuple_impl;
421 typedef _Head_base<_Idx, _Head> _Base;
423 static constexpr _Head&
424 _M_head(
_Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
426 static constexpr
const _Head&
427 _M_head(
const _Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
434 _Tuple_impl(
const _Head& __head)
438 template<
typename _UHead>
440 _Tuple_impl(_UHead&& __head)
444 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
448 _Tuple_impl& operator=(
const _Tuple_impl&) =
delete;
450 #if _GLIBCXX_INLINE_VERSION 451 _Tuple_impl(_Tuple_impl&&) =
default;
454 _Tuple_impl(_Tuple_impl&& __in)
455 noexcept(is_nothrow_move_constructible<_Head>::value)
456 : _Base(static_cast<_Base&&>(__in))
460 template<
typename _UHead>
462 _Tuple_impl(
const _Tuple_impl<_Idx, _UHead>& __in)
463 : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in))
466 template<
typename _UHead>
468 _Tuple_impl(_Tuple_impl<_Idx, _UHead>&& __in)
469 : _Base(
std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
472 template<
typename _Alloc>
474 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a)
475 : _Base(__tag, __use_alloc<_Head>(__a))
478 template<
typename _Alloc>
480 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
482 : _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), __head)
485 template<
typename _Alloc,
typename _UHead>
487 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
489 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
493 template<
typename _Alloc>
495 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
496 const _Tuple_impl& __in)
497 : _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), _M_head(__in))
500 template<
typename _Alloc>
502 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
504 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
508 template<
typename _Alloc,
typename _UHead>
510 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
511 const _Tuple_impl<_Idx, _UHead>& __in)
512 : _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
513 _Tuple_impl<_Idx, _UHead>::_M_head(__in))
516 template<
typename _Alloc,
typename _UHead>
518 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
519 _Tuple_impl<_Idx, _UHead>&& __in)
520 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
521 std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
524 template<
typename _UHead>
527 _M_assign(
const _Tuple_impl<_Idx, _UHead>& __in)
529 _M_head(*
this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in);
532 template<
typename _UHead>
535 _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
538 = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
544 _M_swap(_Tuple_impl& __in)
547 swap(_M_head(*
this), _M_head(__in));
553 template<bool,
typename... _Types>
554 struct _TupleConstraints
556 template<
typename _Tp,
typename _Up>
557 using is_constructible
558 = __bool_constant<__is_constructible(_Tp, _Up)>;
563 template<
typename... _UTypes>
564 static constexpr
bool __is_implicitly_constructible()
566 return __and_<is_constructible<_Types, _UTypes>...,
567 is_convertible<_UTypes, _Types>...
574 template<
typename... _UTypes>
575 static constexpr
bool __is_explicitly_constructible()
577 return __and_<is_constructible<_Types, _UTypes>...,
578 __not_<__and_<is_convertible<_UTypes, _Types>...>>
582 static constexpr
bool __is_implicitly_default_constructible()
584 return __and_<std::__is_implicitly_default_constructible<_Types>...
588 static constexpr
bool __is_explicitly_default_constructible()
590 return __and_<is_default_constructible<_Types>...,
592 std::__is_implicitly_default_constructible<_Types>...>
599 template<
typename... _Types>
600 struct _TupleConstraints<false, _Types...>
602 template<
typename... _UTypes>
603 static constexpr
bool __is_implicitly_constructible()
606 template<
typename... _UTypes>
607 static constexpr
bool __is_explicitly_constructible()
612 template<
typename... _Elements>
613 class tuple :
public _Tuple_impl<0, _Elements...>
615 typedef _Tuple_impl<0, _Elements...> _Inherited;
618 using _TCC = _TupleConstraints<_Cond, _Elements...>;
621 template<
bool _Dummy>
622 using _ImplicitDefaultCtor = __enable_if_t<
623 _TCC<_Dummy>::__is_implicitly_default_constructible(),
627 template<
bool _Dummy>
628 using _ExplicitDefaultCtor = __enable_if_t<
629 _TCC<_Dummy>::__is_explicitly_default_constructible(),
633 template<
bool _Cond,
typename... _Args>
634 using _ImplicitCtor = __enable_if_t<
635 _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(),
639 template<
bool _Cond,
typename... _Args>
640 using _ExplicitCtor = __enable_if_t<
641 _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(),
644 template<
typename... _UElements>
646 __enable_if_t<
sizeof...(_UElements) ==
sizeof...(_Elements),
bool>
648 {
return __and_<is_assignable<_Elements&, _UElements>...>::value; }
651 template<
typename... _UElements>
652 static constexpr
bool __nothrow_assignable()
655 __and_<is_nothrow_assignable<_Elements&, _UElements>...>::value;
659 template<
typename... _UElements>
660 static constexpr
bool __nothrow_constructible()
663 __and_<is_nothrow_constructible<_Elements, _UElements>...>::value;
667 template<
typename _Up>
668 static constexpr
bool __valid_args()
670 return sizeof...(_Elements) == 1
671 && !is_same<tuple, __remove_cvref_t<_Up>>::value;
675 template<
typename,
typename,
typename... _Tail>
676 static constexpr
bool __valid_args()
677 {
return (
sizeof...(_Tail) + 2) ==
sizeof...(_Elements); }
688 template<
typename _Tuple,
typename = tuple,
689 typename = __remove_cvref_t<_Tuple>>
695 template<
typename _Tuple,
typename _Tp,
typename _Up>
696 struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Up>>
697 : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>
701 template<
typename _Tuple,
typename _Tp>
702 struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Tp>>
709 template<
typename _Tuple>
710 static constexpr
bool __use_other_ctor()
711 {
return _UseOtherCtor<_Tuple>::value; }
714 template<
typename _Dummy = void,
715 _ImplicitDefaultCtor<is_void<_Dummy>::value> =
true>
718 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
721 template<
typename _Dummy = void,
722 _ExplicitDefaultCtor<is_void<_Dummy>::value> =
false>
725 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
728 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
729 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
731 tuple(
const _Elements&... __elements)
732 noexcept(__nothrow_constructible<const _Elements&...>())
733 : _Inherited(__elements...) { }
735 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
736 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
738 tuple(
const _Elements&... __elements)
739 noexcept(__nothrow_constructible<const _Elements&...>())
740 : _Inherited(__elements...) { }
742 template<
typename... _UElements,
743 bool _Valid = __valid_args<_UElements...>(),
744 _ImplicitCtor<_Valid, _UElements...> =
true>
746 tuple(_UElements&&... __elements)
747 noexcept(__nothrow_constructible<_UElements...>())
748 : _Inherited(
std::
forward<_UElements>(__elements)...) { }
750 template<
typename... _UElements,
751 bool _Valid = __valid_args<_UElements...>(),
752 _ExplicitCtor<_Valid, _UElements...> =
false>
754 tuple(_UElements&&... __elements)
755 noexcept(__nothrow_constructible<_UElements...>())
756 : _Inherited(
std::
forward<_UElements>(__elements)...) { }
758 constexpr tuple(
const tuple&) =
default;
760 constexpr tuple(tuple&&) =
default;
762 template<
typename... _UElements,
763 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
764 && !__use_other_ctor<
const tuple<_UElements...>&>(),
765 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
767 tuple(
const tuple<_UElements...>& __in)
768 noexcept(__nothrow_constructible<const _UElements&...>())
769 : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
772 template<
typename... _UElements,
773 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
774 && !__use_other_ctor<
const tuple<_UElements...>&>(),
775 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
777 tuple(
const tuple<_UElements...>& __in)
778 noexcept(__nothrow_constructible<const _UElements&...>())
779 : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
782 template<
typename... _UElements,
783 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
784 && !__use_other_ctor<tuple<_UElements...>&&>(),
785 _ImplicitCtor<_Valid, _UElements...> =
true>
787 tuple(tuple<_UElements...>&& __in)
788 noexcept(__nothrow_constructible<_UElements...>())
789 : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
791 template<
typename... _UElements,
792 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
793 && !__use_other_ctor<tuple<_UElements...>&&>(),
794 _ExplicitCtor<_Valid, _UElements...> =
false>
796 tuple(tuple<_UElements...>&& __in)
797 noexcept(__nothrow_constructible<_UElements...>())
798 : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
802 template<
typename _Alloc,
803 _ImplicitDefaultCtor<is_object<_Alloc>::value> =
true>
805 tuple(allocator_arg_t __tag,
const _Alloc& __a)
806 : _Inherited(__tag, __a) { }
808 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
809 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
811 tuple(allocator_arg_t __tag,
const _Alloc& __a,
812 const _Elements&... __elements)
813 : _Inherited(__tag, __a, __elements...) { }
815 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
816 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
819 tuple(allocator_arg_t __tag,
const _Alloc& __a,
820 const _Elements&... __elements)
821 : _Inherited(__tag, __a, __elements...) { }
823 template<
typename _Alloc,
typename... _UElements,
824 bool _Valid = __valid_args<_UElements...>(),
825 _ImplicitCtor<_Valid, _UElements...> =
true>
827 tuple(allocator_arg_t __tag,
const _Alloc& __a,
828 _UElements&&... __elements)
829 : _Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
832 template<
typename _Alloc,
typename... _UElements,
833 bool _Valid = __valid_args<_UElements...>(),
834 _ExplicitCtor<_Valid, _UElements...> =
false>
837 tuple(allocator_arg_t __tag,
const _Alloc& __a,
838 _UElements&&... __elements)
839 : _Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
842 template<
typename _Alloc>
844 tuple(allocator_arg_t __tag,
const _Alloc& __a,
const tuple& __in)
845 : _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
847 template<
typename _Alloc>
849 tuple(allocator_arg_t __tag,
const _Alloc& __a, tuple&& __in)
850 : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
852 template<
typename _Alloc,
typename... _UElements,
853 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
854 && !__use_other_ctor<
const tuple<_UElements...>&>(),
855 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
857 tuple(allocator_arg_t __tag,
const _Alloc& __a,
858 const tuple<_UElements...>& __in)
859 : _Inherited(__tag, __a,
860 static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
863 template<
typename _Alloc,
typename... _UElements,
864 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
865 && !__use_other_ctor<
const tuple<_UElements...>&>(),
866 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
869 tuple(allocator_arg_t __tag,
const _Alloc& __a,
870 const tuple<_UElements...>& __in)
871 : _Inherited(__tag, __a,
872 static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
875 template<
typename _Alloc,
typename... _UElements,
876 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
877 && !__use_other_ctor<tuple<_UElements...>&&>(),
878 _ImplicitCtor<_Valid, _UElements...> =
true>
880 tuple(allocator_arg_t __tag,
const _Alloc& __a,
881 tuple<_UElements...>&& __in)
882 : _Inherited(__tag, __a,
883 static_cast<_Tuple_impl<0, _UElements...>&&>(__in))
886 template<
typename _Alloc,
typename... _UElements,
887 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
888 && !__use_other_ctor<tuple<_UElements...>&&>(),
889 _ExplicitCtor<_Valid, _UElements...> =
false>
892 tuple(allocator_arg_t __tag,
const _Alloc& __a,
893 tuple<_UElements...>&& __in)
894 : _Inherited(__tag, __a,
895 static_cast<_Tuple_impl<0, _UElements...>&&>(__in))
902 operator=(
typename conditional<__assignable<const _Elements&...>(),
904 const __nonesuch&>::type __in)
905 noexcept(__nothrow_assignable<const _Elements&...>())
907 this->_M_assign(__in);
913 operator=(
typename conditional<__assignable<_Elements...>(),
915 __nonesuch&&>::type __in)
916 noexcept(__nothrow_assignable<_Elements...>())
922 template<
typename... _UElements>
924 __enable_if_t<__assignable<
const _UElements&...>(), tuple&>
925 operator=(
const tuple<_UElements...>& __in)
926 noexcept(__nothrow_assignable<const _UElements&...>())
928 this->_M_assign(__in);
932 template<
typename... _UElements>
934 __enable_if_t<__assignable<_UElements...>(), tuple&>
935 operator=(tuple<_UElements...>&& __in)
936 noexcept(__nothrow_assignable<_UElements...>())
946 noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value)
947 { _Inherited::_M_swap(__in); }
950 #if __cpp_deduction_guides >= 201606 951 template<
typename... _UTypes>
952 tuple(_UTypes...) -> tuple<_UTypes...>;
953 template<
typename _T1,
typename _T2>
954 tuple(pair<_T1, _T2>) -> tuple<_T1, _T2>;
955 template<
typename _Alloc,
typename... _UTypes>
956 tuple(allocator_arg_t, _Alloc, _UTypes...) -> tuple<_UTypes...>;
957 template<
typename _Alloc,
typename _T1,
typename _T2>
958 tuple(allocator_arg_t, _Alloc, pair<_T1, _T2>) -> tuple<_T1, _T2>;
959 template<
typename _Alloc,
typename... _UTypes>
960 tuple(allocator_arg_t, _Alloc, tuple<_UTypes...>) -> tuple<_UTypes...>;
969 void swap(tuple&) noexcept { }
974 template<
typename _Alloc>
976 tuple(allocator_arg_t,
const _Alloc&) noexcept { }
977 template<
typename _Alloc>
979 tuple(allocator_arg_t,
const _Alloc&,
const tuple&) noexcept { }
984 template<
typename _T1,
typename _T2>
990 template<
bool _Dummy,
typename _U1,
typename _U2>
991 using _ImplicitDefaultCtor = __enable_if_t<
992 _TupleConstraints<_Dummy, _U1, _U2>::
993 __is_implicitly_default_constructible(),
997 template<
bool _Dummy,
typename _U1,
typename _U2>
998 using _ExplicitDefaultCtor = __enable_if_t<
999 _TupleConstraints<_Dummy, _U1, _U2>::
1000 __is_explicitly_default_constructible(),
1003 template<
bool _Dummy>
1004 using _TCC = _TupleConstraints<_Dummy, _T1, _T2>;
1007 template<
bool _Cond,
typename _U1,
typename _U2>
1008 using _ImplicitCtor = __enable_if_t<
1009 _TCC<_Cond>::template __is_implicitly_constructible<_U1, _U2>(),
1013 template<
bool _Cond,
typename _U1,
typename _U2>
1014 using _ExplicitCtor = __enable_if_t<
1015 _TCC<_Cond>::template __is_explicitly_constructible<_U1, _U2>(),
1018 template<
typename _U1,
typename _U2>
1019 static constexpr
bool __assignable()
1021 return __and_<is_assignable<_T1&, _U1>,
1025 template<
typename _U1,
typename _U2>
1026 static constexpr
bool __nothrow_assignable()
1028 return __and_<is_nothrow_assignable<_T1&, _U1>,
1032 template<
typename _U1,
typename _U2>
1033 static constexpr
bool __nothrow_constructible()
1035 return __and_<is_nothrow_constructible<_T1, _U1>,
1039 static constexpr
bool __nothrow_default_constructible()
1041 return __and_<is_nothrow_default_constructible<_T1>,
1045 template<
typename _U1>
1046 static constexpr
bool __is_alloc_arg()
1050 template<
bool _Dummy =
true,
1051 _ImplicitDefaultCtor<_Dummy, _T1, _T2> =
true>
1054 noexcept(__nothrow_default_constructible())
1057 template<
bool _Dummy =
true,
1058 _ExplicitDefaultCtor<_Dummy, _T1, _T2> =
false>
1061 noexcept(__nothrow_default_constructible())
1064 template<
bool _Dummy =
true,
1065 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1067 tuple(
const _T1& __a1,
const _T2& __a2)
1068 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
1071 template<
bool _Dummy =
true,
1072 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1074 tuple(
const _T1& __a1,
const _T2& __a2)
1075 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
1078 template<
typename _U1,
typename _U2,
1079 _ImplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
true>
1081 tuple(_U1&& __a1, _U2&& __a2)
1082 noexcept(__nothrow_constructible<_U1, _U2>())
1083 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
1085 template<
typename _U1,
typename _U2,
1086 _ExplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
false>
1088 tuple(_U1&& __a1, _U2&& __a2)
1089 noexcept(__nothrow_constructible<_U1, _U2>())
1090 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
1096 template<
typename _U1,
typename _U2,
1097 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1100 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1103 template<
typename _U1,
typename _U2,
1104 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1107 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1110 template<
typename _U1,
typename _U2,
1111 _ImplicitCtor<true, _U1, _U2> =
true>
1114 noexcept(__nothrow_constructible<_U1, _U2>())
1117 template<
typename _U1,
typename _U2,
1118 _ExplicitCtor<true, _U1, _U2> =
false>
1121 noexcept(__nothrow_constructible<_U1, _U2>())
1124 template<
typename _U1,
typename _U2,
1125 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1128 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1131 template<
typename _U1,
typename _U2,
1132 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1135 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1138 template<
typename _U1,
typename _U2,
1139 _ImplicitCtor<true, _U1, _U2> =
true>
1142 noexcept(__nothrow_constructible<_U1, _U2>())
1144 std::forward<_U2>(__in.
second)) { }
1146 template<
typename _U1,
typename _U2,
1147 _ExplicitCtor<true, _U1, _U2> =
false>
1150 noexcept(__nothrow_constructible<_U1, _U2>())
1152 std::forward<_U2>(__in.
second)) { }
1156 template<
typename _Alloc,
1157 _ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> =
true>
1158 _GLIBCXX20_CONSTEXPR
1159 tuple(allocator_arg_t __tag,
const _Alloc& __a)
1162 template<
typename _Alloc,
bool _Dummy =
true,
1163 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1164 _GLIBCXX20_CONSTEXPR
1165 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1166 const _T1& __a1,
const _T2& __a2)
1169 template<
typename _Alloc,
bool _Dummy =
true,
1170 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1172 _GLIBCXX20_CONSTEXPR
1173 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1174 const _T1& __a1,
const _T2& __a2)
1177 template<
typename _Alloc,
typename _U1,
typename _U2,
1178 _ImplicitCtor<true, _U1, _U2> =
true>
1179 _GLIBCXX20_CONSTEXPR
1180 tuple(allocator_arg_t __tag,
const _Alloc& __a, _U1&& __a1, _U2&& __a2)
1181 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1182 std::forward<_U2>(__a2)) { }
1184 template<
typename _Alloc,
typename _U1,
typename _U2,
1185 _ExplicitCtor<true, _U1, _U2> =
false>
1187 _GLIBCXX20_CONSTEXPR
1188 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1189 _U1&& __a1, _U2&& __a2)
1190 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1191 std::forward<_U2>(__a2)) { }
1193 template<
typename _Alloc>
1194 _GLIBCXX20_CONSTEXPR
1195 tuple(allocator_arg_t __tag,
const _Alloc& __a,
const tuple& __in)
1196 :
_Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
1198 template<
typename _Alloc>
1199 _GLIBCXX20_CONSTEXPR
1200 tuple(allocator_arg_t __tag,
const _Alloc& __a,
tuple&& __in)
1201 :
_Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
1203 template<
typename _Alloc,
typename _U1,
typename _U2,
1204 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1205 _GLIBCXX20_CONSTEXPR
1206 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1212 template<
typename _Alloc,
typename _U1,
typename _U2,
1213 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1215 _GLIBCXX20_CONSTEXPR
1216 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1222 template<
typename _Alloc,
typename _U1,
typename _U2,
1223 _ImplicitCtor<true, _U1, _U2> =
true>
1224 _GLIBCXX20_CONSTEXPR
1229 template<
typename _Alloc,
typename _U1,
typename _U2,
1230 _ExplicitCtor<true, _U1, _U2> =
false>
1232 _GLIBCXX20_CONSTEXPR
1237 template<
typename _Alloc,
typename _U1,
typename _U2,
1238 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1239 _GLIBCXX20_CONSTEXPR
1240 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1244 template<
typename _Alloc,
typename _U1,
typename _U2,
1245 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1247 _GLIBCXX20_CONSTEXPR
1248 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1252 template<
typename _Alloc,
typename _U1,
typename _U2,
1253 _ImplicitCtor<true, _U1, _U2> =
true>
1254 _GLIBCXX20_CONSTEXPR
1257 std::forward<_U2>(__in.
second)) { }
1259 template<
typename _Alloc,
typename _U1,
typename _U2,
1260 _ExplicitCtor<true, _U1, _U2> =
false>
1262 _GLIBCXX20_CONSTEXPR
1265 std::forward<_U2>(__in.
second)) { }
1269 _GLIBCXX20_CONSTEXPR
1271 operator=(
typename conditional<__assignable<const _T1&, const _T2&>(),
1273 const __nonesuch&>::type __in)
1274 noexcept(__nothrow_assignable<const _T1&, const _T2&>())
1276 this->_M_assign(__in);
1280 _GLIBCXX20_CONSTEXPR
1282 operator=(
typename conditional<__assignable<_T1, _T2>(),
1284 __nonesuch&&>::type __in)
1285 noexcept(__nothrow_assignable<_T1, _T2>())
1291 template<
typename _U1,
typename _U2>
1292 _GLIBCXX20_CONSTEXPR
1293 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
1295 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1297 this->_M_assign(__in);
1301 template<
typename _U1,
typename _U2>
1302 _GLIBCXX20_CONSTEXPR
1303 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
1305 noexcept(__nothrow_assignable<_U1, _U2>())
1311 template<
typename _U1,
typename _U2>
1312 _GLIBCXX20_CONSTEXPR
1313 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
1315 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1317 this->_M_head(*
this) = __in.
first;
1318 this->_M_tail(*this)._M_head(*
this) = __in.
second;
1322 template<
typename _U1,
typename _U2>
1323 _GLIBCXX20_CONSTEXPR
1324 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
1326 noexcept(__nothrow_assignable<_U1, _U2>())
1328 this->_M_head(*
this) = std::forward<_U1>(__in.
first);
1329 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.
second);
1333 _GLIBCXX20_CONSTEXPR
1336 noexcept(__and_<__is_nothrow_swappable<_T1>,
1337 __is_nothrow_swappable<_T2>>::value)
1338 { _Inherited::_M_swap(__in); }
1343 template<
typename... _Elements>
1347 #if __cplusplus > 201402L 1348 template <
typename _Tp>
1356 template<
size_t __i,
typename _Head,
typename... _Tail>
1363 template<
typename _Head,
typename... _Tail>
1372 template<
size_t __i>
1376 "tuple index must be in range");
1379 template<
size_t __i,
typename _Head,
typename... _Tail>
1384 template<
size_t __i,
typename _Head,
typename... _Tail>
1385 constexpr
const _Head&
1386 __get_helper(
const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
1387 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1390 template<
size_t __i,
typename... _Types>
1391 __enable_if_t<(__i >=
sizeof...(_Types))>
1392 __get_helper(
const tuple<_Types...>&) =
delete;
1395 template<
size_t __i,
typename... _Elements>
1396 constexpr __tuple_element_t<__i, tuple<_Elements...>>&
1398 {
return 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
1404 {
return std::__get_helper<__i>(__t); }
1407 template<
size_t __i,
typename... _Elements>
1408 constexpr __tuple_element_t<__i, tuple<_Elements...>>&&
1411 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1412 return std::forward<__element_type>(std::__get_helper<__i>(__t));
1416 template<
size_t __i,
typename... _Elements>
1417 constexpr
const __tuple_element_t<__i, tuple<_Elements...>>&&
1418 get(
const tuple<_Elements...>&& __t) noexcept
1420 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1421 return std::forward<const __element_type>(std::__get_helper<__i>(__t));
1424 #if __cplusplus >= 201402L 1426 #define __cpp_lib_tuples_by_type 201304 1431 template<
typename _Tp,
typename... _Types>
1433 __find_uniq_type_in_pack()
1435 constexpr
size_t __sz =
sizeof...(_Types);
1436 constexpr
bool __found[__sz] = { __is_same(_Tp, _Types) ... };
1438 for (
size_t __i = 0; __i < __sz; ++__i)
1451 template <
typename _Tp,
typename... _Types>
1455 constexpr
size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1456 static_assert(__idx <
sizeof...(_Types),
1457 "the type T in std::get<T> must occur exactly once in the tuple");
1458 return std::__get_helper<__idx>(__t);
1462 template <
typename _Tp,
typename... _Types>
1466 constexpr
size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1467 static_assert(__idx <
sizeof...(_Types),
1468 "the type T in std::get<T> must occur exactly once in the tuple");
1469 return std::forward<_Tp>(std::__get_helper<__idx>(__t));
1473 template <
typename _Tp,
typename... _Types>
1474 constexpr
const _Tp&
1475 get(
const tuple<_Types...>& __t) noexcept
1477 constexpr
size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1478 static_assert(__idx <
sizeof...(_Types),
1479 "the type T in std::get<T> must occur exactly once in the tuple");
1480 return std::__get_helper<__idx>(__t);
1485 template <
typename _Tp,
typename... _Types>
1486 constexpr
const _Tp&&
1487 get(
const tuple<_Types...>&& __t) noexcept
1489 constexpr
size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
1490 static_assert(__idx <
sizeof...(_Types),
1491 "the type T in std::get<T> must occur exactly once in the tuple");
1492 return std::forward<const _Tp>(std::__get_helper<__idx>(__t));
1497 template<
typename _Tp,
typename _Up,
size_t __i,
size_t __size>
1498 struct __tuple_compare
1500 static constexpr
bool 1501 __eq(
const _Tp& __t,
const _Up& __u)
1503 return bool(std::get<__i>(__t) == std::get<__i>(__u))
1504 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u);
1507 static constexpr
bool 1508 __less(
const _Tp& __t,
const _Up& __u)
1510 return bool(std::get<__i>(__t) < std::get<__i>(__u))
1511 || (!bool(std::get<__i>(__u) < std::get<__i>(__t))
1512 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u));
1516 template<
typename _Tp,
typename _Up,
size_t __size>
1517 struct __tuple_compare<_Tp, _Up, __size, __size>
1519 static constexpr
bool 1520 __eq(
const _Tp&,
const _Up&) {
return true; }
1522 static constexpr
bool 1523 __less(
const _Tp&,
const _Up&) {
return false; }
1526 template<
typename... _TElements,
typename... _UElements>
1528 operator==(
const tuple<_TElements...>& __t,
1529 const tuple<_UElements...>& __u)
1531 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1532 "tuple objects can only be compared if they have equal sizes.");
1533 using __compare = __tuple_compare<tuple<_TElements...>,
1534 tuple<_UElements...>,
1535 0,
sizeof...(_TElements)>;
1536 return __compare::__eq(__t, __u);
1539 #if __cpp_lib_three_way_comparison 1540 template<
typename _Cat,
typename _Tp,
typename _Up>
1542 __tuple_cmp(
const _Tp&,
const _Up&, index_sequence<>)
1543 {
return _Cat::equivalent; }
1545 template<
typename _Cat,
typename _Tp,
typename _Up,
1546 size_t _Idx0,
size_t... _Idxs>
1548 __tuple_cmp(
const _Tp& __t,
const _Up& __u,
1549 index_sequence<_Idx0, _Idxs...>)
1552 = __detail::__synth3way(std::get<_Idx0>(__t), std::get<_Idx0>(__u));
1555 return std::__tuple_cmp<_Cat>(__t, __u,
index_sequence<_Idxs...>());
1558 template<
typename... _Tps,
typename... _Ups>
1560 common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>
1561 operator<=>(
const tuple<_Tps...>& __t,
const tuple<_Ups...>& __u)
1564 = common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>;
1568 template<
typename... _TElements,
typename... _UElements>
1570 operator<(
const tuple<_TElements...>& __t,
1571 const tuple<_UElements...>& __u)
1573 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1574 "tuple objects can only be compared if they have equal sizes.");
1575 using __compare = __tuple_compare<tuple<_TElements...>,
1576 tuple<_UElements...>,
1577 0,
sizeof...(_TElements)>;
1578 return __compare::__less(__t, __u);
1581 template<
typename... _TElements,
typename... _UElements>
1583 operator!=(
const tuple<_TElements...>& __t,
1584 const tuple<_UElements...>& __u)
1585 {
return !(__t == __u); }
1587 template<
typename... _TElements,
typename... _UElements>
1589 operator>(
const tuple<_TElements...>& __t,
1590 const tuple<_UElements...>& __u)
1591 {
return __u < __t; }
1593 template<
typename... _TElements,
typename... _UElements>
1595 operator<=(
const tuple<_TElements...>& __t,
1596 const tuple<_UElements...>& __u)
1597 {
return !(__u < __t); }
1599 template<
typename... _TElements,
typename... _UElements>
1601 operator>=(
const tuple<_TElements...>& __t,
1602 const tuple<_UElements...>& __u)
1603 {
return !(__t < __u); }
1604 #endif // three_way_comparison 1607 template<
typename... _Elements>
1608 constexpr tuple<typename __decay_and_strip<_Elements>::__type...>
1609 make_tuple(_Elements&&... __args)
1611 typedef tuple<typename __decay_and_strip<_Elements>::__type...>
1613 return __result_type(std::forward<_Elements>(__args)...);
1619 template<
typename... _Elements>
1620 constexpr tuple<_Elements&&...>
1622 {
return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
1624 template<
size_t,
typename,
typename,
size_t>
1625 struct __make_tuple_impl;
1627 template<
size_t _Idx,
typename _Tuple,
typename... _Tp,
size_t _Nm>
1628 struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
1629 : __make_tuple_impl<_Idx + 1,
1630 tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
1634 template<
size_t _Nm,
typename _Tuple,
typename... _Tp>
1635 struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
1637 typedef tuple<_Tp...> __type;
1640 template<
typename _Tuple>
1641 struct __do_make_tuple
1642 : __make_tuple_impl<0, tuple<>, _Tuple, tuple_size<_Tuple>::value>
1646 template<
typename _Tuple>
1648 :
public __do_make_tuple<__remove_cvref_t<_Tuple>>
1652 template<
typename...>
1653 struct __combine_tuples;
1656 struct __combine_tuples<>
1658 typedef tuple<> __type;
1661 template<
typename... _Ts>
1662 struct __combine_tuples<tuple<_Ts...>>
1664 typedef tuple<_Ts...> __type;
1667 template<
typename... _T1s,
typename... _T2s,
typename... _Rem>
1668 struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
1670 typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
1671 _Rem...>::__type __type;
1675 template<
typename... _Tpls>
1676 struct __tuple_cat_result
1678 typedef typename __combine_tuples
1679 <
typename __make_tuple<_Tpls>::__type...>::__type __type;
1684 template<
typename...>
1685 struct __make_1st_indices;
1688 struct __make_1st_indices<>
1690 typedef _Index_tuple<> __type;
1693 template<
typename _Tp,
typename... _Tpls>
1694 struct __make_1st_indices<_Tp, _Tpls...>
1696 typedef typename _Build_index_tuple<tuple_size<
1697 typename remove_reference<_Tp>::type>::value>::__type __type;
1703 template<
typename _Ret,
typename _Indices,
typename... _Tpls>
1704 struct __tuple_concater;
1706 template<
typename _Ret,
size_t... _Is,
typename _Tp,
typename... _Tpls>
1707 struct __tuple_concater<_Ret, _Index_tuple<_Is...>, _Tp, _Tpls...>
1709 template<
typename... _Us>
1710 static constexpr _Ret
1711 _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
1713 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1714 typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
1715 return __next::_S_do(std::forward<_Tpls>(__tps)...,
1716 std::forward<_Us>(__us)...,
1717 std::get<_Is>(std::forward<_Tp>(__tp))...);
1721 template<
typename _Ret>
1722 struct __tuple_concater<_Ret, _Index_tuple<>>
1724 template<
typename... _Us>
1725 static constexpr _Ret
1726 _S_do(_Us&&... __us)
1728 return _Ret(std::forward<_Us>(__us)...);
1733 template<
typename... _Tpls,
typename =
typename 1734 enable_if<__and_<__is_tuple_like<_Tpls>...>::value>::type>
1737 ->
typename __tuple_cat_result<_Tpls...>::__type
1739 typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
1740 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1741 typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
1742 return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
1748 template<
typename... _Elements>
1749 constexpr tuple<_Elements&...>
1750 tie(_Elements&... __args) noexcept
1751 {
return tuple<_Elements&...>(__args...); }
1754 template<
typename... _Elements>
1755 _GLIBCXX20_CONSTEXPR
1757 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 1759 typename enable_if<__and_<__is_swappable<_Elements>...>::value
1765 noexcept(noexcept(__x.swap(__y)))
1768 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 1769 template<
typename... _Elements>
1770 _GLIBCXX20_CONSTEXPR
1771 typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type
1772 swap(tuple<_Elements...>&, tuple<_Elements...>&) =
delete;
1779 struct _Swallow_assign
1782 _GLIBCXX14_CONSTEXPR
const _Swallow_assign&
1783 operator=(
const _Tp&)
const 1789 _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
1792 template<
typename... _Types,
typename _Alloc>
1804 template<
class _T1,
class _T2>
1805 template<
typename... _Args1,
typename... _Args2>
1806 _GLIBCXX20_CONSTEXPR
1811 :
pair(__first, __second,
1812 typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
1813 typename _Build_index_tuple<sizeof...(_Args2)>::__type())
1816 template<
class _T1,
class _T2>
1817 template<
typename... _Args1,
size_t... _Indexes1,
1818 typename... _Args2,
size_t... _Indexes2>
1819 _GLIBCXX20_CONSTEXPR
inline 1822 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
1827 #if __cplusplus >= 201703L 1833 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _Tuple>
1834 inline constexpr
bool __unpack_std_tuple =
false;
1836 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1837 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>>
1838 = _Trait<_Tp, _Up...>::value;
1840 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1841 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>&>
1842 = _Trait<_Tp, _Up&...>::value;
1844 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1845 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>>
1846 = _Trait<_Tp,
const _Up...>::value;
1848 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1849 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>&>
1850 = _Trait<_Tp,
const _Up&...>::value;
1852 # define __cpp_lib_apply 201603 1854 template <
typename _Fn,
typename _Tuple,
size_t... _Idx>
1855 constexpr decltype(
auto)
1859 std::get<_Idx>(std::forward<_Tuple>(__t))...);
1862 template <
typename _Fn,
typename _Tuple>
1863 constexpr decltype(
auto)
1864 apply(_Fn&& __f, _Tuple&& __t)
1865 noexcept(__unpack_std_tuple<is_nothrow_invocable, _Fn, _Tuple>)
1868 = make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>;
1869 return std::__apply_impl(std::forward<_Fn>(__f),
1870 std::forward<_Tuple>(__t),
1874 #define __cpp_lib_make_from_tuple 201606 1876 template <
typename _Tp,
typename _Tuple,
size_t... _Idx>
1878 __make_from_tuple_impl(_Tuple&& __t, index_sequence<_Idx...>)
1879 {
return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); }
1881 template <
typename _Tp,
typename _Tuple>
1883 make_from_tuple(_Tuple&& __t)
1884 noexcept(__unpack_std_tuple<is_nothrow_constructible, _Tp, _Tuple>)
1886 return __make_from_tuple_impl<_Tp>(
1887 std::forward<_Tuple>(__t),
1894 _GLIBCXX_END_NAMESPACE_VERSION
1899 #endif // _GLIBCXX_TUPLE
Tag type for piecewise construction of std::pair objects.
_T1 first
The first member.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
constexpr tuple< _Elements &... > tie(_Elements &... __args) noexcept
tie
integer_sequence< size_t, _Idx... > index_sequence
Alias template index_sequence.
Primary class template, 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 tuple< _Elements &&... > forward_as_tuple(_Elements &&... __args) noexcept
std::forward_as_tuple
make_integer_sequence< size_t, _Num > make_index_sequence
Alias template make_index_sequence.
Declare uses_allocator so it can be specialized in <queue> etc.
constexpr __invoke_result< _Callable, _Args... >::type __invoke(_Callable &&__fn, _Args &&... __args) noexcept(__is_nothrow_invocable< _Callable, _Args... >::value)
Invoke a callable object.
is_nothrow_default_constructible
Define a member typedef type to one of two argument types.
Struct holding two objects of arbitrary type.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
make_index_sequence< sizeof...(_Types)> index_sequence_for
Alias template index_sequence_for.
constexpr auto tuple_cat(_Tpls &&... __tpls) -> typename __tuple_cat_result< _Tpls... >::__type
tuple_cat
_T2 second
The second member.
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
ISO C++ entities toplevel namespace is std.