299 static constexpr const _Inherited&
300 _M_tail(
const _Tuple_impl& __t)
noexcept {
return __t; }
302 constexpr _Tuple_impl()
303 : _Inherited(), _Base() { }
306 _Tuple_impl(
const _Head& __head,
const _Tail&... __tail)
307 : _Inherited(__tail...), _Base(__head)
310 template<
typename _UHead,
typename... _UTail,
311 typename = __enable_if_t<
sizeof...(_Tail) ==
sizeof...(_UTail)>>
313 _Tuple_impl(_UHead&& __head, _UTail&&... __tail)
314 : _Inherited(
std::
forward<_UTail>(__tail)...),
318 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
322 _Tuple_impl& operator=(
const _Tuple_impl&) =
delete;
324 _Tuple_impl(_Tuple_impl&&) =
default;
326 template<
typename... _UElements>
328 _Tuple_impl(
const _Tuple_impl<_Idx, _UElements...>& __in)
329 : _Inherited(_Tuple_impl<_Idx, _UElements...>::_M_tail(__in)),
330 _Base(_Tuple_impl<_Idx, _UElements...>::_M_head(__in))
333 template<
typename _UHead,
typename... _UTails>
335 _Tuple_impl(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
337 (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))),
339 (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in)))
342#if __cpp_lib_ranges_zip
343 template<
typename... _UElements>
345 _Tuple_impl(_Tuple_impl<_Idx, _UElements...>& __in)
346 : _Inherited(_Tuple_impl<_Idx, _UElements...>::_M_tail(__in)),
347 _Base(_Tuple_impl<_Idx, _UElements...>::_M_head(__in))
350 template<
typename _UHead,
typename... _UTails>
352 _Tuple_impl(
const _Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
354 (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))),
356 (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in)))
360#if __cpp_lib_tuple_like
361 template<
typename _UTuple,
size_t... _Is>
363 _Tuple_impl(__tuple_like_tag_t, _UTuple&& __u, index_sequence<_Is...>)
368 template<
typename _Alloc>
370 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a)
371 : _Inherited(__tag, __a),
372 _Base(__tag, __use_alloc<_Head>(__a))
375 template<
typename _Alloc>
377 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
378 const _Head& __head,
const _Tail&... __tail)
379 : _Inherited(__tag, __a, __tail...),
380 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head)
383 template<
typename _Alloc,
typename _UHead,
typename... _UTail,
384 typename = __enable_if_t<
sizeof...(_Tail) ==
sizeof...(_UTail)>>
386 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
387 _UHead&& __head, _UTail&&... __tail)
388 : _Inherited(__tag, __a,
std::
forward<_UTail>(__tail)...),
389 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
393 template<
typename _Alloc>
395 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
396 const _Tuple_impl& __in)
397 : _Inherited(__tag, __a, _M_tail(__in)),
398 _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in))
401 template<
typename _Alloc>
403 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
405 : _Inherited(__tag, __a,
std::
move(_M_tail(__in))),
406 _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
410 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
412 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
413 const _Tuple_impl<_Idx, _UHead, _UTails...>& __in)
414 : _Inherited(__tag, __a,
415 _Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in)),
416 _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
417 _Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))
420 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
422 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
423 _Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
424 : _Inherited(__tag, __a,
std::
move
425 (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))),
426 _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
428 (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in)))
431#if __cpp_lib_ranges_zip
432 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
434 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
435 _Tuple_impl<_Idx, _UHead, _UTails...>& __in)
436 : _Inherited(__tag, __a,
437 _Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in)),
438 _Base(__use_alloc<_Head, _Alloc, _UHead&>(__a),
439 _Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))
442 template<
typename _Alloc,
typename _UHead,
typename... _UTails>
444 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a,
445 const _Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
446 : _Inherited(__tag, __a,
std::
move
447 (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))),
448 _Base(__use_alloc<_Head, _Alloc, const _UHead>(__a),
450 (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in)))
454#if __cpp_lib_tuple_like
455 template<
typename _Alloc,
typename _UTuple,
size_t... _Is>
457 _Tuple_impl(__tuple_like_tag_t, allocator_arg_t __tag,
const _Alloc& __a,
458 _UTuple&& __u, index_sequence<_Is...>)
459 : _Tuple_impl(__tag, __a,
std::get<_Is>(
std::
forward<_UTuple>(__u))...)
463 template<
typename... _UElements>
466 _M_assign(
const _Tuple_impl<_Idx, _UElements...>& __in)
468 _M_head(*
this) = _Tuple_impl<_Idx, _UElements...>::_M_head(__in);
469 _M_tail(*this)._M_assign(
470 _Tuple_impl<_Idx, _UElements...>::_M_tail(__in));
473 template<
typename _UHead,
typename... _UTails>
476 _M_assign(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
478 _M_head(*
this) = std::forward<_UHead>
479 (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in));
480 _M_tail(*this)._M_assign(
481 std::move(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in)));
484#if __cpp_lib_ranges_zip
485 template<
typename... _UElements>
487 _M_assign(
const _Tuple_impl<_Idx, _UElements...>& __in)
const
489 _M_head(*
this) = _Tuple_impl<_Idx, _UElements...>::_M_head(__in);
490 _M_tail(*this)._M_assign(
491 _Tuple_impl<_Idx, _UElements...>::_M_tail(__in));
494 template<
typename _UHead,
typename... _UTails>
496 _M_assign(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
const
498 _M_head(*
this) = std::forward<_UHead>
499 (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in));
500 _M_tail(*this)._M_assign(
501 std::move(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in)));
505#if __cpp_lib_tuple_like
506 template<
typename _UTuple>
508 _M_assign(__tuple_like_tag_t __tag, _UTuple&& __u)
510 _M_head(*
this) = std::get<_Idx>(std::forward<_UTuple>(__u));
511 _M_tail(*this)._M_assign(__tag, std::forward<_UTuple>(__u));
514 template<
typename _UTuple>
516 _M_assign(__tuple_like_tag_t __tag, _UTuple&& __u)
const
518 _M_head(*
this) = std::get<_Idx>(std::forward<_UTuple>(__u));
519 _M_tail(*this)._M_assign(__tag, std::forward<_UTuple>(__u));
526 _M_swap(_Tuple_impl& __in)
529 swap(_M_head(*
this), _M_head(__in));
530 _Inherited::_M_swap(_M_tail(__in));
533#if __cpp_lib_ranges_zip
535 _M_swap(
const _Tuple_impl& __in)
const
538 swap(_M_head(*
this), _M_head(__in));
539 _Inherited::_M_swap(_M_tail(__in));
545 template<
size_t _Idx,
typename _Head>
546 struct _Tuple_impl<_Idx, _Head>
547 :
private _Head_base<_Idx, _Head>
549 template<size_t,
typename...>
friend struct _Tuple_impl;
551 typedef _Head_base<_Idx, _Head> _Base;
553 static constexpr _Head&
554 _M_head(_Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
556 static constexpr const _Head&
557 _M_head(
const _Tuple_impl& __t)
noexcept {
return _Base::_M_head(__t); }
564 _Tuple_impl(
const _Head& __head)
568 template<
typename _UHead>
570 _Tuple_impl(_UHead&& __head)
574 constexpr _Tuple_impl(
const _Tuple_impl&) =
default;
578 _Tuple_impl& operator=(
const _Tuple_impl&) =
delete;
580#if _GLIBCXX_INLINE_VERSION
581 _Tuple_impl(_Tuple_impl&&) =
default;
584 _Tuple_impl(_Tuple_impl&& __in)
585 noexcept(is_nothrow_move_constructible<_Head>::value)
586 : _Base(static_cast<_Base&&>(__in))
590 template<
typename _UHead>
592 _Tuple_impl(
const _Tuple_impl<_Idx, _UHead>& __in)
593 : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in))
596 template<
typename _UHead>
598 _Tuple_impl(_Tuple_impl<_Idx, _UHead>&& __in)
599 : _Base(
std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
602#if __cpp_lib_ranges_zip
603 template<
typename _UHead>
605 _Tuple_impl(_Tuple_impl<_Idx, _UHead>& __in)
606 : _Base(_Tuple_impl<_Idx, _UHead>::_M_head(__in))
609 template<
typename _UHead>
611 _Tuple_impl(
const _Tuple_impl<_Idx, _UHead>&& __in)
612 : _Base(
std::
forward<const _UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
616#if __cpp_lib_tuple_like
617 template<
typename _UTuple>
619 _Tuple_impl(__tuple_like_tag_t, _UTuple&& __u, index_sequence<0>)
624 template<
typename _Alloc>
626 _Tuple_impl(allocator_arg_t __tag,
const _Alloc& __a)
627 : _Base(__tag, __use_alloc<_Head>(__a))
630 template<
typename _Alloc>
632 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
634 : _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), __head)
637 template<
typename _Alloc,
typename _UHead>
639 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
641 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
645 template<
typename _Alloc>
647 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
648 const _Tuple_impl& __in)
649 : _Base(__use_alloc<_Head, _Alloc, const _Head&>(__a), _M_head(__in))
652 template<
typename _Alloc>
654 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
656 : _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
660 template<
typename _Alloc,
typename _UHead>
662 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
663 const _Tuple_impl<_Idx, _UHead>& __in)
664 : _Base(__use_alloc<_Head, _Alloc, const _UHead&>(__a),
665 _Tuple_impl<_Idx, _UHead>::_M_head(__in))
668 template<
typename _Alloc,
typename _UHead>
670 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
671 _Tuple_impl<_Idx, _UHead>&& __in)
672 : _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
673 std::
forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
676#if __cpp_lib_ranges_zip
677 template<
typename _Alloc,
typename _UHead>
679 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
680 _Tuple_impl<_Idx, _UHead>& __in)
681 : _Base(__use_alloc<_Head, _Alloc, _UHead&>(__a),
682 _Tuple_impl<_Idx, _UHead>::_M_head(__in))
685 template<
typename _Alloc,
typename _UHead>
687 _Tuple_impl(allocator_arg_t,
const _Alloc& __a,
688 const _Tuple_impl<_Idx, _UHead>&& __in)
689 : _Base(__use_alloc<_Head, _Alloc, const _UHead>(__a),
690 std::
forward<const _UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in)))
694#if __cpp_lib_tuple_like
695 template<
typename _Alloc,
typename _UTuple>
697 _Tuple_impl(__tuple_like_tag_t, allocator_arg_t __tag,
const _Alloc& __a,
698 _UTuple&& __u, index_sequence<0>)
699 : _Tuple_impl(__tag, __a,
std::get<0>(
std::
forward<_UTuple>(__u)))
703 template<
typename _UHead>
706 _M_assign(
const _Tuple_impl<_Idx, _UHead>& __in)
708 _M_head(*
this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in);
711 template<
typename _UHead>
714 _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
717 = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
720#if __cpp_lib_ranges_zip
721 template<
typename _UHead>
723 _M_assign(
const _Tuple_impl<_Idx, _UHead>& __in)
const
725 _M_head(*
this) = _Tuple_impl<_Idx, _UHead>::_M_head(__in);
728 template<
typename _UHead>
730 _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
const
733 = std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
737#if __cpp_lib_tuple_like
738 template<
typename _UTuple>
740 _M_assign(__tuple_like_tag_t, _UTuple&& __u)
741 { _M_head(*
this) = std::get<_Idx>(std::forward<_UTuple>(__u)); }
743 template<
typename _UTuple>
745 _M_assign(__tuple_like_tag_t, _UTuple&& __u)
const
746 { _M_head(*
this) = std::get<_Idx>(std::forward<_UTuple>(__u)); }
752 _M_swap(_Tuple_impl& __in)
755 swap(_M_head(*
this), _M_head(__in));
758#if __cpp_lib_ranges_zip
760 _M_swap(
const _Tuple_impl& __in)
const
763 swap(_M_head(*
this), _M_head(__in));
770 template<bool,
typename... _Types>
771 struct _TupleConstraints
773 template<
typename... _UTypes>
774 using __constructible = __and_<is_constructible<_Types, _UTypes>...>;
776 template<
typename... _UTypes>
777 using __convertible = __and_<is_convertible<_UTypes, _Types>...>;
782 template<
typename... _UTypes>
783 static constexpr bool __is_implicitly_constructible()
785 return __and_<__constructible<_UTypes...>,
786 __convertible<_UTypes...>
793 template<
typename... _UTypes>
794 static constexpr bool __is_explicitly_constructible()
796 return __and_<__constructible<_UTypes...>,
797 __not_<__convertible<_UTypes...>>
801 static constexpr bool __is_implicitly_default_constructible()
803 return __and_<std::__is_implicitly_default_constructible<_Types>...
807 static constexpr bool __is_explicitly_default_constructible()
809 return __and_<is_default_constructible<_Types>...,
811 std::__is_implicitly_default_constructible<_Types>...>
818 template<
typename... _Types>
819 struct _TupleConstraints<false, _Types...>
821 template<
typename... _UTypes>
822 static constexpr bool __is_implicitly_constructible()
825 template<
typename... _UTypes>
826 static constexpr bool __is_explicitly_constructible()
832 template<
typename... _Elements>
833 class tuple :
public _Tuple_impl<0, _Elements...>
835 using _Inherited = _Tuple_impl<0, _Elements...>;
837#if __cpp_concepts && __cpp_consteval && __cpp_conditional_explicit
838 template<
typename... _UTypes>
839 static consteval bool
842 if constexpr (
sizeof...(_UTypes) ==
sizeof...(_Elements))
848 template<
typename... _UTypes>
849 static consteval bool
850 __nothrow_constructible()
852 if constexpr (
sizeof...(_UTypes) ==
sizeof...(_Elements))
858 template<
typename... _UTypes>
859 static consteval bool
862 if constexpr (
sizeof...(_UTypes) ==
sizeof...(_Elements))
870 template<
typename... _UTypes>
871 static consteval bool
872 __disambiguating_constraint()
874 if constexpr (
sizeof...(_Elements) !=
sizeof...(_UTypes))
876 else if constexpr (
sizeof...(_Elements) == 1)
878 using _U0 =
typename _Nth_type<0, _UTypes...>::type;
879 return !is_same_v<remove_cvref_t<_U0>,
tuple>;
881 else if constexpr (
sizeof...(_Elements) < 4)
883 using _U0 =
typename _Nth_type<0, _UTypes...>::type;
884 if constexpr (!is_same_v<remove_cvref_t<_U0>, allocator_arg_t>)
888 using _T0 =
typename _Nth_type<0, _Elements...>::type;
889 return is_same_v<remove_cvref_t<_T0>, allocator_arg_t>;
898 template<
typename _Tuple>
899 static consteval bool
902 if constexpr (
sizeof...(_Elements) != 1)
904 else if constexpr (is_same_v<remove_cvref_t<_Tuple>,
tuple>)
908 using _Tp =
typename _Nth_type<0, _Elements...>::type;
909 if constexpr (is_convertible_v<_Tuple, _Tp>)
911 else if constexpr (is_constructible_v<_Tp, _Tuple>)
917 template<
typename... _Up>
918 static consteval bool
921#if __has_builtin(__reference_constructs_from_temporary)
922 return (__reference_constructs_from_temporary(_Elements, _Up&&)
929#if __cpp_lib_tuple_like
932 template<
typename _UTuple>
933 static consteval bool
934 __dangles_from_tuple_like()
937 return __dangles<decltype(std::get<_Is>(std::declval<_UTuple>()))...>();
941 template<
typename _UTuple>
942 static consteval bool
943 __constructible_from_tuple_like()
946 return __constructible<decltype(std::get<_Is>(std::declval<_UTuple>()))...>();
950 template<
typename _UTuple>
951 static consteval bool
952 __convertible_from_tuple_like()
955 return __convertible<decltype(std::get<_Is>(std::declval<_UTuple>()))...>();
962 explicit(!(__is_implicitly_default_constructible_v<_Elements> && ...))
964 noexcept((is_nothrow_default_constructible_v<_Elements> && ...))
965 requires (is_default_constructible_v<_Elements> && ...)
969 constexpr explicit(!__convertible<
const _Elements&...>())
970 tuple(
const _Elements&... __elements)
971 noexcept(__nothrow_constructible<
const _Elements&...>())
972 requires (__constructible<
const _Elements&...>())
973 : _Inherited(__elements...)
976 template<
typename... _UTypes>
977 requires (__disambiguating_constraint<_UTypes...>())
978 && (__constructible<_UTypes...>())
979 && (!__dangles<_UTypes...>())
980 constexpr explicit(!__convertible<_UTypes...>())
981 tuple(_UTypes&&... __u)
982 noexcept(__nothrow_constructible<_UTypes...>())
983 : _Inherited(std::forward<_UTypes>(__u)...)
986 template<
typename... _UTypes>
987 requires (__disambiguating_constraint<_UTypes...>())
988 && (__constructible<_UTypes...>())
989 && (__dangles<_UTypes...>())
990 tuple(_UTypes&&...) =
delete;
996 template<
typename... _UTypes>
997 requires (__constructible<
const _UTypes&...>())
998 && (!__use_other_ctor<
const tuple<_UTypes...>&>())
999 && (!__dangles<
const _UTypes&...>())
1000 constexpr explicit(!__convertible<
const _UTypes&...>())
1002 noexcept(__nothrow_constructible<
const _UTypes&...>())
1003 : _Inherited(
static_cast<const _Tuple_impl<0, _UTypes...
>&>(__u))
1006 template<
typename... _UTypes>
1007 requires (__constructible<
const _UTypes&...>())
1008 && (!__use_other_ctor<
const tuple<_UTypes...>&>())
1009 && (__dangles<
const _UTypes&...>())
1012 template<
typename... _UTypes>
1013 requires (__constructible<_UTypes...>())
1014 && (!__use_other_ctor<
tuple<_UTypes...>>())
1015 && (!__dangles<_UTypes...>())
1016 constexpr explicit(!__convertible<_UTypes...>())
1018 noexcept(__nothrow_constructible<_UTypes...>())
1019 : _Inherited(
static_cast<_Tuple_impl<0, _UTypes...
>&&>(__u))
1022 template<
typename... _UTypes>
1023 requires (__constructible<_UTypes...>())
1024 && (!__use_other_ctor<
tuple<_UTypes...>>())
1025 && (__dangles<_UTypes...>())
1028#if __cpp_lib_ranges_zip
1029 template<
typename... _UTypes>
1030 requires (__constructible<_UTypes&...>())
1031 && (!__use_other_ctor<
tuple<_UTypes...>&>())
1032 && (!__dangles<_UTypes&...>())
1033 constexpr explicit(!__convertible<_UTypes&...>())
1035 noexcept(__nothrow_constructible<_UTypes&...>())
1036 : _Inherited(
static_cast<_Tuple_impl<0, _UTypes...
>&>(__u))
1039 template<
typename... _UTypes>
1040 requires (__constructible<_UTypes&...>())
1041 && (!__use_other_ctor<
tuple<_UTypes...>&>())
1042 && (__dangles<_UTypes&...>())
1045 template<
typename... _UTypes>
1046 requires (__constructible<
const _UTypes...>())
1047 && (!__use_other_ctor<
const tuple<_UTypes...>>())
1048 && (!__dangles<
const _UTypes...>())
1049 constexpr explicit(!__convertible<
const _UTypes...>())
1051 noexcept(__nothrow_constructible<
const _UTypes...>())
1052 : _Inherited(
static_cast<const _Tuple_impl<0, _UTypes...
>&&>(__u))
1055 template<
typename... _UTypes>
1056 requires (__constructible<
const _UTypes...>())
1057 && (!__use_other_ctor<
const tuple<_UTypes...>>())
1058 && (__dangles<
const _UTypes...>())
1062 template<
typename _U1,
typename _U2>
1063 requires (
sizeof...(_Elements) == 2)
1064 && (__constructible<const _U1&, const _U2&>())
1065 && (!__dangles<const _U1&, const _U2&>())
1066 constexpr explicit(!__convertible<const _U1&, const _U2&>())
1068 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1069 : _Inherited(__u.first, __u.second)
1072 template<
typename _U1,
typename _U2>
1073 requires (
sizeof...(_Elements) == 2)
1074 && (__constructible<const _U1&, const _U2&>())
1075 && (__dangles<const _U1&, const _U2&>())
1078 template<
typename _U1,
typename _U2>
1079 requires (
sizeof...(_Elements) == 2)
1080 && (__constructible<_U1, _U2>())
1081 && (!__dangles<_U1, _U2>())
1082 constexpr explicit(!__convertible<_U1, _U2>())
1084 noexcept(__nothrow_constructible<_U1, _U2>())
1085 : _Inherited(std::forward<_U1>(__u.first),
1086 std::forward<_U2>(__u.second))
1089 template<
typename _U1,
typename _U2>
1090 requires (
sizeof...(_Elements) == 2)
1091 && (__constructible<_U1, _U2>())
1092 && (__dangles<_U1, _U2>())
1095#if __cpp_lib_ranges_zip
1096 template<
typename _U1,
typename _U2>
1097 requires (
sizeof...(_Elements) == 2)
1098 && (__constructible<_U1&, _U2&>())
1099 && (!__dangles<_U1&, _U2&>())
1100 constexpr explicit(!__convertible<_U1&, _U2&>())
1102 noexcept(__nothrow_constructible<_U1&, _U2&>())
1103 : _Inherited(__u.first, __u.second)
1106 template<
typename _U1,
typename _U2>
1107 requires (
sizeof...(_Elements) == 2)
1108 && (__constructible<_U1&, _U2&>())
1109 && (__dangles<_U1&, _U2&>())
1112 template<
typename _U1,
typename _U2>
1113 requires (
sizeof...(_Elements) == 2)
1114 && (__constructible<const _U1, const _U2>())
1115 && (!__dangles<const _U1, const _U2>())
1116 constexpr explicit(!__convertible<const _U1, const _U2>())
1118 noexcept(__nothrow_constructible<const _U1, const _U2>())
1119 : _Inherited(std::forward<const _U1>(__u.first),
1120 std::forward<const _U2>(__u.second))
1123 template<
typename _U1,
typename _U2>
1124 requires (
sizeof...(_Elements) == 2)
1125 && (__constructible<const _U1, const _U2>())
1126 && (__dangles<const _U1, const _U2>())
1130#if __cpp_lib_tuple_like
1131 template<__eligible_tuple_like<tuple> _UTuple>
1132 requires (__constructible_from_tuple_like<_UTuple>())
1133 && (!__use_other_ctor<_UTuple>())
1134 && (!__dangles_from_tuple_like<_UTuple>())
1135 constexpr explicit(!__convertible_from_tuple_like<_UTuple>())
1136 tuple(_UTuple&& __u)
1137 : _Inherited(__tuple_like_tag_t{},
1138 std::forward<_UTuple>(__u),
1142 template<__eligible_tuple_like<tuple> _UTuple>
1143 requires (__constructible_from_tuple_like<_UTuple>())
1144 && (!__use_other_ctor<_UTuple>())
1145 && (__dangles_from_tuple_like<_UTuple>())
1146 tuple(_UTuple&&) =
delete;
1151 template<
typename _Alloc>
1153 explicit(!(__is_implicitly_default_constructible_v<_Elements> && ...))
1154 tuple(allocator_arg_t __tag,
const _Alloc& __a)
1155 requires (is_default_constructible_v<_Elements> && ...)
1156 : _Inherited(__tag, __a)
1159 template<
typename _Alloc>
1160 constexpr explicit(!__convertible<
const _Elements&...>())
1161 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1162 const _Elements&... __elements)
1163 requires (__constructible<
const _Elements&...>())
1164 : _Inherited(__tag, __a, __elements...)
1167 template<
typename _Alloc,
typename... _UTypes>
1168 requires (__disambiguating_constraint<_UTypes...>())
1169 && (__constructible<_UTypes...>())
1170 && (!__dangles<_UTypes...>())
1171 constexpr explicit(!__convertible<_UTypes...>())
1172 tuple(allocator_arg_t __tag,
const _Alloc& __a, _UTypes&&... __u)
1173 : _Inherited(__tag, __a, std::forward<_UTypes>(__u)...)
1176 template<
typename _Alloc,
typename... _UTypes>
1177 requires (__disambiguating_constraint<_UTypes...>())
1178 && (__constructible<_UTypes...>())
1179 && (__dangles<_UTypes...>())
1180 tuple(allocator_arg_t,
const _Alloc&, _UTypes&&...) =
delete;
1182 template<
typename _Alloc>
1184 tuple(allocator_arg_t __tag,
const _Alloc& __a,
const tuple& __u)
1185 : _Inherited(__tag, __a,
static_cast<const _Inherited&
>(__u))
1188 template<
typename _Alloc>
1189 requires (__constructible<_Elements...>())
1191 tuple(allocator_arg_t __tag,
const _Alloc& __a,
tuple&& __u)
1192 : _Inherited(__tag, __a,
static_cast<_Inherited&&
>(__u))
1195 template<
typename _Alloc,
typename... _UTypes>
1196 requires (__constructible<
const _UTypes&...>())
1197 && (!__use_other_ctor<
const tuple<_UTypes...>&>())
1198 && (!__dangles<
const _UTypes&...>())
1199 constexpr explicit(!__convertible<
const _UTypes&...>())
1200 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1202 : _Inherited(__tag, __a,
1203 static_cast<const _Tuple_impl<0, _UTypes...
>&>(__u))
1206 template<
typename _Alloc,
typename... _UTypes>
1207 requires (__constructible<
const _UTypes&...>())
1208 && (!__use_other_ctor<
const tuple<_UTypes...>&>())
1209 && (__dangles<
const _UTypes&...>())
1212 template<
typename _Alloc,
typename... _UTypes>
1213 requires (__constructible<_UTypes...>())
1214 && (!__use_other_ctor<
tuple<_UTypes...>>())
1215 && (!__dangles<_UTypes...>())
1216 constexpr explicit(!__use_other_ctor<
tuple<_UTypes...>>())
1218 : _Inherited(__tag, __a,
static_cast<_Tuple_impl<0, _UTypes...
>&&>(__u))
1221 template<
typename _Alloc,
typename... _UTypes>
1222 requires (__constructible<_UTypes...>())
1223 && (!__use_other_ctor<
tuple<_UTypes...>>())
1224 && (__dangles<_UTypes...>())
1227#if __cpp_lib_ranges_zip
1228 template<
typename _Alloc,
typename... _UTypes>
1229 requires (__constructible<_UTypes&...>())
1230 && (!__use_other_ctor<
tuple<_UTypes...>&>())
1231 && (!__dangles<_UTypes&...>())
1232 constexpr explicit(!__convertible<_UTypes&...>())
1234 : _Inherited(__tag, __a,
static_cast<_Tuple_impl<0, _UTypes...
>&>(__u))
1237 template<
typename _Alloc,
typename... _UTypes>
1238 requires (__constructible<_UTypes&...>())
1239 && (!__use_other_ctor<
tuple<_UTypes...>&>())
1240 && (__dangles<_UTypes&...>())
1243 template<
typename _Alloc,
typename... _UTypes>
1244 requires (__constructible<
const _UTypes...>())
1245 && (!__use_other_ctor<
const tuple<_UTypes...>>())
1246 && (!__dangles<
const _UTypes...>())
1247 constexpr explicit(!__convertible<
const _UTypes...>())
1248 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1250 : _Inherited(__tag, __a,
1251 static_cast<const _Tuple_impl<0, _UTypes...
>&&>(__u))
1254 template<
typename _Alloc,
typename... _UTypes>
1255 requires (__constructible<
const _UTypes...>())
1256 && (!__use_other_ctor<
const tuple<_UTypes...>>())
1257 && (__dangles<
const _UTypes...>())
1261 template<
typename _Alloc,
typename _U1,
typename _U2>
1262 requires (
sizeof...(_Elements) == 2)
1263 && (__constructible<const _U1&, const _U2&>())
1264 && (!__dangles<const _U1&, const _U2&>())
1265 constexpr explicit(!__convertible<const _U1&, const _U2&>())
1266 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1268 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
1269 : _Inherited(__tag, __a, __u.first, __u.second)
1272 template<
typename _Alloc,
typename _U1,
typename _U2>
1273 requires (
sizeof...(_Elements) == 2)
1274 && (__constructible<const _U1&, const _U2&>())
1275 && (__dangles<const _U1&, const _U2&>())
1278 template<
typename _Alloc,
typename _U1,
typename _U2>
1279 requires (
sizeof...(_Elements) == 2)
1280 && (__constructible<_U1, _U2>())
1281 && (!__dangles<_U1, _U2>())
1282 constexpr explicit(!__convertible<_U1, _U2>())
1284 noexcept(__nothrow_constructible<_U1, _U2>())
1288 template<
typename _Alloc,
typename _U1,
typename _U2>
1289 requires (
sizeof...(_Elements) == 2)
1290 && (__constructible<_U1, _U2>())
1291 && (__dangles<_U1, _U2>())
1294#if __cpp_lib_ranges_zip
1295 template<
typename _Alloc,
typename _U1,
typename _U2>
1296 requires (
sizeof...(_Elements) == 2)
1297 && (__constructible<_U1&, _U2&>())
1298 && (!__dangles<_U1&, _U2&>())
1299 constexpr explicit(!__convertible<_U1&, _U2&>())
1301 noexcept(__nothrow_constructible<_U1&, _U2&>())
1302 : _Inherited(__tag, __a, __u.first, __u.second)
1305 template<
typename _Alloc,
typename _U1,
typename _U2>
1306 requires (
sizeof...(_Elements) == 2)
1307 && (__constructible<_U1&, _U2&>())
1308 && (__dangles<_U1&, _U2&>())
1311 template<
typename _Alloc,
typename _U1,
typename _U2>
1312 requires (
sizeof...(_Elements) == 2)
1313 && (__constructible<const _U1, const _U2>())
1314 && (!__dangles<const _U1, const _U2>())
1315 constexpr explicit(!__convertible<const _U1, const _U2>())
1316 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1318 noexcept(__nothrow_constructible<const _U1, const _U2>())
1322 template<
typename _Alloc,
typename _U1,
typename _U2>
1323 requires (
sizeof...(_Elements) == 2)
1324 && (__constructible<const _U1, const _U2>())
1325 && (__dangles<const _U1, const _U2>())
1329#if __cpp_lib_tuple_like
1330 template<
typename _Alloc, __eligible_tuple_like<tuple> _UTuple>
1331 requires (__constructible_from_tuple_like<_UTuple>())
1332 && (!__use_other_ctor<_UTuple>())
1333 && (!__dangles_from_tuple_like<_UTuple>())
1334 constexpr explicit(!__convertible_from_tuple_like<_UTuple>())
1335 tuple(allocator_arg_t __tag,
const _Alloc& __a, _UTuple&& __u)
1336 : _Inherited(__tuple_like_tag_t{},
1337 __tag, __a, std::forward<_UTuple>(__u),
1341 template<
typename _Alloc, __eligible_tuple_like<tuple> _UTuple>
1342 requires (__constructible_from_tuple_like<_UTuple>())
1343 && (!__use_other_ctor<_UTuple>())
1344 && (__dangles_from_tuple_like<_UTuple>())
1345 tuple(allocator_arg_t,
const _Alloc&, _UTuple&&) =
delete;
1350 template<
bool _Cond>
1351 using _TCC = _TupleConstraints<_Cond, _Elements...>;
1354 template<
bool _Dummy>
1355 using _ImplicitDefaultCtor = __enable_if_t<
1356 _TCC<_Dummy>::__is_implicitly_default_constructible(),
1360 template<
bool _Dummy>
1361 using _ExplicitDefaultCtor = __enable_if_t<
1362 _TCC<_Dummy>::__is_explicitly_default_constructible(),
1366 template<
bool _Cond,
typename... _Args>
1367 using _ImplicitCtor = __enable_if_t<
1368 _TCC<_Cond>::template __is_implicitly_constructible<_Args...>(),
1372 template<
bool _Cond,
typename... _Args>
1373 using _ExplicitCtor = __enable_if_t<
1374 _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(),
1378 template<
typename... _UElements>
1379 static constexpr bool __nothrow_constructible()
1382 __and_<is_nothrow_constructible<_Elements, _UElements>...>::value;
1386 template<
typename _Up>
1387 static constexpr bool __valid_args()
1389 return sizeof...(_Elements) == 1
1394 template<
typename,
typename,
typename... _Tail>
1395 static constexpr bool __valid_args()
1396 {
return (
sizeof...(_Tail) + 2) ==
sizeof...(_Elements); }
1407 template<
typename _Tuple,
typename =
tuple,
1408 typename = __remove_cvref_t<_Tuple>>
1409 struct _UseOtherCtor
1414 template<
typename _Tuple,
typename _Tp,
typename _Up>
1415 struct _UseOtherCtor<_Tuple,
tuple<_Tp>,
tuple<_Up>>
1416 : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>::type
1420 template<
typename _Tuple,
typename _Tp>
1421 struct _UseOtherCtor<_Tuple,
tuple<_Tp>,
tuple<_Tp>>
1428 template<
typename _Tuple>
1429 static constexpr bool __use_other_ctor()
1430 {
return _UseOtherCtor<_Tuple>::value; }
1433#undef __glibcxx_no_dangling_refs
1434#if __has_builtin(__reference_constructs_from_temporary) \
1435 && defined _GLIBCXX_DEBUG
1437# if __cpp_fold_expressions
1438# define __glibcxx_dangling_refs(U) \
1439 (__reference_constructs_from_temporary(_Elements, U) || ...)
1441# define __glibcxx_dangling_refs(U) \
1442 __or_<__bool_constant<__reference_constructs_from_temporary(_Elements, U) \
1445# define __glibcxx_no_dangling_refs(U) \
1446 static_assert(!__glibcxx_dangling_refs(U), \
1447 "std::tuple constructor creates a dangling reference")
1449# define __glibcxx_no_dangling_refs(U)
1454 template<
typename _Dummy = void,
1455 _ImplicitDefaultCtor<is_void<_Dummy>::value> =
true>
1458 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
1461 template<
typename _Dummy = void,
1462 _ExplicitDefaultCtor<is_void<_Dummy>::value> =
false>
1465 noexcept(__and_<is_nothrow_default_constructible<_Elements>...>::value)
1468 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
1469 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
1471 tuple(
const _Elements&... __elements)
1472 noexcept(__nothrow_constructible<
const _Elements&...>())
1473 : _Inherited(__elements...) { }
1475 template<
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
1476 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
1478 tuple(
const _Elements&... __elements)
1479 noexcept(__nothrow_constructible<
const _Elements&...>())
1480 : _Inherited(__elements...) { }
1482 template<
typename... _UElements,
1483 bool _Valid = __valid_args<_UElements...>(),
1484 _ImplicitCtor<_Valid, _UElements...> =
true>
1486 tuple(_UElements&&... __elements)
1487 noexcept(__nothrow_constructible<_UElements...>())
1488 : _Inherited(std::forward<_UElements>(__elements)...)
1489 { __glibcxx_no_dangling_refs(_UElements&&); }
1491 template<
typename... _UElements,
1492 bool _Valid = __valid_args<_UElements...>(),
1493 _ExplicitCtor<_Valid, _UElements...> =
false>
1495 tuple(_UElements&&... __elements)
1496 noexcept(__nothrow_constructible<_UElements...>())
1497 : _Inherited(std::forward<_UElements>(__elements)...)
1498 { __glibcxx_no_dangling_refs(_UElements&&); }
1504 template<
typename... _UElements,
1505 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1507 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
1510 noexcept(__nothrow_constructible<
const _UElements&...>())
1511 : _Inherited(
static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
1512 { __glibcxx_no_dangling_refs(
const _UElements&); }
1514 template<
typename... _UElements,
1515 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1517 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
1520 noexcept(__nothrow_constructible<
const _UElements&...>())
1521 : _Inherited(
static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
1522 { __glibcxx_no_dangling_refs(
const _UElements&); }
1524 template<
typename... _UElements,
1525 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1527 _ImplicitCtor<_Valid, _UElements...> =
true>
1530 noexcept(__nothrow_constructible<_UElements...>())
1531 : _Inherited(
static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
1532 { __glibcxx_no_dangling_refs(_UElements&&); }
1534 template<
typename... _UElements,
1535 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1537 _ExplicitCtor<_Valid, _UElements...> =
false>
1540 noexcept(__nothrow_constructible<_UElements...>())
1541 : _Inherited(
static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
1542 { __glibcxx_no_dangling_refs(_UElements&&); }
1546 template<
typename _Alloc,
1547 _ImplicitDefaultCtor<is_object<_Alloc>::value> =
true>
1548 _GLIBCXX20_CONSTEXPR
1549 tuple(allocator_arg_t __tag,
const _Alloc& __a)
1550 : _Inherited(__tag, __a) { }
1552 template<
typename _Alloc,
1553 _ExplicitDefaultCtor<is_object<_Alloc>::value> =
false>
1554 _GLIBCXX20_CONSTEXPR
1556 tuple(allocator_arg_t __tag,
const _Alloc& __a)
1557 : _Inherited(__tag, __a) { }
1559 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
1560 _ImplicitCtor<_NotEmpty,
const _Elements&...> =
true>
1561 _GLIBCXX20_CONSTEXPR
1562 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1563 const _Elements&... __elements)
1564 : _Inherited(__tag, __a, __elements...) { }
1566 template<
typename _Alloc,
bool _NotEmpty = (
sizeof...(_Elements) >= 1),
1567 _ExplicitCtor<_NotEmpty,
const _Elements&...> =
false>
1568 _GLIBCXX20_CONSTEXPR
1570 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1571 const _Elements&... __elements)
1572 : _Inherited(__tag, __a, __elements...) { }
1574 template<
typename _Alloc,
typename... _UElements,
1575 bool _Valid = __valid_args<_UElements...>(),
1576 _ImplicitCtor<_Valid, _UElements...> =
true>
1577 _GLIBCXX20_CONSTEXPR
1578 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1579 _UElements&&... __elements)
1580 : _Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
1581 { __glibcxx_no_dangling_refs(_UElements&&); }
1583 template<
typename _Alloc,
typename... _UElements,
1584 bool _Valid = __valid_args<_UElements...>(),
1585 _ExplicitCtor<_Valid, _UElements...> =
false>
1586 _GLIBCXX20_CONSTEXPR
1588 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1589 _UElements&&... __elements)
1590 : _Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
1591 { __glibcxx_no_dangling_refs(_UElements&&); }
1593 template<
typename _Alloc>
1594 _GLIBCXX20_CONSTEXPR
1595 tuple(allocator_arg_t __tag,
const _Alloc& __a,
const tuple& __in)
1596 : _Inherited(__tag, __a,
static_cast<const _Inherited&
>(__in)) { }
1598 template<
typename _Alloc>
1599 _GLIBCXX20_CONSTEXPR
1600 tuple(allocator_arg_t __tag,
const _Alloc& __a,
tuple&& __in)
1601 : _Inherited(__tag, __a,
static_cast<_Inherited&&
>(__in)) { }
1603 template<
typename _Alloc,
typename... _UElements,
1604 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1606 _ImplicitCtor<_Valid,
const _UElements&...> =
true>
1607 _GLIBCXX20_CONSTEXPR
1608 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1610 : _Inherited(__tag, __a,
1611 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
1612 { __glibcxx_no_dangling_refs(
const _UElements&); }
1614 template<
typename _Alloc,
typename... _UElements,
1615 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1617 _ExplicitCtor<_Valid,
const _UElements&...> =
false>
1618 _GLIBCXX20_CONSTEXPR
1620 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1622 : _Inherited(__tag, __a,
1623 static_cast<const _Tuple_impl<0, _UElements...
>&>(__in))
1624 { __glibcxx_no_dangling_refs(
const _UElements&); }
1626 template<
typename _Alloc,
typename... _UElements,
1627 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1629 _ImplicitCtor<_Valid, _UElements...> =
true>
1630 _GLIBCXX20_CONSTEXPR
1631 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1633 : _Inherited(__tag, __a,
1634 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
1635 { __glibcxx_no_dangling_refs(_UElements&&); }
1637 template<
typename _Alloc,
typename... _UElements,
1638 bool _Valid = (
sizeof...(_Elements) ==
sizeof...(_UElements))
1640 _ExplicitCtor<_Valid, _UElements...> =
false>
1641 _GLIBCXX20_CONSTEXPR
1643 tuple(allocator_arg_t __tag,
const _Alloc& __a,
1645 : _Inherited(__tag, __a,
1646 static_cast<_Tuple_impl<0, _UElements...
>&&>(__in))
1647 { __glibcxx_no_dangling_refs(_UElements&&); }
1652#if __cpp_concepts && __cpp_consteval
1654 template<
typename... _UTypes>
1655 static consteval bool
1658 if constexpr (
sizeof...(_UTypes) ==
sizeof...(_Elements))
1664 template<
typename... _UTypes>
1665 static consteval bool
1666 __nothrow_assignable()
1668 if constexpr (
sizeof...(_UTypes) ==
sizeof...(_Elements))
1674#if __cpp_lib_ranges_zip
1675 template<
typename... _UTypes>
1676 static consteval bool
1677 __const_assignable()
1679 if constexpr (
sizeof...(_UTypes) ==
sizeof...(_Elements))
1686#if __cpp_lib_tuple_like
1687 template<
typename _UTuple>
1688 static consteval bool
1689 __assignable_from_tuple_like()
1692 return __assignable<decltype(std::get<_Is>(std::declval<_UTuple>()))...>();
1696 template<
typename _UTuple>
1697 static consteval bool
1698 __const_assignable_from_tuple_like()
1701 return __const_assignable<decltype(std::get<_Is>(std::declval<_UTuple>()))...>();
1711 operator=(
const tuple& __u)
1712 noexcept(__nothrow_assignable<
const _Elements&...>())
1713 requires (__assignable<
const _Elements&...>())
1715 this->_M_assign(__u);
1720 operator=(
tuple&& __u)
1721 noexcept(__nothrow_assignable<_Elements...>())
1722 requires (__assignable<_Elements...>())
1728 template<
typename... _UTypes>
1729 requires (__assignable<
const _UTypes&...>())
1732 noexcept(__nothrow_assignable<
const _UTypes&...>())
1734 this->_M_assign(__u);
1738 template<
typename... _UTypes>
1739 requires (__assignable<_UTypes...>())
1742 noexcept(__nothrow_assignable<_UTypes...>())
1748#if __cpp_lib_ranges_zip
1749 constexpr const tuple&
1750 operator=(
const tuple& __u)
const
1751 requires (__const_assignable<
const _Elements&...>())
1753 this->_M_assign(__u);
1757 constexpr const tuple&
1758 operator=(
tuple&& __u)
const
1759 requires (__const_assignable<_Elements...>())
1765 template<
typename... _UTypes>
1766 constexpr const tuple&
1768 requires (__const_assignable<
const _UTypes&...>())
1770 this->_M_assign(__u);
1774 template<
typename... _UTypes>
1775 constexpr const tuple&
1777 requires (__const_assignable<_UTypes...>())
1784 template<
typename _U1,
typename _U2>
1785 requires (__assignable<const _U1&, const _U2&>())
1788 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
1790 this->_M_head(*
this) = __u.first;
1791 this->_M_tail(*this)._M_head(*
this) = __u.second;
1795 template<
typename _U1,
typename _U2>
1796 requires (__assignable<_U1, _U2>())
1799 noexcept(__nothrow_assignable<_U1, _U2>())
1801 this->_M_head(*
this) = std::forward<_U1>(__u.first);
1802 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__u.second);
1806#if __cpp_lib_ranges_zip
1807 template<
typename _U1,
typename _U2>
1808 requires (__const_assignable<const _U1&, const _U2>())
1809 constexpr const tuple&
1812 this->_M_head(*
this) = __u.first;
1813 this->_M_tail(*this)._M_head(*
this) = __u.second;
1817 template<
typename _U1,
typename _U2>
1818 requires (__const_assignable<_U1, _U2>())
1819 constexpr const tuple&
1822 this->_M_head(*
this) = std::forward<_U1>(__u.first);
1823 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__u.second);
1828#if __cpp_lib_tuple_like
1829 template<__eligible_tuple_like<tuple> _UTuple>
1830 requires (__assignable_from_tuple_like<_UTuple>())
1832 operator=(_UTuple&& __u)
1834 this->_M_assign(__tuple_like_tag_t{}, std::forward<_UTuple>(__u));
1838 template<__eligible_tuple_like<tuple> _UTuple>
1839 requires (__const_assignable_from_tuple_like<_UTuple>())
1840 constexpr const tuple&
1841 operator=(_UTuple&& __u)
const
1843 this->_M_assign(__tuple_like_tag_t{}, std::forward<_UTuple>(__u));
1847 template<__tuple_like _UTuple>
1848 requires (!__is_tuple_v<_UTuple>)
1849 friend constexpr bool
1850 operator== [[nodiscard]] (
const tuple& __t,
const _UTuple& __u)
1852 static_assert(
sizeof...(_Elements) == tuple_size_v<_UTuple>,
1853 "tuple objects can only be compared if they have equal sizes.");
1855 return (
bool(std::get<_Is>(__t) == std::get<_Is>(__u))
1860 template<__tuple_like _UTuple,
1862 struct __tuple_like_common_comparison_category;
1864 template<__tuple_like _UTuple,
size_t... _Is>
1866 {
typename void_t<__detail::__synth3way_t<_Elements, tuple_element_t<_Is, _UTuple>>...>; }
1867 struct __tuple_like_common_comparison_category<_UTuple,
index_sequence<_Is...>>
1869 using type = common_comparison_category_t
1870 <__detail::__synth3way_t<_Elements, tuple_element_t<_Is, _UTuple>>...>;
1873 template<__tuple_like _UTuple>
1874 requires (!__is_tuple_v<_UTuple>)
1875 friend constexpr typename __tuple_like_common_comparison_category<_UTuple>::type
1876 operator<=>(
const tuple& __t,
const _UTuple& __u)
1878 using _Cat =
typename __tuple_like_common_comparison_category<_UTuple>::type;
1886 template<
typename... _UElements>
1888 __enable_if_t<
sizeof...(_UElements) ==
sizeof...(_Elements),
bool>
1890 {
return __and_<is_assignable<_Elements&, _UElements>...>::value; }
1893 template<
typename... _UElements>
1894 static constexpr bool __nothrow_assignable()
1897 __and_<is_nothrow_assignable<_Elements&, _UElements>...>::value;
1902 _GLIBCXX20_CONSTEXPR
1904 operator=(__conditional_t<__assignable<const _Elements&...>(),
1906 const __nonesuch&> __in)
1907 noexcept(__nothrow_assignable<
const _Elements&...>())
1909 this->_M_assign(__in);
1913 _GLIBCXX20_CONSTEXPR
1915 operator=(__conditional_t<__assignable<_Elements...>(),
1918 noexcept(__nothrow_assignable<_Elements...>())
1924 template<
typename... _UElements>
1925 _GLIBCXX20_CONSTEXPR
1926 __enable_if_t<__assignable<
const _UElements&...>(),
tuple&>
1928 noexcept(__nothrow_assignable<
const _UElements&...>())
1930 this->_M_assign(__in);
1934 template<
typename... _UElements>
1935 _GLIBCXX20_CONSTEXPR
1936 __enable_if_t<__assignable<_UElements...>(),
tuple&>
1938 noexcept(__nothrow_assignable<_UElements...>())
1946 _GLIBCXX20_CONSTEXPR
1949 noexcept(__and_<__is_nothrow_swappable<_Elements>...>::value)
1950 { _Inherited::_M_swap(__in); }
1952#if __cpp_lib_ranges_zip
1960 swap(
const tuple& __in)
const
1961 noexcept(__and_v<__is_nothrow_swappable<const _Elements>...>)
1962 requires (is_swappable_v<const _Elements> && ...)
1963 { _Inherited::_M_swap(__in); }
1967#if __cpp_deduction_guides >= 201606
1968 template<
typename... _UTypes>
1970 template<
typename _T1,
typename _T2>
1972 template<
typename _Alloc,
typename... _UTypes>
1973 tuple(allocator_arg_t, _Alloc, _UTypes...) ->
tuple<_UTypes...>;
1974 template<
typename _Alloc,
typename _T1,
typename _T2>
1976 template<
typename _Alloc,
typename... _UTypes>
1985 _GLIBCXX20_CONSTEXPR
1986 void swap(
tuple&)
noexcept { }
1987#if __cpp_lib_ranges_zip
1988 constexpr void swap(
const tuple&)
const noexcept { }
1994 template<
typename _Alloc>
1995 _GLIBCXX20_CONSTEXPR
1996 tuple(allocator_arg_t,
const _Alloc&)
noexcept { }
1997 template<
typename _Alloc>
1998 _GLIBCXX20_CONSTEXPR
1999 tuple(allocator_arg_t,
const _Alloc&,
const tuple&)
noexcept { }
2002#if !(__cpp_concepts && __cpp_consteval && __cpp_conditional_explicit)
2005 template<typename _T1, typename _T2>
2006 class tuple<_T1, _T2> :
public _Tuple_impl<0, _T1, _T2>
2008 typedef _Tuple_impl<0, _T1, _T2> _Inherited;
2011 template<
bool _Dummy,
typename _U1,
typename _U2>
2012 using _ImplicitDefaultCtor = __enable_if_t<
2013 _TupleConstraints<_Dummy, _U1, _U2>::
2014 __is_implicitly_default_constructible(),
2018 template<
bool _Dummy,
typename _U1,
typename _U2>
2019 using _ExplicitDefaultCtor = __enable_if_t<
2020 _TupleConstraints<_Dummy, _U1, _U2>::
2021 __is_explicitly_default_constructible(),
2024 template<
bool _Dummy>
2025 using _TCC = _TupleConstraints<_Dummy, _T1, _T2>;
2028 template<
bool _Cond,
typename _U1,
typename _U2>
2029 using _ImplicitCtor = __enable_if_t<
2030 _TCC<_Cond>::template __is_implicitly_constructible<_U1, _U2>(),
2034 template<
bool _Cond,
typename _U1,
typename _U2>
2035 using _ExplicitCtor = __enable_if_t<
2036 _TCC<_Cond>::template __is_explicitly_constructible<_U1, _U2>(),
2039 template<
typename _U1,
typename _U2>
2040 static constexpr bool __assignable()
2042 return __and_<is_assignable<_T1&, _U1>,
2046 template<
typename _U1,
typename _U2>
2047 static constexpr bool __nothrow_assignable()
2049 return __and_<is_nothrow_assignable<_T1&, _U1>,
2053 template<
typename _U1,
typename _U2>
2054 static constexpr bool __nothrow_constructible()
2056 return __and_<is_nothrow_constructible<_T1, _U1>,
2060 static constexpr bool __nothrow_default_constructible()
2062 return __and_<is_nothrow_default_constructible<_T1>,
2066 template<
typename _U1>
2067 static constexpr bool __is_alloc_arg()
2071#undef __glibcxx_no_dangling_refs
2073#if __has_builtin(__reference_constructs_from_temporary) \
2074 && defined _GLIBCXX_DEBUG
2075# define __glibcxx_no_dangling_refs(_U1, _U2) \
2076 static_assert(!__reference_constructs_from_temporary(_T1, _U1) \
2077 && !__reference_constructs_from_temporary(_T2, _U2), \
2078 "std::tuple constructor creates a dangling reference")
2080# define __glibcxx_no_dangling_refs(_U1, _U2)
2085 template<
bool _Dummy =
true,
2086 _ImplicitDefaultCtor<_Dummy, _T1, _T2> =
true>
2089 noexcept(__nothrow_default_constructible())
2092 template<
bool _Dummy =
true,
2093 _ExplicitDefaultCtor<_Dummy, _T1, _T2> =
false>
2096 noexcept(__nothrow_default_constructible())
2099 template<
bool _Dummy =
true,
2100 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
2102 tuple(
const _T1& __a1,
const _T2& __a2)
2103 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
2104 : _Inherited(__a1, __a2) { }
2106 template<
bool _Dummy =
true,
2107 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
2109 tuple(
const _T1& __a1,
const _T2& __a2)
2110 noexcept(__nothrow_constructible<const _T1&, const _T2&>())
2111 : _Inherited(__a1, __a2) { }
2113 template<
typename _U1,
typename _U2,
2114 _ImplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
true>
2116 tuple(_U1&& __a1, _U2&& __a2)
2117 noexcept(__nothrow_constructible<_U1, _U2>())
2118 : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2))
2119 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
2121 template<
typename _U1,
typename _U2,
2122 _ExplicitCtor<!__is_alloc_arg<_U1>(), _U1, _U2> =
false>
2124 tuple(_U1&& __a1, _U2&& __a2)
2125 noexcept(__nothrow_constructible<_U1, _U2>())
2126 : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2))
2127 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
2133 template<
typename _U1,
typename _U2,
2134 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
2137 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
2138 : _Inherited(
static_cast<const _Tuple_impl<0, _U1, _U2>&
>(__in))
2139 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
2141 template<
typename _U1,
typename _U2,
2142 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
2145 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
2146 : _Inherited(
static_cast<const _Tuple_impl<0, _U1, _U2>&
>(__in))
2147 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
2149 template<
typename _U1,
typename _U2,
2150 _ImplicitCtor<true, _U1, _U2> =
true>
2153 noexcept(__nothrow_constructible<_U1, _U2>())
2154 : _Inherited(
static_cast<_Tuple_impl<0, _U1, _U2>&&
>(__in))
2155 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
2157 template<
typename _U1,
typename _U2,
2158 _ExplicitCtor<true, _U1, _U2> =
false>
2161 noexcept(__nothrow_constructible<_U1, _U2>())
2162 : _Inherited(
static_cast<_Tuple_impl<0, _U1, _U2>&&
>(__in))
2163 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
2165 template<
typename _U1,
typename _U2,
2166 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
2169 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
2170 : _Inherited(__in.first, __in.second)
2171 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
2173 template<
typename _U1,
typename _U2,
2174 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
2177 noexcept(__nothrow_constructible<const _U1&, const _U2&>())
2178 : _Inherited(__in.first, __in.second)
2179 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
2181 template<
typename _U1,
typename _U2,
2182 _ImplicitCtor<true, _U1, _U2> =
true>
2185 noexcept(__nothrow_constructible<_U1, _U2>())
2186 : _Inherited(std::forward<_U1>(__in.first),
2187 std::forward<_U2>(__in.second))
2188 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
2190 template<
typename _U1,
typename _U2,
2191 _ExplicitCtor<true, _U1, _U2> =
false>
2194 noexcept(__nothrow_constructible<_U1, _U2>())
2195 : _Inherited(std::forward<_U1>(__in.first),
2196 std::forward<_U2>(__in.second))
2197 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
2201 template<
typename _Alloc,
2202 _ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> =
true>
2203 _GLIBCXX20_CONSTEXPR
2204 tuple(allocator_arg_t __tag,
const _Alloc& __a)
2205 : _Inherited(__tag, __a) { }
2207 template<
typename _Alloc,
2208 _ExplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> =
false>
2209 _GLIBCXX20_CONSTEXPR
2211 tuple(allocator_arg_t __tag,
const _Alloc& __a)
2212 : _Inherited(__tag, __a) { }
2214 template<
typename _Alloc,
bool _Dummy =
true,
2215 _ImplicitCtor<_Dummy, const _T1&, const _T2&> =
true>
2216 _GLIBCXX20_CONSTEXPR
2217 tuple(allocator_arg_t __tag,
const _Alloc& __a,
2218 const _T1& __a1,
const _T2& __a2)
2219 : _Inherited(__tag, __a, __a1, __a2) { }
2221 template<
typename _Alloc,
bool _Dummy =
true,
2222 _ExplicitCtor<_Dummy, const _T1&, const _T2&> =
false>
2224 _GLIBCXX20_CONSTEXPR
2225 tuple(allocator_arg_t __tag,
const _Alloc& __a,
2226 const _T1& __a1,
const _T2& __a2)
2227 : _Inherited(__tag, __a, __a1, __a2) { }
2229 template<
typename _Alloc,
typename _U1,
typename _U2,
2230 _ImplicitCtor<true, _U1, _U2> =
true>
2231 _GLIBCXX20_CONSTEXPR
2232 tuple(allocator_arg_t __tag,
const _Alloc& __a, _U1&& __a1, _U2&& __a2)
2233 : _Inherited(__tag, __a, std::forward<_U1>(__a1),
2234 std::forward<_U2>(__a2))
2235 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
2237 template<
typename _Alloc,
typename _U1,
typename _U2,
2238 _ExplicitCtor<true, _U1, _U2> =
false>
2240 _GLIBCXX20_CONSTEXPR
2241 tuple(allocator_arg_t __tag,
const _Alloc& __a,
2242 _U1&& __a1, _U2&& __a2)
2243 : _Inherited(__tag, __a, std::forward<_U1>(__a1),
2244 std::forward<_U2>(__a2))
2245 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
2247 template<
typename _Alloc>
2248 _GLIBCXX20_CONSTEXPR
2249 tuple(allocator_arg_t __tag,
const _Alloc& __a,
const tuple& __in)
2250 : _Inherited(__tag, __a,
static_cast<const _Inherited&
>(__in)) { }
2252 template<
typename _Alloc>
2253 _GLIBCXX20_CONSTEXPR
2254 tuple(allocator_arg_t __tag,
const _Alloc& __a,
tuple&& __in)
2255 : _Inherited(__tag, __a,
static_cast<_Inherited&&
>(__in)) { }
2257 template<
typename _Alloc,
typename _U1,
typename _U2,
2258 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
2259 _GLIBCXX20_CONSTEXPR
2260 tuple(allocator_arg_t __tag,
const _Alloc& __a,
2262 : _Inherited(__tag, __a,
2263 static_cast<const _Tuple_impl<0, _U1, _U2>&
>(__in))
2264 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
2266 template<
typename _Alloc,
typename _U1,
typename _U2,
2267 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
2269 _GLIBCXX20_CONSTEXPR
2270 tuple(allocator_arg_t __tag,
const _Alloc& __a,
2272 : _Inherited(__tag, __a,
2273 static_cast<const _Tuple_impl<0, _U1, _U2>&
>(__in))
2274 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
2276 template<
typename _Alloc,
typename _U1,
typename _U2,
2277 _ImplicitCtor<true, _U1, _U2> =
true>
2278 _GLIBCXX20_CONSTEXPR
2280 : _Inherited(__tag, __a,
static_cast<_Tuple_impl<0, _U1, _U2>&&
>(__in))
2281 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
2283 template<
typename _Alloc,
typename _U1,
typename _U2,
2284 _ExplicitCtor<true, _U1, _U2> =
false>
2286 _GLIBCXX20_CONSTEXPR
2288 : _Inherited(__tag, __a,
static_cast<_Tuple_impl<0, _U1, _U2>&&
>(__in))
2289 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
2291 template<
typename _Alloc,
typename _U1,
typename _U2,
2292 _ImplicitCtor<true, const _U1&, const _U2&> =
true>
2293 _GLIBCXX20_CONSTEXPR
2294 tuple(allocator_arg_t __tag,
const _Alloc& __a,
2296 : _Inherited(__tag, __a, __in.first, __in.second)
2297 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
2299 template<
typename _Alloc,
typename _U1,
typename _U2,
2300 _ExplicitCtor<true, const _U1&, const _U2&> =
false>
2302 _GLIBCXX20_CONSTEXPR
2303 tuple(allocator_arg_t __tag,
const _Alloc& __a,
2305 : _Inherited(__tag, __a, __in.first, __in.second)
2306 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
2308 template<
typename _Alloc,
typename _U1,
typename _U2,
2309 _ImplicitCtor<true, _U1, _U2> =
true>
2310 _GLIBCXX20_CONSTEXPR
2312 : _Inherited(__tag, __a, std::forward<_U1>(__in.first),
2313 std::forward<_U2>(__in.second))
2314 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
2316 template<
typename _Alloc,
typename _U1,
typename _U2,
2317 _ExplicitCtor<true, _U1, _U2> =
false>
2319 _GLIBCXX20_CONSTEXPR
2321 : _Inherited(__tag, __a, std::forward<_U1>(__in.first),
2322 std::forward<_U2>(__in.second))
2323 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
2327 _GLIBCXX20_CONSTEXPR
2329 operator=(__conditional_t<__assignable<const _T1&, const _T2&>(),
2331 const __nonesuch&> __in)
2332 noexcept(__nothrow_assignable<const _T1&, const _T2&>())
2334 this->_M_assign(__in);
2338 _GLIBCXX20_CONSTEXPR
2340 operator=(__conditional_t<__assignable<_T1, _T2>(),
2343 noexcept(__nothrow_assignable<_T1, _T2>())
2349 template<
typename _U1,
typename _U2>
2350 _GLIBCXX20_CONSTEXPR
2351 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
2353 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
2355 this->_M_assign(__in);
2359 template<
typename _U1,
typename _U2>
2360 _GLIBCXX20_CONSTEXPR
2361 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
2363 noexcept(__nothrow_assignable<_U1, _U2>())
2369 template<
typename _U1,
typename _U2>
2370 _GLIBCXX20_CONSTEXPR
2371 __enable_if_t<__assignable<const _U1&, const _U2&>(),
tuple&>
2373 noexcept(__nothrow_assignable<const _U1&, const _U2&>())
2375 this->_M_head(*
this) = __in.first;
2376 this->_M_tail(*this)._M_head(*
this) = __in.second;
2380 template<
typename _U1,
typename _U2>
2381 _GLIBCXX20_CONSTEXPR
2382 __enable_if_t<__assignable<_U1, _U2>(),
tuple&>
2384 noexcept(__nothrow_assignable<_U1, _U2>())
2386 this->_M_head(*
this) = std::forward<_U1>(__in.first);
2387 this->_M_tail(*this)._M_head(*
this) = std::forward<_U2>(__in.second);
2391 _GLIBCXX20_CONSTEXPR
2394 noexcept(__and_<__is_nothrow_swappable<_T1>,
2395 __is_nothrow_swappable<_T2>>::value)
2396 { _Inherited::_M_swap(__in); }
2401 template<
typename... _Elements>
2405#if __cplusplus >= 201703L
2406 template<
typename... _Types>
2407 inline constexpr size_t tuple_size_v<
tuple<_Types...>>
2408 =
sizeof...(_Types);
2410 template<
typename... _Types>
2411 inline constexpr size_t tuple_size_v<
const tuple<_Types...>>
2412 =
sizeof...(_Types);
2416 template<
size_t __i,
typename... _Types>
2419 static_assert(__i <
sizeof...(_Types),
"tuple index must be in range");
2421 using type =
typename _Nth_type<__i, _Types...>::type;
2424 template<
size_t __i,
typename _Head,
typename... _Tail>
2426 __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t)
noexcept
2427 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
2429 template<
size_t __i,
typename _Head,
typename... _Tail>
2430 constexpr const _Head&
2431 __get_helper(
const _Tuple_impl<__i, _Head, _Tail...>& __t)
noexcept
2432 {
return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
2435 template<
size_t __i,
typename... _Types>
2436 __enable_if_t<(__i >=
sizeof...(_Types))>
2437 __get_helper(
const tuple<_Types...>&) =
delete;
2440 template<
size_t __i,
typename... _Elements>
2441 constexpr __tuple_element_t<__i, tuple<_Elements...>>&
2443 {
return std::__get_helper<__i>(__t); }
2446 template<
size_t __i,
typename... _Elements>
2447 constexpr const __tuple_element_t<__i, tuple<_Elements...>>&
2449 {
return std::__get_helper<__i>(__t); }
2452 template<
size_t __i,
typename... _Elements>
2453 constexpr __tuple_element_t<__i, tuple<_Elements...>>&&
2456 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
2457 return std::forward<__element_type>(std::__get_helper<__i>(__t));
2461 template<
size_t __i,
typename... _Elements>
2462 constexpr const __tuple_element_t<__i, tuple<_Elements...>>&&
2465 typedef __tuple_element_t<__i,
tuple<_Elements...>> __element_type;
2466 return std::forward<const __element_type>(std::__get_helper<__i>(__t));
2471 template<
size_t __i,
typename... _Elements>
2472 constexpr __enable_if_t<(__i >=
sizeof...(_Elements))>
2473 get(
const tuple<_Elements...>&) =
delete;
2476#ifdef __cpp_lib_tuples_by_type
2478 template <typename _Tp, typename... _Types>
2480 get(tuple<_Types...>& __t)
noexcept
2482 constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
2483 static_assert(__idx <
sizeof...(_Types),
2484 "the type T in std::get<T> must occur exactly once in the tuple");
2485 return std::__get_helper<__idx>(__t);
2489 template <
typename _Tp,
typename... _Types>
2491 get(tuple<_Types...>&& __t)
noexcept
2493 constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
2494 static_assert(__idx <
sizeof...(_Types),
2495 "the type T in std::get<T> must occur exactly once in the tuple");
2496 return std::forward<_Tp>(std::__get_helper<__idx>(__t));
2500 template <
typename _Tp,
typename... _Types>
2501 constexpr const _Tp&
2502 get(
const tuple<_Types...>& __t)
noexcept
2504 constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
2505 static_assert(__idx <
sizeof...(_Types),
2506 "the type T in std::get<T> must occur exactly once in the tuple");
2507 return std::__get_helper<__idx>(__t);
2512 template <
typename _Tp,
typename... _Types>
2513 constexpr const _Tp&&
2514 get(
const tuple<_Types...>&& __t)
noexcept
2516 constexpr size_t __idx = __find_uniq_type_in_pack<_Tp, _Types...>();
2517 static_assert(__idx <
sizeof...(_Types),
2518 "the type T in std::get<T> must occur exactly once in the tuple");
2519 return std::forward<const _Tp>(std::__get_helper<__idx>(__t));
2523#if __cpp_lib_three_way_comparison
2524 template<
typename... _Tps,
typename... _Ups>
2525 requires (
sizeof...(_Tps) ==
sizeof...(_Ups))
2526 && (
requires (
const _Tps& __t,
const _Ups& __u) {
2527 { __t == __u } -> __detail::__boolean_testable;
2530 operator== [[nodiscard]] (
const tuple<_Tps...>& __t,
2531 const tuple<_Ups...>& __u)
2535 return ((std::get<_Inds>(__t) == std::get<_Inds>(__u)) && ...);
2539 template<
typename _Cat,
typename _Tp,
typename _Up,
typename _IndexSeq>
2542 __tuple_cmp(
const _Tp& __t,
const _Up& __u, _IndexSeq __indices)
2544 _Cat __c = _Cat::equivalent;
2548 auto __cmp = [&]<
size_t _Ind>(integral_constant<size_t, _Ind>) {
2549 __c = __detail::__synth3way(std::get<_Ind>(__t), std::get<_Ind>(__u));
2555 (void)(__cmp(integral_constant<size_t, _Inds>{}) && ...);
2561 template<
typename... _Tps,
typename... _Ups>
2562 requires (
sizeof...(_Tps) ==
sizeof...(_Ups))
2563 && (
requires {
typename __detail::__synth3way_t<_Tps, _Ups>; } && ...)
2565 common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>
2566 operator<=> [[nodiscard]] (
const tuple<_Tps...>& __t,
2567 const tuple<_Ups...>& __u)
2570 = common_comparison_category_t<__detail::__synth3way_t<_Tps, _Ups>...>;
2571 return std::__tuple_cmp<_Cat>(__t, __u, index_sequence_for<_Tps...>());
2576 template<
typename _Tp,
typename _Up,
size_t __i,
size_t __size>
2577 struct __tuple_compare
2579 static constexpr bool
2580 __eq(
const _Tp& __t,
const _Up& __u)
2582 return bool(std::get<__i>(__t) == std::get<__i>(__u))
2583 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__eq(__t, __u);
2586 static constexpr bool
2587 __less(
const _Tp& __t,
const _Up& __u)
2589 return bool(std::get<__i>(__t) < std::get<__i>(__u))
2590 || (!bool(std::get<__i>(__u) < std::get<__i>(__t))
2591 && __tuple_compare<_Tp, _Up, __i + 1, __size>::__less(__t, __u));
2595 template<
typename _Tp,
typename _Up,
size_t __size>
2596 struct __tuple_compare<_Tp, _Up, __size, __size>
2598 static constexpr bool
2599 __eq(
const _Tp&,
const _Up&) {
return true; }
2601 static constexpr bool
2602 __less(
const _Tp&,
const _Up&) {
return false; }
2605 template<
typename... _TElements,
typename... _UElements>
2608 operator==(
const tuple<_TElements...>& __t,
2609 const tuple<_UElements...>& __u)
2611 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
2612 "tuple objects can only be compared if they have equal sizes.");
2613 using __compare = __tuple_compare<tuple<_TElements...>,
2614 tuple<_UElements...>,
2615 0,
sizeof...(_TElements)>;
2616 return __compare::__eq(__t, __u);
2619 template<
typename... _TElements,
typename... _UElements>
2622 operator<(
const tuple<_TElements...>& __t,
2623 const tuple<_UElements...>& __u)
2625 static_assert(
sizeof...(_TElements) ==
sizeof...(_UElements),
2626 "tuple objects can only be compared if they have equal sizes.");
2627 using __compare = __tuple_compare<tuple<_TElements...>,
2628 tuple<_UElements...>,
2629 0,
sizeof...(_TElements)>;
2630 return __compare::__less(__t, __u);
2633 template<
typename... _TElements,
typename... _UElements>
2636 operator!=(
const tuple<_TElements...>& __t,
2637 const tuple<_UElements...>& __u)
2638 {
return !(__t == __u); }
2640 template<
typename... _TElements,
typename... _UElements>
2643 operator>(
const tuple<_TElements...>& __t,
2644 const tuple<_UElements...>& __u)
2645 {
return __u < __t; }
2647 template<
typename... _TElements,
typename... _UElements>
2651 const tuple<_UElements...>& __u)
2652 {
return !(__u < __t); }
2654 template<
typename... _TElements,
typename... _UElements>
2658 const tuple<_UElements...>& __u)
2659 {
return !(__t < __u); }
2664 template<
typename... _Elements>
2665 constexpr tuple<typename __decay_and_strip<_Elements>::__type...>
2670 return __result_type(std::forward<_Elements>(__args)...);
2676 template<
typename... _Elements>
2677 constexpr tuple<_Elements&&...>
2679 {
return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
2682 template<
size_t,
typename,
typename,
size_t>
2683 struct __make_tuple_impl;
2685 template<
size_t _Idx,
typename _Tuple,
typename... _Tp,
size_t _Nm>
2686 struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
2687 : __make_tuple_impl<_Idx + 1,
2688 tuple<_Tp..., __tuple_element_t<_Idx, _Tuple>>,
2692 template<
size_t _Nm,
typename _Tuple,
typename... _Tp>
2693 struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
2695 typedef tuple<_Tp...> __type;
2698 template<
typename _Tuple>
2699 struct __do_make_tuple
2700 : __make_tuple_impl<0, tuple<>, _Tuple, tuple_size<_Tuple>::value>
2704 template<
typename _Tuple>
2706 :
public __do_make_tuple<__remove_cvref_t<_Tuple>>
2710 template<
typename...>
2711 struct __combine_tuples;
2714 struct __combine_tuples<>
2716 typedef tuple<> __type;
2719 template<
typename... _Ts>
2720 struct __combine_tuples<tuple<_Ts...>>
2722 typedef tuple<_Ts...> __type;
2725 template<
typename... _T1s,
typename... _T2s,
typename... _Rem>
2726 struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
2728 typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
2729 _Rem...>::__type __type;
2733 template<
typename... _Tpls>
2734 struct __tuple_cat_result
2736 typedef typename __combine_tuples
2737 <
typename __make_tuple<_Tpls>::__type...>::__type __type;
2742 template<
typename...>
2743 struct __make_1st_indices;
2746 struct __make_1st_indices<>
2748 typedef _Index_tuple<> __type;
2751 template<
typename _Tp,
typename... _Tpls>
2752 struct __make_1st_indices<_Tp, _Tpls...>
2754 typedef typename _Build_index_tuple<tuple_size<
2755 typename remove_reference<_Tp>::type>::value>::__type __type;
2761 template<
typename _Ret,
typename _Indices,
typename... _Tpls>
2762 struct __tuple_concater;
2764 template<
typename _Ret,
size_t... _Is,
typename _Tp,
typename... _Tpls>
2765 struct __tuple_concater<_Ret, _Index_tuple<_Is...>, _Tp, _Tpls...>
2767 template<
typename... _Us>
2768 static constexpr _Ret
2769 _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
2771 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
2772 typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
2773 return __next::_S_do(std::forward<_Tpls>(__tps)...,
2774 std::forward<_Us>(__us)...,
2775 std::get<_Is>(std::forward<_Tp>(__tp))...);
2779 template<
typename _Ret>
2780 struct __tuple_concater<_Ret, _Index_tuple<>>
2782 template<
typename... _Us>
2783 static constexpr _Ret
2784 _S_do(_Us&&... __us)
2786 return _Ret(std::forward<_Us>(__us)...);
2790 template<
typename... _Tps>
2791 struct __is_tuple_like_impl<tuple<_Tps...>> :
true_type
2796#if __cpp_lib_tuple_like
2797 template<__tuple_like... _Tpls>
2799 template<
typename... _Tpls,
typename =
typename
2800 enable_if<__and_<__is_tuple_like<_Tpls>...>::value>::type>
2804 ->
typename __tuple_cat_result<_Tpls...>::__type
2806 typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
2807 typedef typename __make_1st_indices<_Tpls...>::__type __idx;
2808 typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
2809 return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
2815 template<
typename... _Elements>
2816 constexpr tuple<_Elements&...>
2817 tie(_Elements&... __args)
noexcept
2818 {
return tuple<_Elements&...>(__args...); }
2821 template<
typename... _Elements>
2822 _GLIBCXX20_CONSTEXPR
2824#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
2826 typename enable_if<__and_<__is_swappable<_Elements>...>::value
2832 noexcept(
noexcept(__x.swap(__y)))
2835#if __cpp_lib_ranges_zip
2836 template<
typename... _Elements>
2837 requires (is_swappable_v<const _Elements> && ...)
2839 swap(
const tuple<_Elements...>& __x,
const tuple<_Elements...>& __y)
2840 noexcept(
noexcept(__x.swap(__y)))
2844#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
2846 template<typename... _Elements>
2847 _GLIBCXX20_CONSTEXPR
2848 typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type
2849 swap(tuple<_Elements...>&, tuple<_Elements...>&) =
delete;
2853 template<
typename... _Types,
typename _Alloc>
2865 template<
class _T1,
class _T2>
2866 template<
typename... _Args1,
typename... _Args2>
2867 _GLIBCXX20_CONSTEXPR
2872 :
pair(__first, __second,
2873 typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
2874 typename _Build_index_tuple<sizeof...(_Args2)>::__type())