29 #ifndef _GLIBCXX_TUPLE 30 #define _GLIBCXX_TUPLE 1 32 #pragma GCC system_header 34 #if __cplusplus < 201103L 40 #include <bits/uses_allocator.h> 43 namespace std _GLIBCXX_VISIBILITY(default)
45 _GLIBCXX_BEGIN_NAMESPACE_VERSION
52 template<
typename... _Elements>
55 template<
typename _Tp>
56 struct __is_empty_non_tuple :
is_empty<_Tp> { };
59 template<
typename _El0,
typename... _El>
63 template<
typename _Tp>
64 using __empty_not_final
66 __is_empty_non_tuple<_Tp>>::type;
68 template<std::size_t _Idx,
typename _Head,
69 bool = __empty_not_final<_Head>::value>
72 template<std::
size_t _Idx,
typename _Head>
73 struct _Head_base<_Idx, _Head, true>
76 constexpr _Head_base()
79 constexpr _Head_base(
const _Head& __h)
82 constexpr _Head_base(
const _Head_base&) =
default;
83 constexpr _Head_base(_Head_base&&) =
default;
85 template<
typename _UHead>
86 constexpr _Head_base(_UHead&& __h)
92 template<
typename _Alloc>
94 : _Head(allocator_arg, *__a._M_a) { }
96 template<
typename _Alloc>
98 : _Head(*__a._M_a) { }
100 template<
typename _UHead>
101 _Head_base(__uses_alloc0, _UHead&& __uhead)
104 template<
typename _Alloc,
typename _UHead>
105 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
106 : _Head(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead)) { }
108 template<
typename _Alloc,
typename _UHead>
109 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
110 : _Head(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
112 static constexpr _Head&
113 _M_head(_Head_base& __b) noexcept {
return __b; }
115 static constexpr
const _Head&
116 _M_head(
const _Head_base& __b) noexcept {
return __b; }
119 template<std::
size_t _Idx,
typename _Head>
120 struct _Head_base<_Idx, _Head, false>
122 constexpr _Head_base()
125 constexpr _Head_base(
const _Head& __h)
126 : _M_head_impl(__h) { }
128 constexpr _Head_base(
const _Head_base&) =
default;
129 constexpr _Head_base(_Head_base&&) =
default;
131 template<
typename _UHead>
132 constexpr _Head_base(_UHead&& __h)
138 template<
typename _Alloc>
140 : _M_head_impl(allocator_arg, *__a._M_a) { }
142 template<
typename _Alloc>
144 : _M_head_impl(*__a._M_a) { }
146 template<
typename _UHead>
147 _Head_base(__uses_alloc0, _UHead&& __uhead)
148 : _M_head_impl(
std::
forward<_UHead>(__uhead)) { }
150 template<
typename _Alloc,
typename _UHead>
151 _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
152 : _M_head_impl(allocator_arg, *__a._M_a,
std::
forward<_UHead>(__uhead))
155 template<
typename _Alloc,
typename _UHead>
156 _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
157 : _M_head_impl(
std::
forward<_UHead>(__uhead), *__a._M_a) { }
159 static constexpr _Head&
160 _M_head(_Head_base& __b) noexcept {
return __b._M_head_impl; }
162 static constexpr
const _Head&
163 _M_head(
const _Head_base& __b) noexcept {
return __b._M_head_impl; }
176 template<std::size_t _Idx,
typename... _Elements>
184 template<std::size_t _Idx,
typename _Head,
typename... _Tail>
187 private _Head_base<_Idx, _Head>
189 template<std::size_t,
typename...>
friend class _Tuple_impl;
192 typedef _Head_base<_Idx, _Head> _Base;
194 static constexpr _Head&
195 _M_head(
_Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
197 static constexpr
const _Head&
198 _M_head(
const _Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
204 _M_tail(
const _Tuple_impl& __t) noexcept {
return __t; }
210 constexpr _Tuple_impl(
const _Head& __head,
const _Tail&... __tail)
213 template<
typename _UHead,
typename... _UTail,
typename =
typename 214 enable_if<
sizeof...(_Tail) ==
sizeof...(_UTail)>::type>
216 constexpr _Tuple_impl(_UHead&& __head, _UTail&&... __tail)
217 :
_Inherited(std::forward<_UTail>(__tail)...),
218 _Base(std::forward<_UHead>(__head)) { }
220 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
223 _Tuple_impl(_Tuple_impl&& __in)
227 _Base(std::forward<_Head>(_M_head(__in))) { }
229 template<
typename... _UElements>
234 template<
typename _UHead,
typename... _UTails>
238 _Base(std::forward<_UHead>
241 template<
typename _Alloc>
244 _Base(__tag, __use_alloc<_Head>(__a)) { }
246 template<
typename _Alloc>
248 const _Head& __head,
const _Tail&... __tail)
250 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
252 template<
typename _Alloc,
typename _UHead,
typename... _UTail,
253 typename =
typename enable_if<
sizeof...(_Tail)
254 ==
sizeof...(_UTail)>::type>
256 _UHead&& __head, _UTail&&... __tail)
257 :
_Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
258 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
259 std::forward<_UHead>(__head)) { }
261 template<
typename _Alloc>
263 const _Tuple_impl& __in)
265 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
267 template<
typename _Alloc>
270 :
_Inherited(__tag, __a, std::move(_M_tail(__in))),
271 _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
272 std::forward<_Head>(_M_head(__in))) { }
274 template<
typename _Alloc,
typename... _UElements>
279 _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
282 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
287 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
292 operator=(
const _Tuple_impl& __in)
294 _M_head(*
this) = _M_head(__in);
295 _M_tail(*
this) = _M_tail(__in);
300 operator=(_Tuple_impl&& __in)
304 _M_head(*
this) = std::forward<_Head>(_M_head(__in));
305 _M_tail(*
this) = std::move(_M_tail(__in));
309 template<
typename... _UElements>
318 template<
typename _UHead,
typename... _UTails>
322 _M_head(*
this) = std::forward<_UHead>
324 _M_tail(*
this) = std::move
331 _M_swap(_Tuple_impl& __in)
332 noexcept(__is_nothrow_swappable<_Head>::value
333 && noexcept(_M_tail(__in)._M_swap(_M_tail(__in))))
336 swap(_M_head(*
this), _M_head(__in));
337 _Inherited::_M_swap(_M_tail(__in));
342 template<std::
size_t _Idx,
typename _Head>
344 :
private _Head_base<_Idx, _Head>
346 template<std::size_t,
typename...>
friend class _Tuple_impl;
348 typedef _Head_base<_Idx, _Head> _Base;
350 static constexpr _Head&
351 _M_head(
_Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
353 static constexpr
const _Head&
354 _M_head(
const _Tuple_impl& __t) noexcept {
return _Base::_M_head(__t); }
360 constexpr _Tuple_impl(
const _Head& __head)
363 template<
typename _UHead>
365 constexpr _Tuple_impl(_UHead&& __head)
366 : _Base(std::forward<_UHead>(__head)) { }
368 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
371 _Tuple_impl(_Tuple_impl&& __in)
373 : _Base(std::forward<_Head>(_M_head(__in))) { }
375 template<
typename _UHead>
379 template<
typename _UHead>
384 template<
typename _Alloc>
386 : _Base(__tag, __use_alloc<_Head>(__a)) { }
388 template<
typename _Alloc>
391 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
393 template<
typename _Alloc,
typename _UHead>
396 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
397 std::forward<_UHead>(__head)) { }
399 template<
typename _Alloc>
401 const _Tuple_impl& __in)
402 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
404 template<
typename _Alloc>
407 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
408 std::forward<_Head>(_M_head(__in))) { }
410 template<
typename _Alloc,
typename _UHead>
413 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
416 template<
typename _Alloc,
typename _UHead>
419 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
424 operator=(
const _Tuple_impl& __in)
426 _M_head(*
this) = _M_head(__in);
431 operator=(_Tuple_impl&& __in)
434 _M_head(*
this) = std::forward<_Head>(_M_head(__in));
438 template<
typename _UHead>
446 template<
typename _UHead>
457 _M_swap(_Tuple_impl& __in)
458 noexcept(__is_nothrow_swappable<_Head>::value)
461 swap(_M_head(*
this), _M_head(__in));
467 template<bool,
typename... _Elements>
470 template<
typename... _UElements>
471 static constexpr
bool _ConstructibleTuple()
473 return __and_<is_constructible<_Elements, const _UElements&>...>::value;
476 template<
typename... _UElements>
477 static constexpr
bool _ImplicitlyConvertibleTuple()
479 return __and_<is_convertible<const _UElements&, _Elements>...>::value;
482 template<
typename... _UElements>
483 static constexpr
bool _MoveConstructibleTuple()
485 return __and_<is_constructible<_Elements, _UElements&&>...>::value;
488 template<
typename... _UElements>
489 static constexpr
bool _ImplicitlyMoveConvertibleTuple()
491 return __and_<is_convertible<_UElements&&, _Elements>...>::value;
494 template<
typename _SrcTuple>
495 static constexpr
bool _NonNestedTuple()
499 typename remove_reference<_SrcTuple>::type
505 template<
typename... _UElements>
506 static constexpr
bool _NotSameTuple()
515 template<
typename... _Elements>
516 struct _TC<false, _Elements...>
518 template<
typename... _UElements>
519 static constexpr
bool _ConstructibleTuple()
524 template<
typename... _UElements>
525 static constexpr
bool _ImplicitlyConvertibleTuple()
530 template<
typename... _UElements>
531 static constexpr
bool _MoveConstructibleTuple()
536 template<
typename... _UElements>
537 static constexpr
bool _ImplicitlyMoveConvertibleTuple()
542 template<
typename... _UElements>
543 static constexpr
bool _NonNestedTuple()
547 template<
typename... _UElements>
548 static constexpr
bool _NotSameTuple()
555 template<
typename... _Elements>
562 template<
typename _Dummy>
565 static constexpr
bool _DefaultConstructibleTuple()
567 return __and_<is_default_constructible<_Elements>...>::value;
569 static constexpr
bool _ImplicitlyDefaultConstructibleTuple()
571 return __and_<__is_implicitly_default_constructible<_Elements>...>
577 template<
typename _Dummy = void,
584 template<
typename _Dummy = void,
589 _ImplicitlyDefaultConstructibleTuple(),
591 explicit constexpr tuple()
596 template<
typename _Dummy>
using _TCC =
597 _TC<is_same<_Dummy, void>::value,
600 template<
typename _Dummy = void,
602 _TCC<_Dummy>::template
603 _ConstructibleTuple<_Elements...>()
604 && _TCC<_Dummy>::template
605 _ImplicitlyConvertibleTuple<_Elements...>()
606 && (
sizeof...(_Elements) >= 1),
608 constexpr tuple(
const _Elements&... __elements)
611 template<
typename _Dummy = void,
613 _TCC<_Dummy>::template
614 _ConstructibleTuple<_Elements...>()
615 && !_TCC<_Dummy>::template
616 _ImplicitlyConvertibleTuple<_Elements...>()
617 && (
sizeof...(_Elements) >= 1),
619 explicit constexpr tuple(
const _Elements&... __elements)
624 template<
typename... _UElements>
using _TMC =
625 _TC<(
sizeof...(_Elements) ==
sizeof...(_UElements))
626 && (_TC<(
sizeof...(_UElements)==1), _Elements...>::
627 template _NotSameTuple<_UElements...>()),
632 template<typename... _UElements>
using _TMCT =
633 _TC<(
sizeof...(_Elements) ==
sizeof...(_UElements))
634 && !
is_same<tuple<_Elements...>,
635 tuple<_UElements...>>::value,
638 template<
typename... _UElements,
typename 640 _TMC<_UElements...>::template
641 _MoveConstructibleTuple<_UElements...>()
642 && _TMC<_UElements...>::template
643 _ImplicitlyMoveConvertibleTuple<_UElements...>()
644 && (
sizeof...(_Elements) >= 1),
646 constexpr tuple(_UElements&&... __elements)
647 :
_Inherited(std::forward<_UElements>(__elements)...) { }
649 template<
typename... _UElements,
typename 651 _TMC<_UElements...>::template
652 _MoveConstructibleTuple<_UElements...>()
653 && !_TMC<_UElements...>::template
654 _ImplicitlyMoveConvertibleTuple<_UElements...>()
655 && (
sizeof...(_Elements) >= 1),
657 explicit constexpr tuple(_UElements&&... __elements)
658 :
_Inherited(std::forward<_UElements>(__elements)...) { }
660 constexpr tuple(
const tuple&) =
default;
662 constexpr tuple(tuple&&) =
default;
666 template<
typename _Dummy>
using _TNTC =
667 _TC<is_same<_Dummy, void>::value &&
sizeof...(_Elements) == 1,
670 template<
typename... _UElements,
typename _Dummy =
void,
typename 672 _ConstructibleTuple<_UElements...>()
673 && _TMCT<_UElements...>::template
674 _ImplicitlyConvertibleTuple<_UElements...>()
675 && _TNTC<_Dummy>::template
679 :
_Inherited(
static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
682 template<
typename... _UElements,
typename _Dummy = void,
typename 684 _ConstructibleTuple<_UElements...>()
685 && !_TMCT<_UElements...>::template
686 _ImplicitlyConvertibleTuple<_UElements...>()
687 && _TNTC<_Dummy>::template
688 _NonNestedTuple<
const tuple<_UElements...>&>(),
691 :
_Inherited(
static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
694 template<
typename... _UElements,
typename _Dummy = void,
typename 696 _MoveConstructibleTuple<_UElements...>()
697 && _TMCT<_UElements...>::template
698 _ImplicitlyMoveConvertibleTuple<_UElements...>()
699 && _TNTC<_Dummy>::template
700 _NonNestedTuple<tuple<_UElements...>&&>(),
703 :
_Inherited(
static_cast<_Tuple_impl<0, _UElements...
>&&>(__in)) { }
705 template<
typename... _UElements,
typename _Dummy = void,
typename 707 _MoveConstructibleTuple<_UElements...>()
708 && !_TMCT<_UElements...>::template
709 _ImplicitlyMoveConvertibleTuple<_UElements...>()
710 && _TNTC<_Dummy>::template
711 _NonNestedTuple<tuple<_UElements...>&&>(),
714 :
_Inherited(
static_cast<_Tuple_impl<0, _UElements...
>&&>(__in)) { }
718 template<
typename _Alloc>
722 template<
typename _Alloc,
typename _Dummy = void,
724 _TCC<_Dummy>::template
725 _ConstructibleTuple<_Elements...>()
726 && _TCC<_Dummy>::template
727 _ImplicitlyConvertibleTuple<_Elements...>(),
730 const _Elements&... __elements)
733 template<
typename _Alloc,
typename _Dummy = void,
735 _TCC<_Dummy>::template
736 _ConstructibleTuple<_Elements...>()
737 && !_TCC<_Dummy>::template
738 _ImplicitlyConvertibleTuple<_Elements...>(),
741 const _Elements&... __elements)
744 template<
typename _Alloc,
typename... _UElements,
typename 746 _MoveConstructibleTuple<_UElements...>()
747 && _TMC<_UElements...>::template
748 _ImplicitlyMoveConvertibleTuple<_UElements...>(),
751 _UElements&&... __elements)
752 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
755 template<
typename _Alloc,
typename... _UElements,
typename 757 _MoveConstructibleTuple<_UElements...>()
758 && !_TMC<_UElements...>::template
759 _ImplicitlyMoveConvertibleTuple<_UElements...>(),
762 _UElements&&... __elements)
763 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
766 template<
typename _Alloc>
768 :
_Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
770 template<
typename _Alloc>
772 :
_Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
774 template<
typename _Alloc,
typename _Dummy = void,
775 typename... _UElements,
typename 777 _ConstructibleTuple<_UElements...>()
778 && _TMCT<_UElements...>::template
779 _ImplicitlyConvertibleTuple<_UElements...>()
780 && _TNTC<_Dummy>::template
781 _NonNestedTuple<tuple<_UElements...>&&>(),
786 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
789 template<
typename _Alloc,
typename _Dummy = void,
790 typename... _UElements,
typename 792 _ConstructibleTuple<_UElements...>()
793 && !_TMCT<_UElements...>::template
794 _ImplicitlyConvertibleTuple<_UElements...>()
795 && _TNTC<_Dummy>::template
796 _NonNestedTuple<tuple<_UElements...>&&>(),
801 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
804 template<
typename _Alloc,
typename _Dummy = void,
805 typename... _UElements,
typename 807 _MoveConstructibleTuple<_UElements...>()
808 && _TMCT<_UElements...>::template
809 _ImplicitlyMoveConvertibleTuple<_UElements...>()
810 && _TNTC<_Dummy>::template
811 _NonNestedTuple<tuple<_UElements...>&&>(),
816 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
819 template<
typename _Alloc,
typename _Dummy = void,
820 typename... _UElements,
typename 822 _MoveConstructibleTuple<_UElements...>()
823 && !_TMCT<_UElements...>::template
824 _ImplicitlyMoveConvertibleTuple<_UElements...>()
825 && _TNTC<_Dummy>::template
826 _NonNestedTuple<tuple<_UElements...>&&>(),
831 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
835 operator=(
const tuple& __in)
842 operator=(tuple&& __in)
845 static_cast<_Inherited&
>(*this) = std::move(__in);
849 template<
typename... _UElements>
852 ==
sizeof...(_Elements), tuple&>::type
859 template<
typename... _UElements>
862 ==
sizeof...(_Elements), tuple&>::type
865 static_cast<_Inherited&
>(*this) = std::move(__in);
871 noexcept(noexcept(__in._M_swap(__in)))
872 { _Inherited::_M_swap(__in); }
875 #if __cpp_deduction_guides >= 201606 876 template<
typename... _UTypes>
878 template<
typename _T1,
typename _T2>
880 template<
typename _Alloc,
typename... _UTypes>
882 template<
typename _Alloc,
typename _T1,
typename _T2>
884 template<
typename _Alloc,
typename... _UTypes>
893 void swap(
tuple&) noexcept { }
898 template<
typename _Alloc>
900 template<
typename _Alloc>
906 template<
typename _T1,
typename _T2>
912 template <
typename _U1 = _T1,
915 __is_implicitly_default_constructible<_U1>,
916 __is_implicitly_default_constructible<_U2>>
917 ::value,
bool>::type =
true>
922 template <
typename _U1 = _T1,
929 __and_<__is_implicitly_default_constructible<_U1>,
930 __is_implicitly_default_constructible<_U2>>>>
931 ::value,
bool>::type =
false>
933 explicit constexpr tuple()
938 template<
typename _Dummy>
using _TCC =
939 _TC<is_same<_Dummy, void>::value, _T1, _T2>;
941 template<
typename _Dummy = void,
typename 943 _ConstructibleTuple<_T1, _T2>()
944 && _TCC<_Dummy>::template
945 _ImplicitlyConvertibleTuple<_T1, _T2>(),
947 constexpr tuple(
const _T1& __a1,
const _T2& __a2)
948 : _Inherited(__a1, __a2) { }
950 template<
typename _Dummy = void,
typename 952 _ConstructibleTuple<_T1, _T2>()
953 && !_TCC<_Dummy>::template
954 _ImplicitlyConvertibleTuple<_T1, _T2>(),
956 explicit constexpr tuple(
const _T1& __a1,
const _T2& __a2)
957 : _Inherited(__a1, __a2) { }
961 using _TMC = _TC<true, _T1, _T2>;
963 template<
typename _U1,
typename _U2,
typename 965 _MoveConstructibleTuple<_U1, _U2>()
967 _ImplicitlyMoveConvertibleTuple<_U1, _U2>()
971 constexpr tuple(_U1&& __a1, _U2&& __a2)
972 : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
974 template<
typename _U1,
typename _U2,
typename 976 _MoveConstructibleTuple<_U1, _U2>()
978 _ImplicitlyMoveConvertibleTuple<_U1, _U2>()
982 explicit constexpr tuple(_U1&& __a1, _U2&& __a2)
983 : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
985 constexpr tuple(
const tuple&) =
default;
987 constexpr tuple(tuple&&) =
default;
989 template<
typename _U1,
typename _U2,
typename 991 _ConstructibleTuple<_U1, _U2>()
993 _ImplicitlyConvertibleTuple<_U1, _U2>(),
998 template<
typename _U1,
typename _U2,
typename 1000 _ConstructibleTuple<_U1, _U2>()
1002 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1003 bool>::type =
false>
1007 template<
typename _U1,
typename _U2,
typename 1009 _MoveConstructibleTuple<_U1, _U2>()
1011 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1016 template<
typename _U1,
typename _U2,
typename 1018 _MoveConstructibleTuple<_U1, _U2>()
1020 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1021 bool>::type =
false>
1025 template<
typename _U1,
typename _U2,
typename 1027 _ConstructibleTuple<_U1, _U2>()
1029 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1034 template<
typename _U1,
typename _U2,
typename 1036 _ConstructibleTuple<_U1, _U2>()
1038 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1039 bool>::type =
false>
1043 template<
typename _U1,
typename _U2,
typename 1045 _MoveConstructibleTuple<_U1, _U2>()
1047 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1050 : _Inherited(std::forward<_U1>(__in.
first),
1051 std::forward<_U2>(__in.
second)) { }
1053 template<
typename _U1,
typename _U2,
typename 1055 _MoveConstructibleTuple<_U1, _U2>()
1057 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1058 bool>::type =
false>
1060 : _Inherited(std::forward<_U1>(__in.
first),
1061 std::forward<_U2>(__in.
second)) { }
1065 template<
typename _Alloc>
1067 : _Inherited(__tag, __a) { }
1069 template<
typename _Alloc,
typename _Dummy = void,
1071 _TCC<_Dummy>::template
1072 _ConstructibleTuple<_T1, _T2>()
1073 && _TCC<_Dummy>::template
1074 _ImplicitlyConvertibleTuple<_T1, _T2>(),
1078 const _T1& __a1,
const _T2& __a2)
1079 : _Inherited(__tag, __a, __a1, __a2) { }
1081 template<
typename _Alloc,
typename _Dummy = void,
1083 _TCC<_Dummy>::template
1084 _ConstructibleTuple<_T1, _T2>()
1085 && !_TCC<_Dummy>::template
1086 _ImplicitlyConvertibleTuple<_T1, _T2>(),
1090 const _T1& __a1,
const _T2& __a2)
1091 : _Inherited(__tag, __a, __a1, __a2) { }
1093 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1095 _MoveConstructibleTuple<_U1, _U2>()
1097 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1099 tuple(
allocator_arg_t __tag,
const _Alloc& __a, _U1&& __a1, _U2&& __a2)
1100 : _Inherited(__tag, __a, std::forward<_U1>(__a1),
1101 std::forward<_U2>(__a2)) { }
1103 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1105 _MoveConstructibleTuple<_U1, _U2>()
1107 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1108 bool>::type =
false>
1110 _U1&& __a1, _U2&& __a2)
1111 : _Inherited(__tag, __a, std::forward<_U1>(__a1),
1112 std::forward<_U2>(__a2)) { }
1114 template<
typename _Alloc>
1116 : _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
1118 template<
typename _Alloc>
1120 : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
1122 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1124 _ConstructibleTuple<_U1, _U2>()
1126 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1130 : _Inherited(__tag, __a,
1134 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1136 _ConstructibleTuple<_U1, _U2>()
1138 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1139 bool>::type =
false>
1142 : _Inherited(__tag, __a,
1146 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1148 _MoveConstructibleTuple<_U1, _U2>()
1150 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1156 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1158 _MoveConstructibleTuple<_U1, _U2>()
1160 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1161 bool>::type =
false>
1167 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1169 _ConstructibleTuple<_U1, _U2>()
1171 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1175 : _Inherited(__tag, __a, __in.
first, __in.
second) { }
1177 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1179 _ConstructibleTuple<_U1, _U2>()
1181 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1182 bool>::type =
false>
1185 : _Inherited(__tag, __a, __in.
first, __in.
second) { }
1187 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1189 _MoveConstructibleTuple<_U1, _U2>()
1191 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1194 : _Inherited(__tag, __a, std::forward<_U1>(__in.
first),
1195 std::forward<_U2>(__in.
second)) { }
1197 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1199 _MoveConstructibleTuple<_U1, _U2>()
1201 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1202 bool>::type =
false>
1205 : _Inherited(__tag, __a, std::forward<_U1>(__in.
first),
1206 std::forward<_U2>(__in.
second)) { }
1209 operator=(
const tuple& __in)
1211 static_cast<_Inherited&
>(*this) = __in;
1216 operator=(tuple&& __in)
1219 static_cast<_Inherited&
>(*this) = std::move(__in);
1223 template<
typename _U1,
typename _U2>
1227 static_cast<_Inherited&
>(*this) = __in;
1231 template<
typename _U1,
typename _U2>
1235 static_cast<_Inherited&
>(*this) = std::move(__in);
1239 template<
typename _U1,
typename _U2>
1243 this->_M_head(*
this) = __in.
first;
1244 this->_M_tail(*this)._M_head(*
this) = __in.
second;
1248 template<
typename _U1,
typename _U2>
1252 this->_M_head(*
this) = std::forward<_U1>(__in.
first);
1253 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.
second);
1259 noexcept(noexcept(__in._M_swap(__in)))
1260 { _Inherited::_M_swap(__in); }
1265 template<
typename... _Elements>
1269 #if __cplusplus > 201402L 1270 template <
typename _Tp>
1278 template<std::size_t __i,
typename _Head,
typename... _Tail>
1285 template<
typename _Head,
typename... _Tail>
1294 template<
size_t __i>
1298 "tuple index is in range");
1301 template<std::size_t __i,
typename _Head,
typename... _Tail>
1306 template<std::size_t __i,
typename _Head,
typename... _Tail>
1307 constexpr
const _Head&
1312 template<std::size_t __i,
typename... _Elements>
1313 constexpr __tuple_element_t<__i,
tuple<_Elements...>>&
1315 {
return std::__get_helper<__i>(__t); }
1318 template<std::size_t __i,
typename... _Elements>
1319 constexpr
const __tuple_element_t<__i,
tuple<_Elements...>>&
1320 get(
const tuple<_Elements...>& __t) noexcept
1321 {
return std::__get_helper<__i>(__t); }
1324 template<std::size_t __i,
typename... _Elements>
1325 constexpr __tuple_element_t<__i,
tuple<_Elements...>>&&
1328 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1329 return std::forward<__element_type&&>(std::get<__i>(__t));
1333 template<std::size_t __i,
typename... _Elements>
1334 constexpr
const __tuple_element_t<__i,
tuple<_Elements...>>&&
1335 get(
const tuple<_Elements...>&& __t) noexcept
1337 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1338 return std::forward<const __element_type&&>(std::get<__i>(__t));
1341 #if __cplusplus > 201103L 1343 #define __cpp_lib_tuples_by_type 201304 1345 template<
typename _Head,
size_t __i,
typename... _Tail>
1350 template<
typename _Head,
size_t __i,
typename... _Tail>
1351 constexpr
const _Head&
1356 template <
typename _Tp,
typename... _Types>
1359 {
return std::__get_helper2<_Tp>(__t); }
1362 template <
typename _Tp,
typename... _Types>
1365 {
return std::forward<_Tp&&>(std::__get_helper2<_Tp>(__t)); }
1368 template <
typename _Tp,
typename... _Types>
1369 constexpr
const _Tp&
1370 get(
const tuple<_Types...>& __t) noexcept
1371 {
return std::__get_helper2<_Tp>(__t); }
1375 template <
typename _Tp,
typename... _Types>
1376 constexpr
const _Tp&&
1377 get(
const tuple<_Types...>&& __t) noexcept
1378 {
return std::forward<const _Tp&&>(std::__get_helper2<_Tp>(__t)); }
1382 template<
typename _Tp,
typename _Up,
size_t __i,
size_t __size>
1383 struct __tuple_compare
1385 static constexpr
bool 1386 __eq(
const _Tp& __t,
const _Up& __u)
1388 return bool(std::get<__i>(__t) == std::get<__i>(__u))
1389 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u);
1392 static constexpr
bool 1393 __less(
const _Tp& __t,
const _Up& __u)
1395 return bool(std::get<__i>(__t) < std::get<__i>(__u))
1396 || (!bool(std::get<__i>(__u) < std::get<__i>(__t))
1397 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u));
1401 template<
typename _Tp,
typename _Up,
size_t __size>
1402 struct __tuple_compare<_Tp, _Up, __size, __size>
1404 static constexpr
bool 1405 __eq(
const _Tp&,
const _Up&) {
return true; }
1407 static constexpr
bool 1408 __less(
const _Tp&,
const _Up&) {
return false; }
1411 template<
typename... _TElements,
typename... _UElements>
1416 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1417 "tuple objects can only be compared if they have equal sizes.");
1418 using __compare = __tuple_compare<
tuple<_TElements...>,
1419 tuple<_UElements...>,
1420 0,
sizeof...(_TElements)>;
1421 return __compare::__eq(__t, __u);
1424 template<
typename... _TElements,
typename... _UElements>
1429 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1430 "tuple objects can only be compared if they have equal sizes.");
1431 using __compare = __tuple_compare<
tuple<_TElements...>,
1432 tuple<_UElements...>,
1433 0,
sizeof...(_TElements)>;
1434 return __compare::__less(__t, __u);
1437 template<
typename... _TElements,
typename... _UElements>
1441 {
return !(__t == __u); }
1443 template<
typename... _TElements,
typename... _UElements>
1447 {
return __u < __t; }
1449 template<
typename... _TElements,
typename... _UElements>
1453 {
return !(__u < __t); }
1455 template<
typename... _TElements,
typename... _UElements>
1459 {
return !(__t < __u); }
1462 template<
typename... _Elements>
1464 make_tuple(_Elements&&... __args)
1468 return __result_type(std::forward<_Elements>(__args)...);
1473 template<
typename... _Elements>
1474 constexpr
tuple<_Elements&&...>
1475 forward_as_tuple(_Elements&&... __args) noexcept
1476 {
return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
1478 template<
size_t,
typename,
typename,
size_t>
1479 struct __make_tuple_impl;
1481 template<
size_t _Idx,
typename _Tuple,
typename... _Tp,
size_t _Nm>
1482 struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
1483 : __make_tuple_impl<_Idx + 1,
1484 tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
1488 template<std::size_t _Nm,
typename _Tuple,
typename... _Tp>
1489 struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
1491 typedef tuple<_Tp...> __type;
1494 template<
typename _Tuple>
1495 struct __do_make_tuple
1496 : __make_tuple_impl<0, tuple<>, _Tuple, std::tuple_size<_Tuple>::value>
1500 template<
typename _Tuple>
1502 :
public __do_make_tuple<typename std::remove_cv
1503 <typename std::remove_reference<_Tuple>::type>::type>
1507 template<
typename...>
1508 struct __combine_tuples;
1511 struct __combine_tuples<>
1516 template<
typename... _Ts>
1517 struct __combine_tuples<tuple<_Ts...>>
1519 typedef tuple<_Ts...> __type;
1522 template<
typename... _T1s,
typename... _T2s,
typename... _Rem>
1523 struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
1525 typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
1526 _Rem...>::__type __type;
1530 template<
typename... _Tpls>
1531 struct __tuple_cat_result
1533 typedef typename __combine_tuples
1534 <
typename __make_tuple<_Tpls>::__type...>::__type __type;
1539 template<
typename...>
1540 struct __make_1st_indices;
1543 struct __make_1st_indices<>
1545 typedef std::_Index_tuple<> __type;
1548 template<
typename _Tp,
typename... _Tpls>
1549 struct __make_1st_indices<_Tp, _Tpls...>
1552 typename std::remove_reference<_Tp>::type>::value>::__type __type;
1558 template<
typename _Ret,
typename _Indices,
typename... _Tpls>
1559 struct __tuple_concater;
1561 template<
typename _Ret, std::size_t... _Is,
typename _Tp,
typename... _Tpls>
1562 struct __tuple_concater<_Ret, std::_Index_tuple<_Is...>, _Tp, _Tpls...>
1564 template<
typename... _Us>
1565 static constexpr _Ret
1566 _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
1568 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1569 typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
1570 return __next::_S_do(std::forward<_Tpls>(__tps)...,
1571 std::forward<_Us>(__us)...,
1572 std::get<_Is>(std::forward<_Tp>(__tp))...);
1576 template<
typename _Ret>
1577 struct __tuple_concater<_Ret, std::_Index_tuple<>>
1579 template<
typename... _Us>
1580 static constexpr _Ret
1581 _S_do(_Us&&... __us)
1583 return _Ret(std::forward<_Us>(__us)...);
1588 template<
typename... _Tpls,
typename =
typename 1592 ->
typename __tuple_cat_result<_Tpls...>::__type
1594 typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
1595 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1596 typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
1597 return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
1603 template<
typename... _Elements>
1604 constexpr tuple<_Elements&...>
1605 tie(_Elements&... __args) noexcept
1606 {
return tuple<_Elements&...>(__args...); }
1609 template<
typename... _Elements>
1611 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 1619 noexcept(noexcept(__x.swap(__y)))
1622 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 1623 template<
typename... _Elements>
1632 struct _Swallow_assign
1635 _GLIBCXX14_CONSTEXPR
const _Swallow_assign&
1636 operator=(
const _Tp&)
const 1642 _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
1645 template<
typename... _Types,
typename _Alloc>
1649 template<
class _T1,
class _T2>
1650 template<
typename... _Args1,
typename... _Args2>
1655 :
pair(__first, __second,
1656 typename _Build_index_tuple<
sizeof...(_Args1)>::__type(),
1657 typename _Build_index_tuple<
sizeof...(_Args2)>::__type())
1660 template<
class _T1,
class _T2>
1661 template<
typename... _Args1, std::size_t... _Indexes1,
1662 typename... _Args2, std::size_t... _Indexes2>
1666 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
1667 : first(std::forward<_Args1>(std::get<_Indexes1>(__tuple1))...),
1668 second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
1671 #if __cplusplus > 201402L 1672 # define __cpp_lib_apply 201603 1674 template <
typename _Fn,
typename _Tuple,
size_t... _Idx>
1675 constexpr decltype(
auto)
1679 std::get<_Idx>(std::forward<_Tuple>(__t))...);
1682 template <
typename _Fn,
typename _Tuple>
1683 constexpr decltype(
auto)
1684 apply(_Fn&& __f, _Tuple&& __t)
1687 return std::__apply_impl(std::forward<_Fn>(__f),
1688 std::forward<_Tuple>(__t),
1692 #define __cpp_lib_make_from_tuple 201606 1694 template <
typename _Tp,
typename _Tuple,
size_t... _Idx>
1697 {
return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); }
1699 template <
typename _Tp,
typename _Tuple>
1701 make_from_tuple(_Tuple&& __t)
1703 return __make_from_tuple_impl<_Tp>(
1704 std::forward<_Tuple>(__t),
1711 _GLIBCXX_END_NAMESPACE_VERSION
1716 #endif // _GLIBCXX_TUPLE
Primary class template, tuple.
Define a member typedef type only if a boolean constant is true.
constexpr pair()
second is a copy of the second object
Define a member typedef type to one of two argument types.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
is_nothrow_move_assignable
Class template integer_sequence.
constexpr tuple< _Elements &... > tie(_Elements &... __args) noexcept
tie
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
Struct holding two objects of arbitrary type.
ISO C++ entities toplevel namespace is std.
typename decay< _Tp >::type decay_t
Alias template for decay.
is_nothrow_move_constructible
constexpr auto tuple_cat(_Tpls &&... __tpls) -> typename __tuple_cat_result< _Tpls... >::__type
tuple_cat
_T2 second
first is a copy of the first object
constexpr __invoke_result< _Callable, _Args... >::type __invoke(_Callable &&__fn, _Args &&... __args) noexcept(__is_nothrow_invocable< _Callable, _Args... >::value)
Invoke a callable object.
Declare uses_allocator so it can be specialized in <queue> etc.
Partial specialization, 2-element tuple. Includes construction and assignment from a pair...
_T1 first
second_type is the second bound type