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
70 __is_empty_non_tuple<_Tp>>::type;
72 template<std::size_t _Idx,
typename _Head,
73 bool = __empty_not_final<_Head>::value>
76 template<std::
size_t _Idx,
typename _Head>
77 struct _Head_base<_Idx, _Head, true>
80 constexpr _Head_base()
83 constexpr _Head_base(
const _Head& __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)
96 template<
typename _Alloc>
98 : _Head(allocator_arg, *__a._M_a) { }
100 template<
typename _Alloc>
102 : _Head(*__a._M_a) { }
104 template<
typename _UHead>
105 _Head_base(__uses_alloc0, _UHead&& __uhead)
108 template<
typename _Alloc,
typename _UHead>
109 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
110 : _Head(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead)) { }
112 template<
typename _Alloc,
typename _UHead>
113 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
114 : _Head(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
116 static constexpr _Head&
117 _M_head(_Head_base& __b) noexcept {
return __b; }
119 static constexpr
const _Head&
120 _M_head(
const _Head_base& __b) noexcept {
return __b; }
123 template<std::
size_t _Idx,
typename _Head>
124 struct _Head_base<_Idx, _Head, false>
126 constexpr _Head_base()
129 constexpr _Head_base(
const _Head& __h)
130 : _M_head_impl(__h) { }
132 constexpr _Head_base(
const _Head_base&) =
default;
133 constexpr _Head_base(_Head_base&&) =
default;
135 template<
typename _UHead>
136 constexpr _Head_base(_UHead&& __h)
143 template<
typename _Alloc>
145 : _M_head_impl(allocator_arg, *__a._M_a) { }
147 template<
typename _Alloc>
149 : _M_head_impl(*__a._M_a) { }
151 template<
typename _UHead>
153 _Head_base(__uses_alloc0, _UHead&& __uhead)
154 : _M_head_impl(
std::
forward<_UHead>(__uhead)) { }
156 template<
typename _Alloc,
typename _UHead>
157 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
158 : _M_head_impl(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead))
161 template<
typename _Alloc,
typename _UHead>
162 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
163 : _M_head_impl(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
165 static constexpr _Head&
166 _M_head(_Head_base& __b) noexcept {
return __b._M_head_impl; }
168 static constexpr
const _Head&
169 _M_head(
const _Head_base& __b) noexcept {
return __b._M_head_impl; }
182 template<std::size_t _Idx,
typename... _Elements>
190 template<std::size_t _Idx,
typename _Head,
typename... _Tail>
193 private _Head_base<_Idx, _Head>
195 template<std::size_t,
typename...>
friend class _Tuple_impl;
198 typedef _Head_base<_Idx, _Head> _Base;
200 static constexpr _Head&
201 _M_head(
_Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
203 static constexpr
const _Head&
204 _M_head(
const _Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
210 _M_tail(
const _Tuple_impl& __t) noexcept {
return __t; }
216 constexpr _Tuple_impl(
const _Head& __head,
const _Tail&... __tail)
219 template<
typename _UHead,
typename... _UTail,
typename =
typename 220 enable_if<
sizeof...(_Tail) ==
sizeof...(_UTail)>::type>
222 constexpr _Tuple_impl(_UHead&& __head, _UTail&&... __tail)
223 :
_Inherited(std::forward<_UTail>(__tail)...),
224 _Base(std::forward<_UHead>(__head)) { }
226 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
230 _Tuple_impl& operator=(
const _Tuple_impl&) =
delete;
233 _Tuple_impl(_Tuple_impl&& __in)
237 _Base(std::forward<_Head>(_M_head(__in))) { }
239 template<
typename... _UElements>
244 template<
typename _UHead,
typename... _UTails>
248 _Base(std::forward<_UHead>
251 template<
typename _Alloc>
255 _Base(__tag, __use_alloc<_Head>(__a)) { }
257 template<
typename _Alloc>
259 const _Head& __head,
const _Tail&... __tail)
261 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
263 template<
typename _Alloc,
typename _UHead,
typename... _UTail,
264 typename =
typename enable_if<
sizeof...(_Tail)
265 ==
sizeof...(_UTail)>::type>
268 _UHead&& __head, _UTail&&... __tail)
269 :
_Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
270 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
271 std::forward<_UHead>(__head)) { }
273 template<
typename _Alloc>
276 const _Tuple_impl& __in)
278 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
280 template<
typename _Alloc>
285 _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
286 std::forward<_Head>(_M_head(__in))) { }
288 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
294 _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
297 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
303 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
307 template<
typename... _UElements>
313 _M_tail(*this)._M_assign(
317 template<
typename _UHead,
typename... _UTails>
322 _M_head(*
this) = std::forward<_UHead>
324 _M_tail(*this)._M_assign(
331 _M_swap(_Tuple_impl& __in)
334 swap(_M_head(*
this), _M_head(__in));
335 _Inherited::_M_swap(_M_tail(__in));
340 template<std::
size_t _Idx,
typename _Head>
342 :
private _Head_base<_Idx, _Head>
344 template<std::size_t,
typename...>
friend class _Tuple_impl;
346 typedef _Head_base<_Idx, _Head> _Base;
348 static constexpr _Head&
349 _M_head(
_Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
351 static constexpr
const _Head&
352 _M_head(
const _Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
358 constexpr _Tuple_impl(
const _Head& __head)
361 template<
typename _UHead>
363 constexpr _Tuple_impl(_UHead&& __head)
364 : _Base(std::forward<_UHead>(__head)) { }
366 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
370 _Tuple_impl& operator=(
const _Tuple_impl&) =
delete;
373 _Tuple_impl(_Tuple_impl&& __in)
375 : _Base(std::forward<_Head>(_M_head(__in))) { }
377 template<
typename _UHead>
381 template<
typename _UHead>
386 template<
typename _Alloc>
389 : _Base(__tag, __use_alloc<_Head>(__a)) { }
391 template<
typename _Alloc>
394 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
396 template<
typename _Alloc,
typename _UHead>
400 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
401 std::forward<_UHead>(__head)) { }
403 template<
typename _Alloc>
406 const _Tuple_impl& __in)
407 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
409 template<
typename _Alloc>
413 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
414 std::forward<_Head>(_M_head(__in))) { }
416 template<
typename _Alloc,
typename _UHead>
420 : _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
423 template<
typename _Alloc,
typename _UHead>
427 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
431 template<
typename _UHead>
439 template<
typename _UHead>
451 _M_swap(_Tuple_impl& __in)
454 swap(_M_head(*
this), _M_head(__in));
460 template<bool,
typename... _Types>
461 struct _TupleConstraints
466 template<
typename... _UTypes>
467 static constexpr
bool __is_implicitly_constructible()
469 return __and_<is_constructible<_Types, _UTypes>...,
477 template<
typename... _UTypes>
478 static constexpr
bool __is_explicitly_constructible()
480 return __and_<is_constructible<_Types, _UTypes>...,
481 __not_<__and_<is_convertible<_UTypes, _Types>...>>
485 static constexpr
bool __is_implicitly_default_constructible()
487 return __and_<std::__is_implicitly_default_constructible<_Types>...
491 static constexpr
bool __is_explicitly_default_constructible()
493 return __and_<is_default_constructible<_Types>...,
495 std::__is_implicitly_default_constructible<_Types>...>
502 template<
typename... _Types>
503 struct _TupleConstraints<false, _Types...>
505 template<
typename... _UTypes>
506 static constexpr
bool __is_implicitly_constructible()
509 template<
typename... _UTypes>
510 static constexpr
bool __is_explicitly_constructible()
515 template<
typename... _Elements>
521 using _TCC = _TupleConstraints<_Cond, _Elements...>;
524 template<
bool _Dummy>
525 using _ImplicitDefaultCtor = __enable_if_t<
526 _TCC<_Dummy>::__is_implicitly_default_constructible(),
530 template<
bool _Dummy>
531 using _ExplicitDefaultCtor = __enable_if_t<
532 _TCC<_Dummy>::__is_explicitly_default_constructible(),
536 template<
bool _Cond,
typename... _Args>
537 using _ImplicitCtor = __enable_if_t<
538 _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(),
542 template<
bool _Cond,
typename... _Args>
543 using _ExplicitCtor = __enable_if_t<
544 _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(),
547 template<
typename... _UElements>
549 __enable_if_t<
sizeof...(_UElements) ==
sizeof...(_Elements),
bool>
551 {
return __and_<is_assignable<_Elements&, _UElements>...>::value; }
554 template<
typename... _UElements>
555 static constexpr
bool __nothrow_assignable()
558 __and_<is_nothrow_assignable<_Elements&, _UElements>...>::value;
562 template<
typename... _UElements>
563 static constexpr
bool __nothrow_constructible()
566 __and_<is_nothrow_constructible<_Elements, _UElements>...>::value;
570 template<
typename _Up>
571 static constexpr
bool __valid_args()
573 return sizeof...(_Elements) == 1
578 template<
typename,
typename,
typename... _Tail>
579 static constexpr
bool __valid_args()
580 {
return (
sizeof...(_Tail) + 2) ==
sizeof...(_Elements); }
591 template<
typename _Tuple,
typename =
tuple,
592 typename = __remove_cvref_t<_Tuple>>
598 template<
typename _Tuple,
typename _Tp,
typename _Up>
599 struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Up>>
600 : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>
604 template<
typename _Tuple,
typename _Tp>
605 struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Tp>>
612 template<
typename _Tuple>
613 static constexpr
bool __use_other_ctor()
614 {
return _UseOtherCtor<_Tuple>::value; }
617 template<
typename _Dummy = void,
618 _ImplicitDefaultCtor<is_void<_Dummy>::value> =
true>
624 template<
typename _Dummy = void,
625 _ExplicitDefaultCtor<is_void<_Dummy>::value> =
false>
631 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
632 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
634 tuple(
const _Elements&... __elements)
635 noexcept(__nothrow_constructible<const _Elements&...>())
638 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
639 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
641 tuple(
const _Elements&... __elements)
642 noexcept(__nothrow_constructible<const _Elements&...>())
645 template<
typename... _UElements,
646 bool _Valid = __valid_args<_UElements...>(),
647 _ImplicitCtor<_Valid, _UElements...> =
true>
649 tuple(_UElements&&... __elements)
650 noexcept(__nothrow_constructible<_UElements...>())
651 :
_Inherited(std::forward<_UElements>(__elements)...) { }
653 template<
typename... _UElements,
654 bool _Valid = __valid_args<_UElements...>(),
655 _ExplicitCtor<_Valid, _UElements...> =
false>
657 tuple(_UElements&&... __elements)
658 noexcept(__nothrow_constructible<_UElements...>())
659 :
_Inherited(std::forward<_UElements>(__elements)...) { }
661 constexpr tuple(
const tuple&) =
default;
663 constexpr tuple(tuple&&) =
default;
665 template<
typename... _UElements,
666 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
668 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
671 noexcept(__nothrow_constructible<const _UElements&...>())
672 :
_Inherited(
static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
675 template<
typename... _UElements,
676 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
678 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
681 noexcept(__nothrow_constructible<const _UElements&...>())
682 :
_Inherited(
static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
685 template<
typename... _UElements,
686 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
688 _ImplicitCtor<_Valid, _UElements...> =
true>
691 noexcept(__nothrow_constructible<_UElements...>())
692 :
_Inherited(
static_cast<_Tuple_impl<0, _UElements...
>&&>(__in)) { }
694 template<
typename... _UElements,
695 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
697 _ExplicitCtor<_Valid, _UElements...> =
false>
700 noexcept(__nothrow_constructible<_UElements...>())
701 :
_Inherited(
static_cast<_Tuple_impl<0, _UElements...
>&&>(__in)) { }
705 template<
typename _Alloc,
706 _ImplicitDefaultCtor<is_object<_Alloc>::value> =
true>
711 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
712 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
715 const _Elements&... __elements)
718 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
719 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
723 const _Elements&... __elements)
726 template<
typename _Alloc,
typename... _UElements,
727 bool _Valid = __valid_args<_UElements...>(),
728 _ImplicitCtor<_Valid, _UElements...> =
true>
731 _UElements&&... __elements)
732 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
735 template<
typename _Alloc,
typename... _UElements,
736 bool _Valid = __valid_args<_UElements...>(),
737 _ExplicitCtor<_Valid, _UElements...> =
false>
741 _UElements&&... __elements)
742 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
745 template<
typename _Alloc>
748 :
_Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
750 template<
typename _Alloc>
753 :
_Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
755 template<
typename _Alloc,
typename... _UElements,
756 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
758 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
763 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
766 template<
typename _Alloc,
typename... _UElements,
767 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
769 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
775 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
778 template<
typename _Alloc,
typename... _UElements,
779 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
781 _ImplicitCtor<_Valid, _UElements...> =
true>
786 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
789 template<
typename _Alloc,
typename... _UElements,
790 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
792 _ExplicitCtor<_Valid, _UElements...> =
false>
798 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
805 operator=(
typename conditional<__assignable<const _Elements&...>(),
807 const __nonesuch&>::type __in)
808 noexcept(__nothrow_assignable<const _Elements&...>())
810 this->_M_assign(__in);
816 operator=(
typename conditional<__assignable<_Elements...>(),
818 __nonesuch&&>::type __in)
819 noexcept(__nothrow_assignable<_Elements...>())
825 template<
typename... _UElements>
827 __enable_if_t<__assignable<
const _UElements&...>(), tuple&>
829 noexcept(__nothrow_assignable<const _UElements&...>())
831 this->_M_assign(__in);
835 template<
typename... _UElements>
837 __enable_if_t<__assignable<_UElements...>(), tuple&>
839 noexcept(__nothrow_assignable<_UElements...>())
849 noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value)
850 { _Inherited::_M_swap(__in); }
853 #if __cpp_deduction_guides >= 201606 854 template<
typename... _UTypes>
856 template<
typename _T1,
typename _T2>
858 template<
typename _Alloc,
typename... _UTypes>
860 template<
typename _Alloc,
typename _T1,
typename _T2>
862 template<
typename _Alloc,
typename... _UTypes>
871 void swap(
tuple&) noexcept { }
876 template<
typename _Alloc>
879 template<
typename _Alloc>
886 template<
typename _T1,
typename _T2>
892 template<
bool _Dummy,
typename _U1,
typename _U2>
893 using _ImplicitDefaultCtor = __enable_if_t<
894 _TupleConstraints<_Dummy, _U1, _U2>::
895 __is_implicitly_default_constructible(),
899 template<
bool _Dummy,
typename _U1,
typename _U2>
900 using _ExplicitDefaultCtor = __enable_if_t<
901 _TupleConstraints<_Dummy, _U1, _U2>::
902 __is_explicitly_default_constructible(),
905 template<
bool _Dummy>
906 using _TCC = _TupleConstraints<_Dummy, _T1, _T2>;
909 template<
bool _Cond,
typename _U1,
typename _U2>
910 using _ImplicitCtor = __enable_if_t<
911 _TCC<_Cond>::template __is_implicitly_constructible<_U1, _U2>(),
915 template<
bool _Cond,
typename _U1,
typename _U2>
916 using _ExplicitCtor = __enable_if_t<
917 _TCC<_Cond>::template __is_explicitly_constructible<_U1, _U2>(),
920 template<
typename _U1,
typename _U2>
921 static constexpr
bool __assignable()
923 return __and_<is_assignable<_T1&, _U1>,
927 template<
typename _U1,
typename _U2>
928 static constexpr
bool __nothrow_assignable()
930 return __and_<is_nothrow_assignable<_T1&, _U1>,
934 template<
typename _U1,
typename _U2>
935 static constexpr
bool __nothrow_constructible()
937 return __and_<is_nothrow_constructible<_T1, _U1>,
941 static constexpr
bool __nothrow_default_constructible()
943 return __and_<is_nothrow_default_constructible<_T1>,
947 template<
typename _U1>
948 static constexpr
bool __is_alloc_arg()
952 template<
bool _Dummy =
true,
953 _ImplicitDefaultCtor<_Dummy, _T1, _T2> =
true>
956 noexcept(__nothrow_default_constructible())
959 template<
bool _Dummy =
true,
960 _ExplicitDefaultCtor<_Dummy, _T1, _T2> =
false>
963 noexcept(__nothrow_default_constructible())
966 template<
bool _Dummy =
true,
967 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
969 tuple(
const _T1& __a1,
const _T2& __a2)
970 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
971 : _Inherited(__a1, __a2) { }
973 template<
bool _Dummy =
true,
974 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
976 tuple(
const _T1& __a1,
const _T2& __a2)
977 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
978 : _Inherited(__a1, __a2) { }
980 template<
typename _U1,
typename _U2,
981 _ImplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
true>
983 tuple(_U1&& __a1, _U2&& __a2)
984 noexcept(__nothrow_constructible<_U1, _U2>())
985 : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
987 template<
typename _U1,
typename _U2,
988 _ExplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
false>
990 tuple(_U1&& __a1, _U2&& __a2)
991 noexcept(__nothrow_constructible<_U1, _U2>())
992 : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
998 template<
typename _U1,
typename _U2,
999 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1002 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1005 template<
typename _U1,
typename _U2,
1006 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1009 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1012 template<
typename _U1,
typename _U2,
1013 _ImplicitCtor<true, _U1, _U2> =
true>
1016 noexcept(__nothrow_constructible<_U1, _U2>())
1019 template<
typename _U1,
typename _U2,
1020 _ExplicitCtor<true, _U1, _U2> =
false>
1023 noexcept(__nothrow_constructible<_U1, _U2>())
1026 template<
typename _U1,
typename _U2,
1027 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1030 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1033 template<
typename _U1,
typename _U2,
1034 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1037 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1040 template<
typename _U1,
typename _U2,
1041 _ImplicitCtor<true, _U1, _U2> =
true>
1044 noexcept(__nothrow_constructible<_U1, _U2>())
1045 : _Inherited(std::forward<_U1>(__in.
first),
1046 std::forward<_U2>(__in.
second)) { }
1048 template<
typename _U1,
typename _U2,
1049 _ExplicitCtor<true, _U1, _U2> =
false>
1052 noexcept(__nothrow_constructible<_U1, _U2>())
1053 : _Inherited(std::forward<_U1>(__in.
first),
1054 std::forward<_U2>(__in.
second)) { }
1058 template<
typename _Alloc,
1059 _ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> =
true>
1060 _GLIBCXX20_CONSTEXPR
1062 : _Inherited(__tag, __a) { }
1064 template<
typename _Alloc,
bool _Dummy =
true,
1065 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1066 _GLIBCXX20_CONSTEXPR
1068 const _T1& __a1,
const _T2& __a2)
1069 : _Inherited(__tag, __a, __a1, __a2) { }
1071 template<
typename _Alloc,
bool _Dummy =
true,
1072 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1074 _GLIBCXX20_CONSTEXPR
1076 const _T1& __a1,
const _T2& __a2)
1077 : _Inherited(__tag, __a, __a1, __a2) { }
1079 template<
typename _Alloc,
typename _U1,
typename _U2,
1080 _ImplicitCtor<true, _U1, _U2> =
true>
1081 _GLIBCXX20_CONSTEXPR
1082 tuple(
allocator_arg_t __tag,
const _Alloc& __a, _U1&& __a1, _U2&& __a2)
1083 : _Inherited(__tag, __a, std::forward<_U1>(__a1),
1084 std::forward<_U2>(__a2)) { }
1086 template<
typename _Alloc,
typename _U1,
typename _U2,
1087 _ExplicitCtor<true, _U1, _U2> =
false>
1089 _GLIBCXX20_CONSTEXPR
1091 _U1&& __a1, _U2&& __a2)
1092 : _Inherited(__tag, __a, std::forward<_U1>(__a1),
1093 std::forward<_U2>(__a2)) { }
1095 template<
typename _Alloc>
1096 _GLIBCXX20_CONSTEXPR
1098 : _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
1100 template<
typename _Alloc>
1101 _GLIBCXX20_CONSTEXPR
1103 : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
1105 template<
typename _Alloc,
typename _U1,
typename _U2,
1106 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1107 _GLIBCXX20_CONSTEXPR
1110 : _Inherited(__tag, __a,
1114 template<
typename _Alloc,
typename _U1,
typename _U2,
1115 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1117 _GLIBCXX20_CONSTEXPR
1120 : _Inherited(__tag, __a,
1124 template<
typename _Alloc,
typename _U1,
typename _U2,
1125 _ImplicitCtor<true, _U1, _U2> =
true>
1126 _GLIBCXX20_CONSTEXPR
1131 template<
typename _Alloc,
typename _U1,
typename _U2,
1132 _ExplicitCtor<true, _U1, _U2> =
false>
1134 _GLIBCXX20_CONSTEXPR
1139 template<
typename _Alloc,
typename _U1,
typename _U2,
1140 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1141 _GLIBCXX20_CONSTEXPR
1144 : _Inherited(__tag, __a, __in.
first, __in.
second) { }
1146 template<
typename _Alloc,
typename _U1,
typename _U2,
1147 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1149 _GLIBCXX20_CONSTEXPR
1152 : _Inherited(__tag, __a, __in.
first, __in.
second) { }
1154 template<
typename _Alloc,
typename _U1,
typename _U2,
1155 _ImplicitCtor<true, _U1, _U2> =
true>
1156 _GLIBCXX20_CONSTEXPR
1158 : _Inherited(__tag, __a, std::forward<_U1>(__in.
first),
1159 std::forward<_U2>(__in.
second)) { }
1161 template<
typename _Alloc,
typename _U1,
typename _U2,
1162 _ExplicitCtor<true, _U1, _U2> =
false>
1164 _GLIBCXX20_CONSTEXPR
1166 : _Inherited(__tag, __a, std::forward<_U1>(__in.
first),
1167 std::forward<_U2>(__in.
second)) { }
1171 _GLIBCXX20_CONSTEXPR
1173 operator=(
typename conditional<__assignable<const _T1&, const _T2&>(),
1175 const __nonesuch&>::type __in)
1176 noexcept(__nothrow_assignable<const _T1&, const _T2&>())
1178 this->_M_assign(__in);
1182 _GLIBCXX20_CONSTEXPR
1184 operator=(
typename conditional<__assignable<_T1, _T2>(),
1186 __nonesuch&&>::type __in)
1187 noexcept(__nothrow_assignable<_T1, _T2>())
1193 template<
typename _U1,
typename _U2>
1194 _GLIBCXX20_CONSTEXPR
1195 __enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&>
1197 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1199 this->_M_assign(__in);
1203 template<
typename _U1,
typename _U2>
1204 _GLIBCXX20_CONSTEXPR
1205 __enable_if_t<__assignable<_U1, _U2>(), tuple&>
1207 noexcept(__nothrow_assignable<_U1, _U2>())
1213 template<
typename _U1,
typename _U2>
1214 _GLIBCXX20_CONSTEXPR
1215 __enable_if_t<__assignable<const _U1&, const _U2&>(), tuple&>
1217 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1219 this->_M_head(*
this) = __in.
first;
1220 this->_M_tail(*this)._M_head(*
this) = __in.
second;
1224 template<
typename _U1,
typename _U2>
1225 _GLIBCXX20_CONSTEXPR
1226 __enable_if_t<__assignable<_U1, _U2>(), tuple&>
1228 noexcept(__nothrow_assignable<_U1, _U2>())
1230 this->_M_head(*
this) = std::forward<_U1>(__in.
first);
1231 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.
second);
1235 _GLIBCXX20_CONSTEXPR
1238 noexcept(__and_<__is_nothrow_swappable<_T1>,
1239 __is_nothrow_swappable<_T2>>::value)
1240 { _Inherited::_M_swap(__in); }
1245 template<
typename... _Elements>
1249 #if __cplusplus > 201402L 1250 template <
typename _Tp>
1258 template<std::size_t __i,
typename _Head,
typename... _Tail>
1265 template<
typename _Head,
typename... _Tail>
1274 template<
size_t __i>
1278 "tuple index is in range");
1281 template<std::size_t __i,
typename _Head,
typename... _Tail>
1286 template<std::size_t __i,
typename _Head,
typename... _Tail>
1287 constexpr
const _Head&
1292 template<std::size_t __i,
typename... _Elements>
1293 constexpr __tuple_element_t<__i,
tuple<_Elements...>>&
1295 {
return std::__get_helper<__i>(__t); }
1298 template<std::size_t __i,
typename... _Elements>
1299 constexpr
const __tuple_element_t<__i,
tuple<_Elements...>>&
1300 get(
const tuple<_Elements...>& __t) noexcept
1301 {
return std::__get_helper<__i>(__t); }
1304 template<std::size_t __i,
typename... _Elements>
1305 constexpr __tuple_element_t<__i,
tuple<_Elements...>>&&
1308 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1309 return std::forward<__element_type&&>(std::get<__i>(__t));
1313 template<std::size_t __i,
typename... _Elements>
1314 constexpr
const __tuple_element_t<__i,
tuple<_Elements...>>&&
1315 get(
const tuple<_Elements...>&& __t) noexcept
1317 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1318 return std::forward<const __element_type&&>(std::get<__i>(__t));
1321 #if __cplusplus >= 201402L 1323 #define __cpp_lib_tuples_by_type 201304 1325 template<
typename _Head,
size_t __i,
typename... _Tail>
1330 template<
typename _Head,
size_t __i,
typename... _Tail>
1331 constexpr
const _Head&
1336 template <
typename _Tp,
typename... _Types>
1339 {
return std::__get_helper2<_Tp>(__t); }
1342 template <
typename _Tp,
typename... _Types>
1345 {
return std::forward<_Tp&&>(std::__get_helper2<_Tp>(__t)); }
1348 template <
typename _Tp,
typename... _Types>
1349 constexpr
const _Tp&
1350 get(
const tuple<_Types...>& __t) noexcept
1351 {
return std::__get_helper2<_Tp>(__t); }
1355 template <
typename _Tp,
typename... _Types>
1356 constexpr
const _Tp&&
1357 get(
const tuple<_Types...>&& __t) noexcept
1358 {
return std::forward<const _Tp&&>(std::__get_helper2<_Tp>(__t)); }
1362 template<
typename _Tp,
typename _Up,
size_t __i,
size_t __size>
1363 struct __tuple_compare
1365 static constexpr
bool 1366 __eq(
const _Tp& __t,
const _Up& __u)
1368 return bool(std::get<__i>(__t) == std::get<__i>(__u))
1369 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u);
1372 static constexpr
bool 1373 __less(
const _Tp& __t,
const _Up& __u)
1375 return bool(std::get<__i>(__t) < std::get<__i>(__u))
1376 || (!bool(std::get<__i>(__u) < std::get<__i>(__t))
1377 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u));
1381 template<
typename _Tp,
typename _Up,
size_t __size>
1382 struct __tuple_compare<_Tp, _Up, __size, __size>
1384 static constexpr
bool 1385 __eq(
const _Tp&,
const _Up&) {
return true; }
1387 static constexpr
bool 1388 __less(
const _Tp&,
const _Up&) {
return false; }
1391 template<
typename... _TElements,
typename... _UElements>
1396 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1397 "tuple objects can only be compared if they have equal sizes.");
1398 using __compare = __tuple_compare<
tuple<_TElements...>,
1399 tuple<_UElements...>,
1400 0,
sizeof...(_TElements)>;
1401 return __compare::__eq(__t, __u);
1404 #if __cpp_lib_three_way_comparison 1405 template<
typename _Cat,
typename _Tp,
typename _Up>
1408 {
return _Cat::equivalent; }
1410 template<
typename _Cat,
typename _Tp,
typename _Up,
1411 size_t _Idx0,
size_t... _Idxs>
1413 __tuple_cmp(
const _Tp& __t,
const _Up& __u,
1417 = __detail::__synth3way(std::get<_Idx0>(__t), std::get<_Idx0>(__u));
1420 return std::__tuple_cmp<_Cat>(__t, __u,
index_sequence<_Idxs...>());
1423 template<
typename... _Tps,
typename... _Ups>
1425 common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>
1429 = common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>;
1433 template<
typename... _TElements,
typename... _UElements>
1438 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1439 "tuple objects can only be compared if they have equal sizes.");
1440 using __compare = __tuple_compare<
tuple<_TElements...>,
1441 tuple<_UElements...>,
1442 0,
sizeof...(_TElements)>;
1443 return __compare::__less(__t, __u);
1446 template<
typename... _TElements,
typename... _UElements>
1450 {
return !(__t == __u); }
1452 template<
typename... _TElements,
typename... _UElements>
1456 {
return __u < __t; }
1458 template<
typename... _TElements,
typename... _UElements>
1462 {
return !(__u < __t); }
1464 template<
typename... _TElements,
typename... _UElements>
1468 {
return !(__t < __u); }
1469 #endif // three_way_comparison 1472 template<
typename... _Elements>
1474 make_tuple(_Elements&&... __args)
1478 return __result_type(std::forward<_Elements>(__args)...);
1484 template<
typename... _Elements>
1485 constexpr
tuple<_Elements&&...>
1487 {
return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
1489 template<
size_t,
typename,
typename,
size_t>
1490 struct __make_tuple_impl;
1492 template<
size_t _Idx,
typename _Tuple,
typename... _Tp,
size_t _Nm>
1493 struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
1494 : __make_tuple_impl<_Idx + 1,
1495 tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
1499 template<std::size_t _Nm,
typename _Tuple,
typename... _Tp>
1500 struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
1502 typedef tuple<_Tp...> __type;
1505 template<
typename _Tuple>
1506 struct __do_make_tuple
1507 : __make_tuple_impl<0, tuple<>, _Tuple, std::tuple_size<_Tuple>::value>
1511 template<
typename _Tuple>
1513 :
public __do_make_tuple<__remove_cvref_t<_Tuple>>
1517 template<
typename...>
1518 struct __combine_tuples;
1521 struct __combine_tuples<>
1526 template<
typename... _Ts>
1527 struct __combine_tuples<tuple<_Ts...>>
1529 typedef tuple<_Ts...> __type;
1532 template<
typename... _T1s,
typename... _T2s,
typename... _Rem>
1533 struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
1535 typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
1536 _Rem...>::__type __type;
1540 template<
typename... _Tpls>
1541 struct __tuple_cat_result
1543 typedef typename __combine_tuples
1544 <
typename __make_tuple<_Tpls>::__type...>::__type __type;
1549 template<
typename...>
1550 struct __make_1st_indices;
1553 struct __make_1st_indices<>
1555 typedef std::_Index_tuple<> __type;
1558 template<
typename _Tp,
typename... _Tpls>
1559 struct __make_1st_indices<_Tp, _Tpls...>
1562 typename std::remove_reference<_Tp>::type>::value>::__type __type;
1568 template<
typename _Ret,
typename _Indices,
typename... _Tpls>
1569 struct __tuple_concater;
1571 template<
typename _Ret, std::size_t... _Is,
typename _Tp,
typename... _Tpls>
1572 struct __tuple_concater<_Ret, std::_Index_tuple<_Is...>, _Tp, _Tpls...>
1574 template<
typename... _Us>
1575 static constexpr _Ret
1576 _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
1578 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1579 typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
1580 return __next::_S_do(std::forward<_Tpls>(__tps)...,
1581 std::forward<_Us>(__us)...,
1582 std::get<_Is>(std::forward<_Tp>(__tp))...);
1586 template<
typename _Ret>
1587 struct __tuple_concater<_Ret, std::_Index_tuple<>>
1589 template<
typename... _Us>
1590 static constexpr _Ret
1591 _S_do(_Us&&... __us)
1593 return _Ret(std::forward<_Us>(__us)...);
1598 template<
typename... _Tpls,
typename =
typename 1602 ->
typename __tuple_cat_result<_Tpls...>::__type
1604 typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
1605 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1606 typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
1607 return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
1613 template<
typename... _Elements>
1614 constexpr tuple<_Elements&...>
1615 tie(_Elements&... __args) noexcept
1616 {
return tuple<_Elements&...>(__args...); }
1619 template<
typename... _Elements>
1620 _GLIBCXX20_CONSTEXPR
1622 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 1630 noexcept(noexcept(__x.swap(__y)))
1633 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 1634 template<
typename... _Elements>
1635 _GLIBCXX20_CONSTEXPR
1644 struct _Swallow_assign
1647 _GLIBCXX14_CONSTEXPR
const _Swallow_assign&
1648 operator=(
const _Tp&)
const 1654 _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
1657 template<
typename... _Types,
typename _Alloc>
1669 template<
class _T1,
class _T2>
1670 template<
typename... _Args1,
typename... _Args2>
1671 _GLIBCXX20_CONSTEXPR
1676 :
pair(__first, __second,
1677 typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
1678 typename _Build_index_tuple<sizeof...(_Args2)>::__type())
1681 template<
class _T1,
class _T2>
1682 template<
typename... _Args1, std::size_t... _Indexes1,
1683 typename... _Args2, std::size_t... _Indexes2>
1684 _GLIBCXX20_CONSTEXPR
inline 1687 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
1688 : first(std::forward<_Args1>(std::get<_Indexes1>(__tuple1))...),
1689 second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
1692 #if __cplusplus >= 201703L 1698 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _Tuple>
1699 inline constexpr
bool __unpack_std_tuple =
false;
1701 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1702 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>>
1703 = _Trait<_Tp, _Up...>::value;
1705 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1706 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp, tuple<_Up...>&>
1707 = _Trait<_Tp, _Up&...>::value;
1709 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1710 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>>
1711 = _Trait<_Tp,
const _Up...>::value;
1713 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1714 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>&>
1715 = _Trait<_Tp,
const _Up&...>::value;
1717 # define __cpp_lib_apply 201603 1719 template <
typename _Fn,
typename _Tuple,
size_t... _Idx>
1720 constexpr decltype(
auto)
1724 std::get<_Idx>(std::forward<_Tuple>(__t))...);
1727 template <
typename _Fn,
typename _Tuple>
1728 constexpr decltype(
auto)
1729 apply(_Fn&& __f, _Tuple&& __t)
1730 noexcept(__unpack_std_tuple<is_nothrow_invocable, _Fn, _Tuple>)
1734 return std::__apply_impl(std::forward<_Fn>(__f),
1735 std::forward<_Tuple>(__t),
1739 #define __cpp_lib_make_from_tuple 201606 1741 template <
typename _Tp,
typename _Tuple,
size_t... _Idx>
1744 {
return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); }
1746 template <
typename _Tp,
typename _Tuple>
1748 make_from_tuple(_Tuple&& __t)
1749 noexcept(__unpack_std_tuple<is_nothrow_constructible, _Tp, _Tuple>)
1751 return __make_from_tuple_impl<_Tp>(
1752 std::forward<_Tuple>(__t),
1759 _GLIBCXX_END_NAMESPACE_VERSION
1764 #endif // _GLIBCXX_TUPLE constexpr tuple< _Elements &&... > forward_as_tuple(_Elements &&... __args) noexcept
std::forward_as_tuple
Declare uses_allocator so it can be specialized in <queue> etc.
_T1 first
The first member.
Primary class template, tuple.
is_nothrow_move_constructible
is_nothrow_default_constructible
typename remove_reference< _Tp >::type remove_reference_t
Alias template for remove_reference.
constexpr tuple< _Elements &... > tie(_Elements &... __args) noexcept
tie
constexpr auto tuple_cat(_Tpls &&... __tpls) -> typename __tuple_cat_result< _Tpls... >::__type
tuple_cat
Define a member typedef type to one of two argument types.
Define a member typedef type only if a boolean constant is true.
constexpr __invoke_result< _Callable, _Args... >::type __invoke(_Callable &&__fn, _Args &&... __args) noexcept(__is_nothrow_invocable< _Callable, _Args... >::value)
Invoke a callable object.
Class template integer_sequence.
_T2 second
The second member.
ISO C++ entities toplevel namespace is std.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
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.
Struct holding two objects of arbitrary type.
Partial specialization, 2-element tuple. Includes construction and assignment from a pair...
Tag type for piecewise construction of std::pair objects.