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
65 =
typename conditional<__is_final(_Tp),
false_type,
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)
224 noexcept(__and_<is_nothrow_move_constructible<_Head>,
225 is_nothrow_move_constructible<_Inherited>>::value)
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)
301 noexcept(__and_<is_nothrow_move_assignable<_Head>,
302 is_nothrow_move_assignable<_Inherited>>::value)
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)
372 noexcept(is_nothrow_move_constructible<_Head>::value)
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)
432 noexcept(is_nothrow_move_assignable<_Head>::value)
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()
497 return __and_<__not_<is_same<
tuple<_Elements...>,
499 typename remove_reference<_SrcTuple>::type
501 __not_<is_convertible<_SrcTuple, _Elements...>>,
502 __not_<is_constructible<_Elements..., _SrcTuple>>
505 template<
typename... _UElements>
506 static constexpr
bool _NotSameTuple()
508 return __not_<is_same<
tuple<_Elements...>,
509 typename remove_const<
510 typename remove_reference<_UElements...>::type
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,
578 typename enable_if<_TC2<_Dummy>::
579 _ImplicitlyDefaultConstructibleTuple(),
584 template<
typename _Dummy = void,
585 typename enable_if<_TC2<_Dummy>::
586 _DefaultConstructibleTuple()
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 671 enable_if<_TMCT<_UElements...>::template
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 683 enable_if<_TMCT<_UElements...>::template
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 695 enable_if<_TMCT<_UElements...>::template
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 706 enable_if<_TMCT<_UElements...>::template
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 745 enable_if<_TMC<_UElements...>::template
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 756 enable_if<_TMC<_UElements...>::template
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 776 enable_if<_TMCT<_UElements...>::template
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 791 enable_if<_TMCT<_UElements...>::template
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 806 enable_if<_TMCT<_UElements...>::template
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 821 enable_if<_TMCT<_UElements...>::template
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)
843 noexcept(is_nothrow_move_assignable<_Inherited>::value)
845 static_cast<_Inherited&
>(*this) = std::move(__in);
849 template<
typename... _UElements>
851 enable_if<
sizeof...(_UElements)
852 ==
sizeof...(_Elements), tuple&>::type
859 template<
typename... _UElements>
861 enable_if<
sizeof...(_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); }
880 void swap(
tuple&) noexcept { }
885 template<
typename _Alloc>
887 template<
typename _Alloc>
893 template<
typename _T1,
typename _T2>
899 template <
typename _U1 = _T1,
901 typename enable_if<__and_<
902 __is_implicitly_default_constructible<_U1>,
903 __is_implicitly_default_constructible<_U2>>
904 ::value,
bool>::type =
true>
909 template <
typename _U1 = _T1,
913 is_default_constructible<_U1>,
914 is_default_constructible<_U2>,
916 __and_<__is_implicitly_default_constructible<_U1>,
917 __is_implicitly_default_constructible<_U2>>>>
918 ::value,
bool>::type =
false>
920 explicit constexpr tuple()
925 template<
typename _Dummy>
using _TCC =
926 _TC<is_same<_Dummy, void>::value, _T1, _T2>;
928 template<
typename _Dummy = void,
typename 929 enable_if<_TCC<_Dummy>::template
930 _ConstructibleTuple<_T1, _T2>()
931 && _TCC<_Dummy>::template
932 _ImplicitlyConvertibleTuple<_T1, _T2>(),
934 constexpr tuple(
const _T1& __a1,
const _T2& __a2)
935 : _Inherited(__a1, __a2) { }
937 template<
typename _Dummy = void,
typename 938 enable_if<_TCC<_Dummy>::template
939 _ConstructibleTuple<_T1, _T2>()
940 && !_TCC<_Dummy>::template
941 _ImplicitlyConvertibleTuple<_T1, _T2>(),
943 explicit constexpr tuple(
const _T1& __a1,
const _T2& __a2)
944 : _Inherited(__a1, __a2) { }
948 using _TMC = _TC<true, _T1, _T2>;
950 template<
typename _U1,
typename _U2,
typename 951 enable_if<_TMC::template
952 _MoveConstructibleTuple<_U1, _U2>()
954 _ImplicitlyMoveConvertibleTuple<_U1, _U2>()
955 && !is_same<typename decay<_U1>::type,
958 constexpr tuple(_U1&& __a1, _U2&& __a2)
959 : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
961 template<
typename _U1,
typename _U2,
typename 962 enable_if<_TMC::template
963 _MoveConstructibleTuple<_U1, _U2>()
965 _ImplicitlyMoveConvertibleTuple<_U1, _U2>()
966 && !is_same<typename decay<_U1>::type,
969 explicit constexpr tuple(_U1&& __a1, _U2&& __a2)
970 : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
972 constexpr tuple(
const tuple&) =
default;
974 constexpr tuple(tuple&&) =
default;
976 template<
typename _U1,
typename _U2,
typename 977 enable_if<_TMC::template
978 _ConstructibleTuple<_U1, _U2>()
980 _ImplicitlyConvertibleTuple<_U1, _U2>(),
985 template<
typename _U1,
typename _U2,
typename 986 enable_if<_TMC::template
987 _ConstructibleTuple<_U1, _U2>()
989 _ImplicitlyConvertibleTuple<_U1, _U2>(),
994 template<
typename _U1,
typename _U2,
typename 995 enable_if<_TMC::template
996 _MoveConstructibleTuple<_U1, _U2>()
998 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1003 template<
typename _U1,
typename _U2,
typename 1004 enable_if<_TMC::template
1005 _MoveConstructibleTuple<_U1, _U2>()
1007 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1008 bool>::type =
false>
1012 template<
typename _U1,
typename _U2,
typename 1013 enable_if<_TMC::template
1014 _ConstructibleTuple<_U1, _U2>()
1016 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1021 template<
typename _U1,
typename _U2,
typename 1022 enable_if<_TMC::template
1023 _ConstructibleTuple<_U1, _U2>()
1025 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1026 bool>::type =
false>
1030 template<
typename _U1,
typename _U2,
typename 1031 enable_if<_TMC::template
1032 _MoveConstructibleTuple<_U1, _U2>()
1034 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1037 : _Inherited(std::forward<_U1>(__in.
first),
1038 std::forward<_U2>(__in.
second)) { }
1040 template<
typename _U1,
typename _U2,
typename 1041 enable_if<_TMC::template
1042 _MoveConstructibleTuple<_U1, _U2>()
1044 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1045 bool>::type =
false>
1047 : _Inherited(std::forward<_U1>(__in.
first),
1048 std::forward<_U2>(__in.
second)) { }
1052 template<
typename _Alloc>
1054 : _Inherited(__tag, __a) { }
1056 template<
typename _Alloc,
typename _Dummy = void,
1058 _TCC<_Dummy>::template
1059 _ConstructibleTuple<_T1, _T2>()
1060 && _TCC<_Dummy>::template
1061 _ImplicitlyConvertibleTuple<_T1, _T2>(),
1065 const _T1& __a1,
const _T2& __a2)
1066 : _Inherited(__tag, __a, __a1, __a2) { }
1068 template<
typename _Alloc,
typename _Dummy = void,
1070 _TCC<_Dummy>::template
1071 _ConstructibleTuple<_T1, _T2>()
1072 && !_TCC<_Dummy>::template
1073 _ImplicitlyConvertibleTuple<_T1, _T2>(),
1077 const _T1& __a1,
const _T2& __a2)
1078 : _Inherited(__tag, __a, __a1, __a2) { }
1080 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1081 enable_if<_TMC::template
1082 _MoveConstructibleTuple<_U1, _U2>()
1084 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1086 tuple(
allocator_arg_t __tag,
const _Alloc& __a, _U1&& __a1, _U2&& __a2)
1087 : _Inherited(__tag, __a, std::forward<_U1>(__a1),
1088 std::forward<_U2>(__a2)) { }
1090 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1091 enable_if<_TMC::template
1092 _MoveConstructibleTuple<_U1, _U2>()
1094 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1095 bool>::type =
false>
1097 _U1&& __a1, _U2&& __a2)
1098 : _Inherited(__tag, __a, std::forward<_U1>(__a1),
1099 std::forward<_U2>(__a2)) { }
1101 template<
typename _Alloc>
1103 : _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
1105 template<
typename _Alloc>
1107 : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
1109 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1110 enable_if<_TMC::template
1111 _ConstructibleTuple<_U1, _U2>()
1113 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1117 : _Inherited(__tag, __a,
1121 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1122 enable_if<_TMC::template
1123 _ConstructibleTuple<_U1, _U2>()
1125 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1126 bool>::type =
false>
1129 : _Inherited(__tag, __a,
1133 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1134 enable_if<_TMC::template
1135 _MoveConstructibleTuple<_U1, _U2>()
1137 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1143 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1144 enable_if<_TMC::template
1145 _MoveConstructibleTuple<_U1, _U2>()
1147 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1148 bool>::type =
false>
1154 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1155 enable_if<_TMC::template
1156 _ConstructibleTuple<_U1, _U2>()
1158 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1162 : _Inherited(__tag, __a, __in.
first, __in.
second) { }
1164 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1165 enable_if<_TMC::template
1166 _ConstructibleTuple<_U1, _U2>()
1168 _ImplicitlyConvertibleTuple<_U1, _U2>(),
1169 bool>::type =
false>
1172 : _Inherited(__tag, __a, __in.
first, __in.
second) { }
1174 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1175 enable_if<_TMC::template
1176 _MoveConstructibleTuple<_U1, _U2>()
1178 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1181 : _Inherited(__tag, __a, std::forward<_U1>(__in.
first),
1182 std::forward<_U2>(__in.
second)) { }
1184 template<
typename _Alloc,
typename _U1,
typename _U2,
typename 1185 enable_if<_TMC::template
1186 _MoveConstructibleTuple<_U1, _U2>()
1188 _ImplicitlyMoveConvertibleTuple<_U1, _U2>(),
1189 bool>::type =
false>
1192 : _Inherited(__tag, __a, std::forward<_U1>(__in.
first),
1193 std::forward<_U2>(__in.
second)) { }
1196 operator=(
const tuple& __in)
1198 static_cast<_Inherited&
>(*this) = __in;
1203 operator=(tuple&& __in)
1204 noexcept(is_nothrow_move_assignable<_Inherited>::value)
1206 static_cast<_Inherited&
>(*this) = std::move(__in);
1210 template<
typename _U1,
typename _U2>
1214 static_cast<_Inherited&
>(*this) = __in;
1218 template<
typename _U1,
typename _U2>
1222 static_cast<_Inherited&
>(*this) = std::move(__in);
1226 template<
typename _U1,
typename _U2>
1230 this->_M_head(*
this) = __in.
first;
1231 this->_M_tail(*this)._M_head(*
this) = __in.
second;
1235 template<
typename _U1,
typename _U2>
1239 this->_M_head(*
this) = std::forward<_U1>(__in.
first);
1240 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.
second);
1246 noexcept(noexcept(__in._M_swap(__in)))
1247 { _Inherited::_M_swap(__in); }
1252 template<
typename... _Elements>
1256 #if __cplusplus > 201402L 1257 template <
typename _Tp>
1265 template<std::size_t __i,
typename _Head,
typename... _Tail>
1272 template<
typename _Head,
typename... _Tail>
1281 template<
size_t __i>
1285 "tuple index is in range");
1288 template<std::size_t __i,
typename _Head,
typename... _Tail>
1293 template<std::size_t __i,
typename _Head,
typename... _Tail>
1294 constexpr
const _Head&
1299 template<std::size_t __i,
typename... _Elements>
1300 constexpr __tuple_element_t<__i,
tuple<_Elements...>>&
1302 {
return std::__get_helper<__i>(__t); }
1305 template<std::size_t __i,
typename... _Elements>
1306 constexpr
const __tuple_element_t<__i,
tuple<_Elements...>>&
1307 get(
const tuple<_Elements...>& __t) noexcept
1308 {
return std::__get_helper<__i>(__t); }
1311 template<std::size_t __i,
typename... _Elements>
1312 constexpr __tuple_element_t<__i,
tuple<_Elements...>>&&
1315 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1316 return std::forward<__element_type&&>(std::get<__i>(__t));
1319 #if __cplusplus > 201103L 1321 #define __cpp_lib_tuples_by_type 201304 1323 template<
typename _Head,
size_t __i,
typename... _Tail>
1328 template<
typename _Head,
size_t __i,
typename... _Tail>
1329 constexpr
const _Head&
1334 template <
typename _Tp,
typename... _Types>
1337 {
return std::__get_helper2<_Tp>(__t); }
1340 template <
typename _Tp,
typename... _Types>
1343 {
return std::forward<_Tp&&>(std::__get_helper2<_Tp>(__t)); }
1346 template <
typename _Tp,
typename... _Types>
1347 constexpr
const _Tp&
1348 get(
const tuple<_Types...>& __t) noexcept
1349 {
return std::__get_helper2<_Tp>(__t); }
1353 template<
typename _Tp,
typename _Up,
size_t __i,
size_t __size>
1354 struct __tuple_compare
1356 static constexpr
bool 1357 __eq(
const _Tp& __t,
const _Up& __u)
1359 return bool(std::get<__i>(__t) == std::get<__i>(__u))
1360 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u);
1363 static constexpr
bool 1364 __less(
const _Tp& __t,
const _Up& __u)
1366 return bool(std::get<__i>(__t) < std::get<__i>(__u))
1367 || (!bool(std::get<__i>(__u) < std::get<__i>(__t))
1368 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u));
1372 template<
typename _Tp,
typename _Up,
size_t __size>
1373 struct __tuple_compare<_Tp, _Up, __size, __size>
1375 static constexpr
bool 1376 __eq(
const _Tp&,
const _Up&) {
return true; }
1378 static constexpr
bool 1379 __less(
const _Tp&,
const _Up&) {
return false; }
1382 template<
typename... _TElements,
typename... _UElements>
1387 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1388 "tuple objects can only be compared if they have equal sizes.");
1389 using __compare = __tuple_compare<
tuple<_TElements...>,
1390 tuple<_UElements...>,
1391 0,
sizeof...(_TElements)>;
1392 return __compare::__eq(__t, __u);
1395 template<
typename... _TElements,
typename... _UElements>
1400 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1401 "tuple objects can only be compared if they have equal sizes.");
1402 using __compare = __tuple_compare<
tuple<_TElements...>,
1403 tuple<_UElements...>,
1404 0,
sizeof...(_TElements)>;
1405 return __compare::__less(__t, __u);
1408 template<
typename... _TElements,
typename... _UElements>
1412 {
return !(__t == __u); }
1414 template<
typename... _TElements,
typename... _UElements>
1418 {
return __u < __t; }
1420 template<
typename... _TElements,
typename... _UElements>
1424 {
return !(__u < __t); }
1426 template<
typename... _TElements,
typename... _UElements>
1430 {
return !(__t < __u); }
1433 template<
typename... _Elements>
1435 make_tuple(_Elements&&... __args)
1439 return __result_type(std::forward<_Elements>(__args)...);
1444 template<
typename... _Elements>
1445 constexpr
tuple<_Elements&&...>
1446 forward_as_tuple(_Elements&&... __args) noexcept
1447 {
return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
1449 template<
size_t,
typename,
typename,
size_t>
1450 struct __make_tuple_impl;
1452 template<
size_t _Idx,
typename _Tuple,
typename... _Tp,
size_t _Nm>
1453 struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
1454 : __make_tuple_impl<_Idx + 1,
1455 tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
1459 template<std::size_t _Nm,
typename _Tuple,
typename... _Tp>
1460 struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
1462 typedef tuple<_Tp...> __type;
1465 template<
typename _Tuple>
1466 struct __do_make_tuple
1467 : __make_tuple_impl<0, tuple<>, _Tuple, std::tuple_size<_Tuple>::value>
1471 template<
typename _Tuple>
1473 :
public __do_make_tuple<typename std::remove_cv
1474 <typename std::remove_reference<_Tuple>::type>::type>
1478 template<
typename...>
1479 struct __combine_tuples;
1482 struct __combine_tuples<>
1487 template<
typename... _Ts>
1488 struct __combine_tuples<tuple<_Ts...>>
1490 typedef tuple<_Ts...> __type;
1493 template<
typename... _T1s,
typename... _T2s,
typename... _Rem>
1494 struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
1496 typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
1497 _Rem...>::__type __type;
1501 template<
typename... _Tpls>
1502 struct __tuple_cat_result
1504 typedef typename __combine_tuples
1505 <
typename __make_tuple<_Tpls>::__type...>::__type __type;
1510 template<
typename...>
1511 struct __make_1st_indices;
1514 struct __make_1st_indices<>
1516 typedef std::_Index_tuple<> __type;
1519 template<
typename _Tp,
typename... _Tpls>
1520 struct __make_1st_indices<_Tp, _Tpls...>
1523 typename std::remove_reference<_Tp>::type>::value>::__type __type;
1529 template<
typename _Ret,
typename _Indices,
typename... _Tpls>
1530 struct __tuple_concater;
1532 template<
typename _Ret, std::size_t... _Is,
typename _Tp,
typename... _Tpls>
1533 struct __tuple_concater<_Ret, std::_Index_tuple<_Is...>, _Tp, _Tpls...>
1535 template<
typename... _Us>
1536 static constexpr _Ret
1537 _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
1539 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1540 typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
1541 return __next::_S_do(std::forward<_Tpls>(__tps)...,
1542 std::forward<_Us>(__us)...,
1543 std::get<_Is>(std::forward<_Tp>(__tp))...);
1547 template<
typename _Ret>
1548 struct __tuple_concater<_Ret, std::_Index_tuple<>>
1550 template<
typename... _Us>
1551 static constexpr _Ret
1552 _S_do(_Us&&... __us)
1554 return _Ret(std::forward<_Us>(__us)...);
1559 template<
typename... _Tpls,
typename =
typename 1560 enable_if<__and_<__is_tuple_like<_Tpls>...>::value>::type>
1563 ->
typename __tuple_cat_result<_Tpls...>::__type
1565 typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
1566 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1567 typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
1568 return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
1574 template<
typename... _Elements>
1575 constexpr tuple<_Elements&...>
1576 tie(_Elements&... __args) noexcept
1577 {
return tuple<_Elements&...>(__args...); }
1580 template<
typename... _Elements>
1582 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 1584 typename enable_if<__and_<__is_swappable<_Elements>...>::value
1590 noexcept(noexcept(__x.swap(__y)))
1593 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 1594 template<
typename... _Elements>
1595 typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type
1601 struct _Swallow_assign
1604 const _Swallow_assign&
1605 operator=(
const _Tp&)
const 1609 const _Swallow_assign ignore{};
1612 template<
typename... _Types,
typename _Alloc>
1616 template<
class _T1,
class _T2>
1617 template<
typename... _Args1,
typename... _Args2>
1622 :
pair(__first, __second,
1623 typename _Build_index_tuple<
sizeof...(_Args1)>::__type(),
1624 typename _Build_index_tuple<
sizeof...(_Args2)>::__type())
1627 template<
class _T1,
class _T2>
1628 template<
typename... _Args1, std::size_t... _Indexes1,
1629 typename... _Args2, std::size_t... _Indexes2>
1633 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
1634 : first(std::forward<_Args1>(std::get<_Indexes1>(__tuple1))...),
1635 second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
1638 #if __cplusplus > 201402L 1639 # define __cpp_lib_apply 201603 1641 template <
typename _Fn,
typename _Tuple,
size_t... _Idx>
1642 constexpr decltype(
auto)
1646 std::get<_Idx>(std::forward<_Tuple>(__t))...);
1649 template <
typename _Fn,
typename _Tuple>
1650 constexpr decltype(
auto)
1651 apply(_Fn&& __f, _Tuple&& __t)
1654 return std::__apply_impl(std::forward<_Fn>(__f),
1655 std::forward<_Tuple>(__t),
1659 #define __cpp_lib_make_from_tuple 201606 1661 template <
typename _Tp,
typename _Tuple,
size_t... _Idx>
1664 {
return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); }
1666 template <
typename _Tp,
typename _Tuple>
1668 make_from_tuple(_Tuple&& __t)
1670 return __make_from_tuple_impl<_Tp>(
1671 std::forward<_Tuple>(__t),
1678 _GLIBCXX_END_NAMESPACE_VERSION
1683 #endif // _GLIBCXX_TUPLE _T2 second
first is a copy of the first object
Primary class template, tuple.
ISO C++ entities toplevel namespace is std.
constexpr tuple< _Elements &... > tie(_Elements &... __args) noexcept
tie
make_integer_sequence< size_t, _Num > make_index_sequence
Alias template make_index_sequence.
constexpr auto tuple_cat(_Tpls &&... __tpls) -> typename __tuple_cat_result< _Tpls... >::__type
tuple_cat
Class template integer_sequence.
constexpr pair()
second is a copy of the second object
Declare uses_allocator so it can be specialized in <queue> etc.
_T1 first
second_type is the second bound type
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.
constexpr result_of< _Callable &&(_Args &&...)>::type __invoke(_Callable &&__fn, _Args &&... __args) noexcept(__is_nothrow_callable< _Callable &&(_Args &&...)>::value)
Invoke a callable object.