396 :
public __pair_base<_T1, _T2>
404#if __cplusplus >= 201103L
408 template<
typename... _Args1,
typename... _Args2>
413 _GLIBCXX20_CONSTEXPR
void
415 noexcept(__and_<__is_nothrow_swappable<_T1>,
416 __is_nothrow_swappable<_T2>>::value)
423#if __glibcxx_ranges_zip
432 noexcept(__and_v<__is_nothrow_swappable<const _T1>,
433 __is_nothrow_swappable<const _T2>>)
434 requires is_swappable_v<const _T1> && is_swappable_v<const _T2>
443 template<
typename... _Args1,
size_t... _Indexes1,
444 typename... _Args2,
size_t... _Indexes2>
446 pair(tuple<_Args1...>&, tuple<_Args2...>&,
447 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
450#if __cpp_lib_concepts
455 explicit(__not_<__and_<__is_implicitly_default_constructible<_T1>,
456 __is_implicitly_default_constructible<_T2>>>())
458 noexcept(is_nothrow_default_constructible_v<_T1>
459 && is_nothrow_default_constructible_v<_T2>)
460 requires is_default_constructible_v<_T1>
461 && is_default_constructible_v<_T2>
468 template<
typename _U1,
typename _U2>
469 static constexpr bool
472 if constexpr (is_constructible_v<_T1, _U1>)
473 return is_constructible_v<_T2, _U2>;
477 template<
typename _U1,
typename _U2>
478 static constexpr bool
479 _S_nothrow_constructible()
481 if constexpr (is_nothrow_constructible_v<_T1, _U1>)
482 return is_nothrow_constructible_v<_T2, _U2>;
486 template<
typename _U1,
typename _U2>
487 static constexpr bool
490 if constexpr (is_convertible_v<_U1, _T1>)
491 return is_convertible_v<_U2, _T2>;
496 template<
typename _U1,
typename _U2>
497 static constexpr bool
500#if __has_builtin(__reference_constructs_from_temporary)
501 if constexpr (__reference_constructs_from_temporary(_T1, _U1&&))
504 return __reference_constructs_from_temporary(_T2, _U2&&);
510#if __glibcxx_tuple_like
511 template<
typename _UPair>
512 static constexpr bool
513 _S_constructible_from_pair_like()
519 template<
typename _UPair>
520 static constexpr bool
521 _S_convertible_from_pair_like()
527 template<
typename _UPair>
528 static constexpr bool
529 _S_dangles_from_pair_like()
540 constexpr explicit(!_S_convertible<const _T1&, const _T2&>())
541 pair(
const type_identity_t<_T1>& __x,
const _T2& __y)
542 noexcept(_S_nothrow_constructible<const _T1&, const _T2&>())
543 requires (_S_constructible<const _T1&, const _T2&>())
548#if __cplusplus > 202002L
549 template<
typename _U1 = _T1,
typename _U2 = _T2>
551 template<
typename _U1,
typename _U2>
553 requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
554 constexpr explicit(!_S_convertible<_U1, _U2>())
555 pair(_U1&& __x, _U2&& __y)
556 noexcept(_S_nothrow_constructible<_U1, _U2>())
560#if __cplusplus > 202002L
561 template<
typename _U1 = _T1,
typename _U2 = _T2>
563 template<
typename _U1,
typename _U2>
565 requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
566 constexpr explicit(!_S_convertible<_U1, _U2>())
567 pair(_U1&&, _U2&&) =
delete;
570 template<
typename _U1,
typename _U2>
571 requires (_S_constructible<const _U1&, const _U2&>())
572 && (!_S_dangles<_U1, _U2>())
573 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
575 noexcept(_S_nothrow_constructible<const _U1&, const _U2&>())
579 template<
typename _U1,
typename _U2>
580 requires (_S_constructible<const _U1&, const _U2&>())
581 && (_S_dangles<const _U1&, const _U2&>())
582 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
586 template<
typename _U1,
typename _U2>
587 requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
588 constexpr explicit(!_S_convertible<_U1, _U2>())
590 noexcept(_S_nothrow_constructible<_U1, _U2>())
595 template<
typename _U1,
typename _U2>
596 requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
597 constexpr explicit(!_S_convertible<_U1, _U2>())
600#if __glibcxx_ranges_zip
602 template<typename _U1, typename _U2>
603 requires (_S_constructible<_U1&, _U2&>()) && (!_S_dangles<_U1&, _U2&>())
604 constexpr explicit(!_S_convertible<_U1&, _U2&>())
606 noexcept(_S_nothrow_constructible<_U1&, _U2&>())
610 template<
typename _U1,
typename _U2>
611 requires (_S_constructible<_U1&, _U2&>()) && (_S_dangles<_U1&, _U2&>())
612 constexpr explicit(!_S_convertible<_U1&, _U2&>())
616 template<
typename _U1,
typename _U2>
617 requires (_S_constructible<const _U1, const _U2>())
618 && (!_S_dangles<const _U1, const _U2>())
619 constexpr explicit(!_S_convertible<const _U1, const _U2>())
621 noexcept(_S_nothrow_constructible<const _U1, const _U2>())
626 template<
typename _U1,
typename _U2>
627 requires (_S_constructible<const _U1, const _U2>())
628 && (_S_dangles<const _U1, const _U2>())
629 constexpr explicit(!_S_convertible<const _U1, const _U2>())
633#if __glibcxx_tuple_like
634 template<__eligible_pair_like<pair> _UPair>
635 requires (_S_constructible_from_pair_like<_UPair>())
636 && (!_S_dangles_from_pair_like<_UPair>())
637 constexpr explicit(!_S_convertible_from_pair_like<_UPair>())
643 template<__eligible_pair_like<pair> _UPair>
644 requires (_S_constructible_from_pair_like<_UPair>())
645 && (_S_dangles_from_pair_like<_UPair>())
646 constexpr explicit(!_S_convertible_from_pair_like<_UPair>())
647 pair(_UPair&&) =
delete;
652 template<
typename _U1,
typename _U2>
653 static constexpr bool
656 if constexpr (is_assignable_v<_T1&, _U1>)
657 return is_assignable_v<_T2&, _U2>;
661 template<
typename _U1,
typename _U2>
662 static constexpr bool
663 _S_const_assignable()
665 if constexpr (is_assignable_v<const _T1&, _U1>)
666 return is_assignable_v<const _T2&, _U2>;
670 template<
typename _U1,
typename _U2>
671 static constexpr bool
672 _S_nothrow_assignable()
674 if constexpr (is_nothrow_assignable_v<_T1&, _U1>)
675 return is_nothrow_assignable_v<_T2&, _U2>;
679#if __glibcxx_tuple_like
680 template<
typename _UPair>
681 static constexpr bool
682 _S_assignable_from_tuple_like()
688 template<
typename _UPair>
689 static constexpr bool
690 _S_const_assignable_from_tuple_like()
700 pair& operator=(
const pair&) =
delete;
705 noexcept(_S_nothrow_assignable<const _T1&, const _T2&>())
706 requires (_S_assignable<const _T1&, const _T2&>())
716 noexcept(_S_nothrow_assignable<_T1, _T2>())
717 requires (_S_assignable<_T1, _T2>())
725 template<
typename _U1,
typename _U2>
728 noexcept(_S_nothrow_assignable<const _U1&, const _U2&>())
729 requires (_S_assignable<const _U1&, const _U2&>())
737 template<
typename _U1,
typename _U2>
740 noexcept(_S_nothrow_assignable<_U1, _U2>())
741 requires (_S_assignable<_U1, _U2>())
748#if __glibcxx_ranges_zip
750 constexpr const pair&
752 requires (_S_const_assignable<const first_type&, const second_type&>())
760 constexpr const pair&
762 requires (_S_const_assignable<first_type, second_type>())
770 template<
typename _U1,
typename _U2>
771 constexpr const pair&
773 requires (_S_const_assignable<const _U1&, const _U2&>())
781 template<
typename _U1,
typename _U2>
782 constexpr const pair&
784 requires (_S_const_assignable<_U1, _U2>())
792#if __glibcxx_tuple_like
793 template<__eligible_pair_like<pair> _UPair>
794 requires (_S_assignable_from_tuple_like<_UPair>())
796 operator=(_UPair&& __p)
803 template<__eligible_pair_like<pair> _UPair>
804 requires (_S_const_assignable_from_tuple_like<_UPair>())
805 constexpr const pair&
806 operator=(_UPair&& __p)
const
819#if __has_builtin(__reference_constructs_from_temporary)
820# define __glibcxx_no_dangling_refs(_U1, _U2) \
821 static_assert(!__reference_constructs_from_temporary(_T1, _U1) \
822 && !__reference_constructs_from_temporary(_T2, _U2), \
823 "std::pair constructor creates a dangling reference")
825# define __glibcxx_no_dangling_refs(_U1, _U2)
831 template <
typename _U1 = _T1,
833 typename enable_if<__and_<
834 __is_implicitly_default_constructible<_U1>,
835 __is_implicitly_default_constructible<_U2>>
836 ::value,
bool>::type =
true>
840 template <
typename _U1 = _T1,
842 typename enable_if<__and_<
843 is_default_constructible<_U1>,
844 is_default_constructible<_U2>,
846 __and_<__is_implicitly_default_constructible<_U1>,
847 __is_implicitly_default_constructible<_U2>>>>
848 ::value,
bool>::type =
false>
849 explicit constexpr pair()
854 using _PCCP = _PCC<true, _T1, _T2>;
858 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
859 enable_if<_PCCP::template
860 _ConstructiblePair<_U1, _U2>()
862 _ImplicitlyConvertiblePair<_U1, _U2>(),
864 constexpr pair(
const _T1& __a,
const _T2& __b)
868 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
869 enable_if<_PCCP::template
870 _ConstructiblePair<_U1, _U2>()
872 _ImplicitlyConvertiblePair<_U1, _U2>(),
874 explicit constexpr pair(
const _T1& __a,
const _T2& __b)
879 template <
typename _U1,
typename _U2>
880 using _PCCFP = _PCC<!is_same<_T1, _U1>::value
881 || !is_same<_T2, _U2>::value,
885 template<
typename _U1,
typename _U2,
typename
886 enable_if<_PCCFP<_U1, _U2>::template
887 _ConstructiblePair<_U1, _U2>()
888 && _PCCFP<_U1, _U2>::template
889 _ImplicitlyConvertiblePair<_U1, _U2>(),
893 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
895 template<
typename _U1,
typename _U2,
typename
896 enable_if<_PCCFP<_U1, _U2>::template
897 _ConstructiblePair<_U1, _U2>()
898 && !_PCCFP<_U1, _U2>::template
899 _ImplicitlyConvertiblePair<_U1, _U2>(),
903 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
905#if _GLIBCXX_USE_DEPRECATED
906#if defined(__DEPRECATED)
907# define _GLIBCXX_DEPRECATED_PAIR_CTOR \
908 __attribute__ ((__deprecated__ ("use 'nullptr' instead of '0' to " \
909 "initialize std::pair of move-only " \
910 "type and pointer")))
912# define _GLIBCXX_DEPRECATED_PAIR_CTOR
919 struct __zero_as_null_pointer_constant
921 __zero_as_null_pointer_constant(
int __zero_as_null_pointer_constant::*)
923 template<
typename _Tp,
924 typename = __enable_if_t<is_null_pointer<_Tp>::value>>
925 __zero_as_null_pointer_constant(_Tp) =
delete;
933 template<
typename _U1,
934 __enable_if_t<__and_<__not_<is_reference<_U1>>,
936 is_constructible<_T1, _U1>,
937 __not_<is_constructible<_T1, const _U1&>>,
938 is_convertible<_U1, _T1>>::value,
940 _GLIBCXX_DEPRECATED_PAIR_CTOR
942 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
944 { __glibcxx_no_dangling_refs(_U1&&, std::nullptr_t); }
946 template<
typename _U1,
947 __enable_if_t<__and_<__not_<is_reference<_U1>>,
949 is_constructible<_T1, _U1>,
950 __not_<is_constructible<_T1, const _U1&>>,
951 __not_<is_convertible<_U1, _T1>>>::value,
953 _GLIBCXX_DEPRECATED_PAIR_CTOR
955 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
957 { __glibcxx_no_dangling_refs(_U1&&, std::nullptr_t); }
959 template<
typename _U2,
960 __enable_if_t<__and_<is_pointer<_T1>,
961 __not_<is_reference<_U2>>,
962 is_constructible<_T2, _U2>,
963 __not_<is_constructible<_T2, const _U2&>>,
964 is_convertible<_U2, _T2>>::value,
966 _GLIBCXX_DEPRECATED_PAIR_CTOR
968 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
970 { __glibcxx_no_dangling_refs(std::nullptr_t, _U2&&); }
972 template<
typename _U2,
973 __enable_if_t<__and_<is_pointer<_T1>,
974 __not_<is_reference<_U2>>,
975 is_constructible<_T2, _U2>,
976 __not_<is_constructible<_T2, const _U2&>>,
977 __not_<is_convertible<_U2, _T2>>>::value,
979 _GLIBCXX_DEPRECATED_PAIR_CTOR
981 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
983 { __glibcxx_no_dangling_refs(std::nullptr_t, _U2&&); }
984#undef _GLIBCXX_DEPRECATED_PAIR_CTOR
987 template<
typename _U1,
typename _U2,
typename
988 enable_if<_PCCP::template
989 _MoveConstructiblePair<_U1, _U2>()
991 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
993 constexpr pair(_U1&& __x, _U2&& __y)
995 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
997 template<
typename _U1,
typename _U2,
typename
998 enable_if<_PCCP::template
999 _MoveConstructiblePair<_U1, _U2>()
1001 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
1003 explicit constexpr pair(_U1&& __x, _U2&& __y)
1005 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
1008 template<
typename _U1,
typename _U2,
typename
1009 enable_if<_PCCFP<_U1, _U2>::template
1010 _MoveConstructiblePair<_U1, _U2>()
1011 && _PCCFP<_U1, _U2>::template
1012 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
1017 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
1019 template<
typename _U1,
typename _U2,
typename
1020 enable_if<_PCCFP<_U1, _U2>::template
1021 _MoveConstructiblePair<_U1, _U2>()
1022 && !_PCCFP<_U1, _U2>::template
1023 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
1028 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
1030#undef __glibcxx_no_dangling_refs
1033 operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
1034 is_copy_assignable<_T2>>::value,
1035 const pair&,
const __nonesuch&> __p)
1043 operator=(__conditional_t<__and_<is_move_assignable<_T1>,
1044 is_move_assignable<_T2>>::value,
1045 pair&&, __nonesuch&&> __p)
1046 noexcept(__and_<is_nothrow_move_assignable<_T1>,
1047 is_nothrow_move_assignable<_T2>>::value)
1054 template<
typename _U1,
typename _U2>
1055 typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
1056 is_assignable<_T2&, const _U2&>>::value,
1065 template<
typename _U1,
typename _U2>
1066 typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
1067 is_assignable<_T2&, _U2&&>>::value,
1086 pair(
const _T1& __a,
const _T2& __b)
1090 template<
typename _U1,
typename _U2>
1094#if __has_builtin(__reference_constructs_from_temporary)
1095#pragma GCC diagnostic push
1096#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
1097 typedef int _DanglingCheck1[
1098 __reference_constructs_from_temporary(_T1,
const _U1&) ? -1 : 1
1100 typedef int _DanglingCheck2[
1101 __reference_constructs_from_temporary(_T2,
const _U2&) ? -1 : 1
1103#pragma GCC diagnostic pop