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>
64 struct __is_empty_non_tuple<tuple<_El0, _El...>> :
false_type { };
67 template<
typename _Tp>
68 using __empty_not_final
69 =
typename conditional<__is_final(_Tp),
false_type,
70 __is_empty_non_tuple<_Tp>>::type;
72 template<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)
93 _Head_base(allocator_arg_t, __uses_alloc0)
96 template<
typename _Alloc>
97 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
98 : _Head(allocator_arg, *__a._M_a) { }
100 template<
typename _Alloc>
101 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
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)
140 _Head_base(allocator_arg_t, __uses_alloc0)
143 template<
typename _Alloc>
144 _Head_base(allocator_arg_t, __uses_alloc1<_Alloc> __a)
145 : _M_head_impl(allocator_arg, *__a._M_a) { }
147 template<
typename _Alloc>
148 _Head_base(allocator_arg_t, __uses_alloc2<_Alloc> __a)
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)) { }
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>
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(
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); }
354 constexpr _Tuple_impl()
358 constexpr _Tuple_impl(
const _Head& __head)
361 template<
typename _UHead>
363 constexpr _Tuple_impl(_UHead&& __head)
366 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
370 _Tuple_impl& operator=(
const _Tuple_impl&) =
delete;
373 _Tuple_impl(_Tuple_impl&& __in)
374 noexcept(is_nothrow_move_constructible<_Head>::value)
375 : _Base(
std::
forward<_Head>(_M_head(__in))) { }
377 template<
typename _UHead>
378 constexpr _Tuple_impl(
const _Tuple_impl<_Idx, _UHead>& __in)
379 : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in)) { }
381 template<
typename _UHead>
382 constexpr _Tuple_impl(_Tuple_impl<_Idx, _UHead>&& __in)
383 : _Base(
std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
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>
398 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
400 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
403 template<
typename _Alloc>
405 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
406 const _Tuple_impl& __in)
407 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
409 template<
typename _Alloc>
411 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
413 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
416 template<
typename _Alloc,
typename _UHead>
418 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
419 const _Tuple_impl<_Idx, _UHead>& __in)
420 : _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
421 _Tuple_impl<_Idx, _UHead>::_M_head(__in)) { }
423 template<
typename _Alloc,
typename _UHead>
425 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
426 _Tuple_impl<_Idx, _UHead>&& __in)
427 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
428 std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
431 template<
typename _UHead>
434 _M_assign(
const _Tuple_impl<_Idx, _UHead>& __in)
436 _M_head(*
this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in);
439 template<
typename _UHead>
442 _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
445 = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
451 _M_swap(_Tuple_impl& __in)
454 swap(_M_head(*
this), _M_head(__in));
460 template<bool,
typename... _Types>
461 struct _TupleConstraints
463 template<
typename _Tp,
typename _Up>
464 using is_constructible
465 = __bool_constant<__is_constructible(_Tp, _Up)>;
470 template<
typename... _UTypes>
471 static constexpr
bool __is_implicitly_constructible()
473 return __and_<is_constructible<_Types, _UTypes>...,
474 is_convertible<_UTypes, _Types>...
481 template<
typename... _UTypes>
482 static constexpr
bool __is_explicitly_constructible()
484 return __and_<is_constructible<_Types, _UTypes>...,
485 __not_<__and_<is_convertible<_UTypes, _Types>...>>
489 static constexpr
bool __is_implicitly_default_constructible()
491 return __and_<std::__is_implicitly_default_constructible<_Types>...
495 static constexpr
bool __is_explicitly_default_constructible()
497 return __and_<is_default_constructible<_Types>...,
499 std::__is_implicitly_default_constructible<_Types>...>
506 template<
typename... _Types>
507 struct _TupleConstraints<false, _Types...>
509 template<
typename... _UTypes>
510 static constexpr
bool __is_implicitly_constructible()
513 template<
typename... _UTypes>
514 static constexpr
bool __is_explicitly_constructible()
519 template<
typename... _Elements>
525 using _TCC = _TupleConstraints<_Cond, _Elements...>;
528 template<
bool _Dummy>
529 using _ImplicitDefaultCtor = __enable_if_t<
530 _TCC<_Dummy>::__is_implicitly_default_constructible(),
534 template<
bool _Dummy>
535 using _ExplicitDefaultCtor = __enable_if_t<
536 _TCC<_Dummy>::__is_explicitly_default_constructible(),
540 template<
bool _Cond,
typename... _Args>
541 using _ImplicitCtor = __enable_if_t<
542 _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(),
546 template<
bool _Cond,
typename... _Args>
547 using _ExplicitCtor = __enable_if_t<
548 _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(),
551 template<
typename... _UElements>
553 __enable_if_t<
sizeof...(_UElements) ==
sizeof...(_Elements),
bool>
555 {
return __and_<is_assignable<_Elements&, _UElements>...>::value; }
558 template<
typename... _UElements>
559 static constexpr
bool __nothrow_assignable()
562 __and_<is_nothrow_assignable<_Elements&, _UElements>...>::value;
566 template<
typename... _UElements>
567 static constexpr
bool __nothrow_constructible()
570 __and_<is_nothrow_constructible<_Elements, _UElements>...>::value;
574 template<
typename _Up>
575 static constexpr
bool __valid_args()
577 return sizeof...(_Elements) == 1
582 template<
typename,
typename,
typename... _Tail>
583 static constexpr
bool __valid_args()
584 {
return (
sizeof...(_Tail) + 2) ==
sizeof...(_Elements); }
595 template<
typename _Tuple,
typename =
tuple,
596 typename = __remove_cvref_t<_Tuple>>
602 template<
typename _Tuple,
typename _Tp,
typename _Up>
603 struct _UseOtherCtor<_Tuple,
tuple<_Tp>,
tuple<_Up>>
604 : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>
608 template<
typename _Tuple,
typename _Tp>
609 struct _UseOtherCtor<_Tuple,
tuple<_Tp>,
tuple<_Tp>>
616 template<
typename _Tuple>
617 static constexpr
bool __use_other_ctor()
618 {
return _UseOtherCtor<_Tuple>::value; }
621 template<
typename _Dummy = void,
622 _ImplicitDefaultCtor<is_void<_Dummy>::value> =
true>
628 template<
typename _Dummy = void,
629 _ExplicitDefaultCtor<is_void<_Dummy>::value> =
false>
635 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
636 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
638 tuple(
const _Elements&... __elements)
639 noexcept(__nothrow_constructible<const _Elements&...>())
642 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
643 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
645 tuple(
const _Elements&... __elements)
646 noexcept(__nothrow_constructible<const _Elements&...>())
649 template<
typename... _UElements,
650 bool _Valid = __valid_args<_UElements...>(),
651 _ImplicitCtor<_Valid, _UElements...> =
true>
653 tuple(_UElements&&... __elements)
654 noexcept(__nothrow_constructible<_UElements...>())
655 :
_Inherited(std::forward<_UElements>(__elements)...) { }
657 template<
typename... _UElements,
658 bool _Valid = __valid_args<_UElements...>(),
659 _ExplicitCtor<_Valid, _UElements...> =
false>
661 tuple(_UElements&&... __elements)
662 noexcept(__nothrow_constructible<_UElements...>())
663 :
_Inherited(std::forward<_UElements>(__elements)...) { }
669 template<
typename... _UElements,
670 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
672 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
675 noexcept(__nothrow_constructible<const _UElements&...>())
679 template<
typename... _UElements,
680 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
682 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
685 noexcept(__nothrow_constructible<const _UElements&...>())
689 template<
typename... _UElements,
690 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
692 _ImplicitCtor<_Valid, _UElements...> =
true>
695 noexcept(__nothrow_constructible<_UElements...>())
698 template<
typename... _UElements,
699 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
701 _ExplicitCtor<_Valid, _UElements...> =
false>
704 noexcept(__nothrow_constructible<_UElements...>())
709 template<
typename _Alloc,
710 _ImplicitDefaultCtor<is_object<_Alloc>::value> =
true>
715 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
716 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
719 const _Elements&... __elements)
722 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
723 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
727 const _Elements&... __elements)
730 template<
typename _Alloc,
typename... _UElements,
731 bool _Valid = __valid_args<_UElements...>(),
732 _ImplicitCtor<_Valid, _UElements...> =
true>
735 _UElements&&... __elements)
736 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
739 template<
typename _Alloc,
typename... _UElements,
740 bool _Valid = __valid_args<_UElements...>(),
741 _ExplicitCtor<_Valid, _UElements...> =
false>
745 _UElements&&... __elements)
746 :
_Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
749 template<
typename _Alloc>
754 template<
typename _Alloc>
759 template<
typename _Alloc,
typename... _UElements,
760 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
762 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
767 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
770 template<
typename _Alloc,
typename... _UElements,
771 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
773 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
779 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
782 template<
typename _Alloc,
typename... _UElements,
783 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
785 _ImplicitCtor<_Valid, _UElements...> =
true>
790 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
793 template<
typename _Alloc,
typename... _UElements,
794 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
796 _ExplicitCtor<_Valid, _UElements...> =
false>
802 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
809 operator=(
typename conditional<__assignable<const _Elements&...>(),
811 const __nonesuch&>::type __in)
812 noexcept(__nothrow_assignable<const _Elements&...>())
814 this->_M_assign(__in);
820 operator=(
typename conditional<__assignable<_Elements...>(),
822 __nonesuch&&>::type __in)
823 noexcept(__nothrow_assignable<_Elements...>())
829 template<
typename... _UElements>
831 __enable_if_t<__assignable<
const _UElements&...>(),
tuple&>
833 noexcept(__nothrow_assignable<const _UElements&...>())
835 this->_M_assign(__in);
839 template<
typename... _UElements>
841 __enable_if_t<__assignable<_UElements...>(),
tuple&>
843 noexcept(__nothrow_assignable<_UElements...>())
853 noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value)
854 { _Inherited::_M_swap(__in); }
857 #if __cpp_deduction_guides >= 201606
858 template<
typename... _UTypes>
860 template<
typename _T1,
typename _T2>
862 template<
typename _Alloc,
typename... _UTypes>
864 template<
typename _Alloc,
typename _T1,
typename _T2>
866 template<
typename _Alloc,
typename... _UTypes>
875 void swap(
tuple&) noexcept { }
880 template<
typename _Alloc>
882 tuple(allocator_arg_t,
const _Alloc&) noexcept { }
883 template<
typename _Alloc>
885 tuple(allocator_arg_t,
const _Alloc&,
const tuple&) noexcept { }
890 template<
typename _T1,
typename _T2>
896 template<
bool _Dummy,
typename _U1,
typename _U2>
897 using _ImplicitDefaultCtor = __enable_if_t<
898 _TupleConstraints<_Dummy, _U1, _U2>::
899 __is_implicitly_default_constructible(),
903 template<
bool _Dummy,
typename _U1,
typename _U2>
904 using _ExplicitDefaultCtor = __enable_if_t<
905 _TupleConstraints<_Dummy, _U1, _U2>::
906 __is_explicitly_default_constructible(),
909 template<
bool _Dummy>
910 using _TCC = _TupleConstraints<_Dummy, _T1, _T2>;
913 template<
bool _Cond,
typename _U1,
typename _U2>
914 using _ImplicitCtor = __enable_if_t<
915 _TCC<_Cond>::template __is_implicitly_constructible<_U1, _U2>(),
919 template<
bool _Cond,
typename _U1,
typename _U2>
920 using _ExplicitCtor = __enable_if_t<
921 _TCC<_Cond>::template __is_explicitly_constructible<_U1, _U2>(),
924 template<
typename _U1,
typename _U2>
925 static constexpr
bool __assignable()
927 return __and_<is_assignable<_T1&, _U1>,
931 template<
typename _U1,
typename _U2>
932 static constexpr
bool __nothrow_assignable()
934 return __and_<is_nothrow_assignable<_T1&, _U1>,
938 template<
typename _U1,
typename _U2>
939 static constexpr
bool __nothrow_constructible()
941 return __and_<is_nothrow_constructible<_T1, _U1>,
945 static constexpr
bool __nothrow_default_constructible()
947 return __and_<is_nothrow_default_constructible<_T1>,
951 template<
typename _U1>
952 static constexpr
bool __is_alloc_arg()
956 template<
bool _Dummy =
true,
957 _ImplicitDefaultCtor<_Dummy, _T1, _T2> =
true>
960 noexcept(__nothrow_default_constructible())
963 template<
bool _Dummy =
true,
964 _ExplicitDefaultCtor<_Dummy, _T1, _T2> =
false>
967 noexcept(__nothrow_default_constructible())
970 template<
bool _Dummy =
true,
971 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
973 tuple(
const _T1& __a1,
const _T2& __a2)
974 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
977 template<
bool _Dummy =
true,
978 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
980 tuple(
const _T1& __a1,
const _T2& __a2)
981 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
984 template<
typename _U1,
typename _U2,
985 _ImplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
true>
987 tuple(_U1&& __a1, _U2&& __a2)
988 noexcept(__nothrow_constructible<_U1, _U2>())
989 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
991 template<
typename _U1,
typename _U2,
992 _ExplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
false>
994 tuple(_U1&& __a1, _U2&& __a2)
995 noexcept(__nothrow_constructible<_U1, _U2>())
996 :
_Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
1002 template<
typename _U1,
typename _U2,
1003 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1006 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1009 template<
typename _U1,
typename _U2,
1010 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1013 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1016 template<
typename _U1,
typename _U2,
1017 _ImplicitCtor<true, _U1, _U2> =
true>
1020 noexcept(__nothrow_constructible<_U1, _U2>())
1023 template<
typename _U1,
typename _U2,
1024 _ExplicitCtor<true, _U1, _U2> =
false>
1027 noexcept(__nothrow_constructible<_U1, _U2>())
1030 template<
typename _U1,
typename _U2,
1031 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1034 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1037 template<
typename _U1,
typename _U2,
1038 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1041 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1044 template<
typename _U1,
typename _U2,
1045 _ImplicitCtor<true, _U1, _U2> =
true>
1048 noexcept(__nothrow_constructible<_U1, _U2>())
1050 std::forward<_U2>(__in.second)) { }
1052 template<
typename _U1,
typename _U2,
1053 _ExplicitCtor<true, _U1, _U2> =
false>
1056 noexcept(__nothrow_constructible<_U1, _U2>())
1058 std::forward<_U2>(__in.second)) { }
1062 template<
typename _Alloc,
1063 _ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> =
true>
1064 _GLIBCXX20_CONSTEXPR
1068 template<
typename _Alloc,
bool _Dummy =
true,
1069 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
1070 _GLIBCXX20_CONSTEXPR
1072 const _T1& __a1,
const _T2& __a2)
1075 template<
typename _Alloc,
bool _Dummy =
true,
1076 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
1078 _GLIBCXX20_CONSTEXPR
1080 const _T1& __a1,
const _T2& __a2)
1083 template<
typename _Alloc,
typename _U1,
typename _U2,
1084 _ImplicitCtor<true, _U1, _U2> =
true>
1085 _GLIBCXX20_CONSTEXPR
1087 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1088 std::forward<_U2>(__a2)) { }
1090 template<
typename _Alloc,
typename _U1,
typename _U2,
1091 _ExplicitCtor<true, _U1, _U2> =
false>
1093 _GLIBCXX20_CONSTEXPR
1095 _U1&& __a1, _U2&& __a2)
1096 :
_Inherited(__tag, __a, std::forward<_U1>(__a1),
1097 std::forward<_U2>(__a2)) { }
1099 template<
typename _Alloc>
1100 _GLIBCXX20_CONSTEXPR
1104 template<
typename _Alloc>
1105 _GLIBCXX20_CONSTEXPR
1109 template<
typename _Alloc,
typename _U1,
typename _U2,
1110 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1111 _GLIBCXX20_CONSTEXPR
1118 template<
typename _Alloc,
typename _U1,
typename _U2,
1119 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1121 _GLIBCXX20_CONSTEXPR
1128 template<
typename _Alloc,
typename _U1,
typename _U2,
1129 _ImplicitCtor<true, _U1, _U2> =
true>
1130 _GLIBCXX20_CONSTEXPR
1135 template<
typename _Alloc,
typename _U1,
typename _U2,
1136 _ExplicitCtor<true, _U1, _U2> =
false>
1138 _GLIBCXX20_CONSTEXPR
1143 template<
typename _Alloc,
typename _U1,
typename _U2,
1144 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
1145 _GLIBCXX20_CONSTEXPR
1148 :
_Inherited(__tag, __a, __in.first, __in.second) { }
1150 template<
typename _Alloc,
typename _U1,
typename _U2,
1151 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
1153 _GLIBCXX20_CONSTEXPR
1156 :
_Inherited(__tag, __a, __in.first, __in.second) { }
1158 template<
typename _Alloc,
typename _U1,
typename _U2,
1159 _ImplicitCtor<true, _U1, _U2> =
true>
1160 _GLIBCXX20_CONSTEXPR
1162 :
_Inherited(__tag, __a, std::forward<_U1>(__in.first),
1163 std::forward<_U2>(__in.second)) { }
1165 template<
typename _Alloc,
typename _U1,
typename _U2,
1166 _ExplicitCtor<true, _U1, _U2> =
false>
1168 _GLIBCXX20_CONSTEXPR
1170 :
_Inherited(__tag, __a, std::forward<_U1>(__in.first),
1171 std::forward<_U2>(__in.second)) { }
1175 _GLIBCXX20_CONSTEXPR
1177 operator=(
typename conditional<__assignable<const _T1&, const _T2&>(),
1179 const __nonesuch&>::type __in)
1180 noexcept(__nothrow_assignable<const _T1&, const _T2&>())
1182 this->_M_assign(__in);
1186 _GLIBCXX20_CONSTEXPR
1188 operator=(
typename conditional<__assignable<_T1, _T2>(),
1190 __nonesuch&&>::type __in)
1191 noexcept(__nothrow_assignable<_T1, _T2>())
1197 template<
typename _U1,
typename _U2>
1198 _GLIBCXX20_CONSTEXPR
1199 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
1201 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1203 this->_M_assign(__in);
1207 template<
typename _U1,
typename _U2>
1208 _GLIBCXX20_CONSTEXPR
1209 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
1211 noexcept(__nothrow_assignable<_U1, _U2>())
1217 template<
typename _U1,
typename _U2>
1218 _GLIBCXX20_CONSTEXPR
1219 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
1221 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1223 this->_M_head(*
this) = __in.first;
1224 this->_M_tail(*this)._M_head(*
this) = __in.second;
1228 template<
typename _U1,
typename _U2>
1229 _GLIBCXX20_CONSTEXPR
1230 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
1232 noexcept(__nothrow_assignable<_U1, _U2>())
1234 this->_M_head(*
this) = std::forward<_U1>(__in.first);
1235 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.second);
1239 _GLIBCXX20_CONSTEXPR
1242 noexcept(__and_<__is_nothrow_swappable<_T1>,
1243 __is_nothrow_swappable<_T2>>::value)
1244 { _Inherited::_M_swap(__in); }
1249 template<
typename... _Elements>
1253 #if __cplusplus > 201402L
1254 template <
typename _Tp>
1262 template<std::size_t __i,
typename _Head,
typename... _Tail>
1269 template<
typename _Head,
typename... _Tail>
1278 template<
size_t __i>
1282 "tuple index is in range");
1285 template<std::size_t __i,
typename _Head,
typename... _Tail>
1290 template<std::size_t __i,
typename _Head,
typename... _Tail>
1291 constexpr
const _Head&
1292 __get_helper(
const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
1293 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1296 template<std::size_t __i,
typename... _Elements>
1297 constexpr __tuple_element_t<__i, tuple<_Elements...>>&
1299 {
return std::__get_helper<__i>(__t); }
1302 template<std::size_t __i,
typename... _Elements>
1303 constexpr
const __tuple_element_t<__i, tuple<_Elements...>>&
1305 {
return std::__get_helper<__i>(__t); }
1308 template<std::size_t __i,
typename... _Elements>
1309 constexpr __tuple_element_t<__i, tuple<_Elements...>>&&
1312 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1313 return std::forward<__element_type&&>(std::get<__i>(__t));
1317 template<std::size_t __i,
typename... _Elements>
1318 constexpr
const __tuple_element_t<__i, tuple<_Elements...>>&&
1321 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
1322 return std::forward<const __element_type&&>(std::get<__i>(__t));
1325 #if __cplusplus >= 201402L
1327 #define __cpp_lib_tuples_by_type 201304
1329 template<
typename _Head,
size_t __i,
typename... _Tail>
1331 __get_helper2(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
1332 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1334 template<
typename _Head,
size_t __i,
typename... _Tail>
1335 constexpr
const _Head&
1336 __get_helper2(
const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
1337 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
1340 template <
typename _Tp,
typename... _Types>
1343 {
return std::__get_helper2<_Tp>(__t); }
1346 template <
typename _Tp,
typename... _Types>
1349 {
return std::forward<_Tp&&>(std::__get_helper2<_Tp>(__t)); }
1352 template <
typename _Tp,
typename... _Types>
1353 constexpr
const _Tp&
1355 {
return std::__get_helper2<_Tp>(__t); }
1359 template <
typename _Tp,
typename... _Types>
1360 constexpr
const _Tp&&
1362 {
return std::forward<const _Tp&&>(std::__get_helper2<_Tp>(__t)); }
1366 template<
typename _Tp,
typename _Up,
size_t __i,
size_t __size>
1367 struct __tuple_compare
1369 static constexpr
bool
1370 __eq(
const _Tp& __t,
const _Up& __u)
1372 return bool(std::get<__i>(__t) == std::get<__i>(__u))
1373 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u);
1376 static constexpr
bool
1377 __less(
const _Tp& __t,
const _Up& __u)
1379 return bool(std::get<__i>(__t) < std::get<__i>(__u))
1380 || (!bool(std::get<__i>(__u) < std::get<__i>(__t))
1381 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u));
1385 template<
typename _Tp,
typename _Up,
size_t __size>
1386 struct __tuple_compare<_Tp, _Up, __size, __size>
1388 static constexpr
bool
1389 __eq(
const _Tp&,
const _Up&) {
return true; }
1391 static constexpr
bool
1392 __less(
const _Tp&,
const _Up&) {
return false; }
1395 template<
typename... _TElements,
typename... _UElements>
1397 operator==(
const tuple<_TElements...>& __t,
1398 const tuple<_UElements...>& __u)
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::__eq(__t, __u);
1408 #if __cpp_lib_three_way_comparison
1409 template<
typename _Cat,
typename _Tp,
typename _Up>
1411 __tuple_cmp(
const _Tp&,
const _Up&, index_sequence<>)
1412 {
return _Cat::equivalent; }
1414 template<
typename _Cat,
typename _Tp,
typename _Up,
1415 size_t _Idx0,
size_t... _Idxs>
1417 __tuple_cmp(
const _Tp& __t,
const _Up& __u,
1418 index_sequence<_Idx0, _Idxs...>)
1421 = __detail::__synth3way(std::get<_Idx0>(__t), std::get<_Idx0>(__u));
1424 return std::__tuple_cmp<_Cat>(__t, __u, index_sequence<_Idxs...>());
1427 template<
typename... _Tps,
typename... _Ups>
1429 common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>
1430 operator<=>(
const tuple<_Tps...>& __t,
const tuple<_Ups...>& __u)
1433 = common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>;
1434 return std::__tuple_cmp<_Cat>(__t, __u, index_sequence_for<_Tps...>());
1437 template<
typename... _TElements,
typename... _UElements>
1439 operator<(
const tuple<_TElements...>& __t,
1440 const tuple<_UElements...>& __u)
1442 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
1443 "tuple objects can only be compared if they have equal sizes.");
1444 using __compare = __tuple_compare<tuple<_TElements...>,
1445 tuple<_UElements...>,
1446 0,
sizeof...(_TElements)>;
1447 return __compare::__less(__t, __u);
1450 template<
typename... _TElements,
typename... _UElements>
1452 operator!=(
const tuple<_TElements...>& __t,
1453 const tuple<_UElements...>& __u)
1454 {
return !(__t == __u); }
1456 template<
typename... _TElements,
typename... _UElements>
1458 operator>(
const tuple<_TElements...>& __t,
1459 const tuple<_UElements...>& __u)
1460 {
return __u < __t; }
1462 template<
typename... _TElements,
typename... _UElements>
1464 operator<=(
const tuple<_TElements...>& __t,
1465 const tuple<_UElements...>& __u)
1466 {
return !(__u < __t); }
1468 template<
typename... _TElements,
typename... _UElements>
1470 operator>=(
const tuple<_TElements...>& __t,
1471 const tuple<_UElements...>& __u)
1472 {
return !(__t < __u); }
1476 template<
typename... _Elements>
1477 constexpr tuple<typename __decay_and_strip<_Elements>::__type...>
1478 make_tuple(_Elements&&... __args)
1480 typedef tuple<typename __decay_and_strip<_Elements>::__type...>
1482 return __result_type(std::forward<_Elements>(__args)...);
1488 template<
typename... _Elements>
1489 constexpr tuple<_Elements&&...>
1491 {
return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
1493 template<
size_t,
typename,
typename,
size_t>
1494 struct __make_tuple_impl;
1496 template<
size_t _Idx,
typename _Tuple,
typename... _Tp,
size_t _Nm>
1497 struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
1498 : __make_tuple_impl<_Idx + 1,
1499 tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
1503 template<std::size_t _Nm,
typename _Tuple,
typename... _Tp>
1504 struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
1506 typedef tuple<_Tp...> __type;
1509 template<
typename _Tuple>
1510 struct __do_make_tuple
1511 : __make_tuple_impl<0, tuple<>, _Tuple, std::tuple_size<_Tuple>::value>
1515 template<
typename _Tuple>
1517 :
public __do_make_tuple<__remove_cvref_t<_Tuple>>
1521 template<
typename...>
1522 struct __combine_tuples;
1525 struct __combine_tuples<>
1527 typedef tuple<> __type;
1530 template<
typename... _Ts>
1531 struct __combine_tuples<tuple<_Ts...>>
1533 typedef tuple<_Ts...> __type;
1536 template<
typename... _T1s,
typename... _T2s,
typename... _Rem>
1537 struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
1539 typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
1540 _Rem...>::__type __type;
1544 template<
typename... _Tpls>
1545 struct __tuple_cat_result
1547 typedef typename __combine_tuples
1548 <
typename __make_tuple<_Tpls>::__type...>::__type __type;
1553 template<
typename...>
1554 struct __make_1st_indices;
1557 struct __make_1st_indices<>
1559 typedef std::_Index_tuple<> __type;
1562 template<
typename _Tp,
typename... _Tpls>
1563 struct __make_1st_indices<_Tp, _Tpls...>
1566 typename std::remove_reference<_Tp>::type>::value>::__type __type;
1572 template<
typename _Ret,
typename _Indices,
typename... _Tpls>
1573 struct __tuple_concater;
1575 template<
typename _Ret, std::size_t... _Is,
typename _Tp,
typename... _Tpls>
1576 struct __tuple_concater<_Ret,
std::_Index_tuple<_Is...>, _Tp, _Tpls...>
1578 template<
typename... _Us>
1579 static constexpr _Ret
1580 _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
1582 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1583 typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
1584 return __next::_S_do(std::forward<_Tpls>(__tps)...,
1585 std::forward<_Us>(__us)...,
1586 std::get<_Is>(std::forward<_Tp>(__tp))...);
1590 template<
typename _Ret>
1591 struct __tuple_concater<_Ret,
std::_Index_tuple<>>
1593 template<
typename... _Us>
1594 static constexpr _Ret
1595 _S_do(_Us&&... __us)
1597 return _Ret(std::forward<_Us>(__us)...);
1602 template<
typename... _Tpls,
typename =
typename
1603 enable_if<__and_<__is_tuple_like<_Tpls>...>::value>::type>
1606 ->
typename __tuple_cat_result<_Tpls...>::__type
1608 typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
1609 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
1610 typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
1611 return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
1617 template<
typename... _Elements>
1618 constexpr tuple<_Elements&...>
1619 tie(_Elements&... __args) noexcept
1620 {
return tuple<_Elements&...>(__args...); }
1623 template<
typename... _Elements>
1624 _GLIBCXX20_CONSTEXPR
1626 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
1628 typename enable_if<__and_<__is_swappable<_Elements>...>::value
1634 noexcept(noexcept(__x.swap(__y)))
1637 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
1638 template<
typename... _Elements>
1639 _GLIBCXX20_CONSTEXPR
1640 typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type
1641 swap(tuple<_Elements...>&, tuple<_Elements...>&) =
delete;
1648 struct _Swallow_assign
1651 _GLIBCXX14_CONSTEXPR
const _Swallow_assign&
1652 operator=(
const _Tp&)
const
1658 _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{};
1661 template<
typename... _Types,
typename _Alloc>
1673 template<
class _T1,
class _T2>
1674 template<
typename... _Args1,
typename... _Args2>
1675 _GLIBCXX20_CONSTEXPR
1680 :
pair(__first, __second,
1681 typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
1682 typename _Build_index_tuple<sizeof...(_Args2)>::__type())
1685 template<
class _T1,
class _T2>
1686 template<
typename... _Args1, std::size_t... _Indexes1,
1687 typename... _Args2, std::size_t... _Indexes2>
1688 _GLIBCXX20_CONSTEXPR
inline
1691 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
1692 : first(
std::
forward<_Args1>(
std::get<_Indexes1>(__tuple1))...),
1693 second(
std::
forward<_Args2>(
std::get<_Indexes2>(__tuple2))...)
1696 #if __cplusplus >= 201703L
1702 template<
template<
typename...>
class _Trait,
typename _Tp,
typename _Tuple>
1703 inline constexpr
bool __unpack_std_tuple =
false;
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, tuple<_Up...>&>
1711 = _Trait<_Tp, _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 template<
template<
typename...>
class _Trait,
typename _Tp,
typename... _Up>
1718 inline constexpr
bool __unpack_std_tuple<_Trait, _Tp,
const tuple<_Up...>&>
1719 = _Trait<_Tp,
const _Up&...>::value;
1721 # define __cpp_lib_apply 201603
1723 template <
typename _Fn,
typename _Tuple,
size_t... _Idx>
1724 constexpr decltype(
auto)
1728 std::get<_Idx>(std::forward<_Tuple>(__t))...);
1731 template <
typename _Fn,
typename _Tuple>
1732 constexpr decltype(
auto)
1733 apply(_Fn&& __f, _Tuple&& __t)
1734 noexcept(__unpack_std_tuple<is_nothrow_invocable, _Fn, _Tuple>)
1737 = make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>;
1738 return std::__apply_impl(std::forward<_Fn>(__f),
1739 std::forward<_Tuple>(__t),
1743 #define __cpp_lib_make_from_tuple 201606
1745 template <
typename _Tp,
typename _Tuple,
size_t... _Idx>
1747 __make_from_tuple_impl(_Tuple&& __t, index_sequence<_Idx...>)
1748 {
return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...); }
1750 template <
typename _Tp,
typename _Tuple>
1752 make_from_tuple(_Tuple&& __t)
1753 noexcept(__unpack_std_tuple<is_nothrow_constructible, _Tp, _Tuple>)
1755 return __make_from_tuple_impl<_Tp>(
1756 std::forward<_Tuple>(__t),
1763 _GLIBCXX_END_NAMESPACE_VERSION
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
constexpr auto tuple_cat(_Tpls &&... __tpls) -> typename __tuple_cat_result< _Tpls... >::__type
tuple_cat
constexpr tuple< _Elements &... > tie(_Elements &... __args) noexcept
tie
constexpr __invoke_result< _Callable, _Args... >::type __invoke(_Callable &&__fn, _Args &&... __args) noexcept(__is_nothrow_invocable< _Callable, _Args... >::value)
Invoke a callable object.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr tuple< _Elements &&... > forward_as_tuple(_Elements &&... __args) noexcept
std::forward_as_tuple
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.
make_integer_sequence< size_t, _Num > make_index_sequence
Alias template make_index_sequence.
integer_sequence< size_t, _Idx... > index_sequence
Alias template index_sequence.
Primary class template, tuple.
Partial specialization, 2-element tuple. Includes construction and assignment from a pair.
Define a member typedef type to one of two argument types.
is_nothrow_default_constructible
is_nothrow_move_constructible
Define a member typedef type only if a boolean constant is true.
Declare uses_allocator so it can be specialized in <queue> etc.
Tag type for piecewise construction of std::pair objects.
Struct holding two objects of arbitrary type.