306 :
public __pair_base<_T1, _T2>
314#if __cplusplus >= 201103L
318 template<
typename... _Args1,
typename... _Args2>
323 _GLIBCXX20_CONSTEXPR
void
325 noexcept(__and_<__is_nothrow_swappable<_T1>,
326 __is_nothrow_swappable<_T2>>::value)
333#if __glibcxx_ranges_zip
342 noexcept(__and_v<__is_nothrow_swappable<const _T1>,
343 __is_nothrow_swappable<const _T2>>)
344 requires is_swappable_v<const _T1> && is_swappable_v<const _T2>
353 template<
typename... _Args1,
size_t... _Indexes1,
354 typename... _Args2,
size_t... _Indexes2>
356 pair(tuple<_Args1...>&, tuple<_Args2...>&,
357 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
360#if __cpp_lib_concepts
365 explicit(__not_<__and_<__is_implicitly_default_constructible<_T1>,
366 __is_implicitly_default_constructible<_T2>>>())
368 noexcept(is_nothrow_default_constructible_v<_T1>
369 && is_nothrow_default_constructible_v<_T2>)
370 requires is_default_constructible_v<_T1>
371 && is_default_constructible_v<_T2>
378 template<
typename _U1,
typename _U2>
379 static constexpr bool
382 if constexpr (is_constructible_v<_T1, _U1>)
383 return is_constructible_v<_T2, _U2>;
387 template<
typename _U1,
typename _U2>
388 static constexpr bool
389 _S_nothrow_constructible()
391 if constexpr (is_nothrow_constructible_v<_T1, _U1>)
392 return is_nothrow_constructible_v<_T2, _U2>;
396 template<
typename _U1,
typename _U2>
397 static constexpr bool
400 if constexpr (is_convertible_v<_U1, _T1>)
401 return is_convertible_v<_U2, _T2>;
406 template<
typename _U1,
typename _U2>
407 static constexpr bool
410#if __has_builtin(__reference_constructs_from_temporary)
411 if constexpr (__reference_constructs_from_temporary(_T1, _U1&&))
414 return __reference_constructs_from_temporary(_T2, _U2&&);
420#if __glibcxx_tuple_like
421 template<
typename _UPair>
422 static constexpr bool
423 _S_constructible_from_pair_like()
429 template<
typename _UPair>
430 static constexpr bool
431 _S_convertible_from_pair_like()
437 template<
typename _UPair>
438 static constexpr bool
439 _S_dangles_from_pair_like()
450 constexpr explicit(!_S_convertible<const _T1&, const _T2&>())
451 pair(
const type_identity_t<_T1>& __x,
const _T2& __y)
452 noexcept(_S_nothrow_constructible<const _T1&, const _T2&>())
453 requires (_S_constructible<const _T1&, const _T2&>())
458#if __cplusplus > 202002L
459 template<
typename _U1 = _T1,
typename _U2 = _T2>
461 template<
typename _U1,
typename _U2>
463 requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
464 constexpr explicit(!_S_convertible<_U1, _U2>())
465 pair(_U1&& __x, _U2&& __y)
466 noexcept(_S_nothrow_constructible<_U1, _U2>())
470#if __cplusplus > 202002L
471 template<
typename _U1 = _T1,
typename _U2 = _T2>
473 template<
typename _U1,
typename _U2>
475 requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
476 constexpr explicit(!_S_convertible<_U1, _U2>())
477 pair(_U1&&, _U2&&) =
delete;
480 template<
typename _U1,
typename _U2>
481 requires (_S_constructible<const _U1&, const _U2&>())
482 && (!_S_dangles<_U1, _U2>())
483 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
485 noexcept(_S_nothrow_constructible<const _U1&, const _U2&>())
489 template<
typename _U1,
typename _U2>
490 requires (_S_constructible<const _U1&, const _U2&>())
491 && (_S_dangles<const _U1&, const _U2&>())
492 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
496 template<
typename _U1,
typename _U2>
497 requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
498 constexpr explicit(!_S_convertible<_U1, _U2>())
500 noexcept(_S_nothrow_constructible<_U1, _U2>())
505 template<
typename _U1,
typename _U2>
506 requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
507 constexpr explicit(!_S_convertible<_U1, _U2>())
510#if __glibcxx_ranges_zip
512 template<typename _U1, typename _U2>
513 requires (_S_constructible<_U1&, _U2&>()) && (!_S_dangles<_U1&, _U2&>())
514 constexpr explicit(!_S_convertible<_U1&, _U2&>())
516 noexcept(_S_nothrow_constructible<_U1&, _U2&>())
520 template<
typename _U1,
typename _U2>
521 requires (_S_constructible<_U1&, _U2&>()) && (_S_dangles<_U1&, _U2&>())
522 constexpr explicit(!_S_convertible<_U1&, _U2&>())
526 template<
typename _U1,
typename _U2>
527 requires (_S_constructible<const _U1, const _U2>())
528 && (!_S_dangles<const _U1, const _U2>())
529 constexpr explicit(!_S_convertible<const _U1, const _U2>())
531 noexcept(_S_nothrow_constructible<const _U1, const _U2>())
536 template<
typename _U1,
typename _U2>
537 requires (_S_constructible<const _U1, const _U2>())
538 && (_S_dangles<const _U1, const _U2>())
539 constexpr explicit(!_S_convertible<const _U1, const _U2>())
543#if __glibcxx_tuple_like
544 template<__eligible_pair_like<pair> _UPair>
545 requires (_S_constructible_from_pair_like<_UPair>())
546 && (!_S_dangles_from_pair_like<_UPair>())
547 constexpr explicit(!_S_convertible_from_pair_like<_UPair>())
553 template<__eligible_pair_like<pair> _UPair>
554 requires (_S_constructible_from_pair_like<_UPair>())
555 && (_S_dangles_from_pair_like<_UPair>())
556 constexpr explicit(!_S_convertible_from_pair_like<_UPair>())
557 pair(_UPair&&) =
delete;
562 template<
typename _U1,
typename _U2>
563 static constexpr bool
566 if constexpr (is_assignable_v<_T1&, _U1>)
567 return is_assignable_v<_T2&, _U2>;
571 template<
typename _U1,
typename _U2>
572 static constexpr bool
573 _S_const_assignable()
575 if constexpr (is_assignable_v<const _T1&, _U1>)
576 return is_assignable_v<const _T2&, _U2>;
580 template<
typename _U1,
typename _U2>
581 static constexpr bool
582 _S_nothrow_assignable()
584 if constexpr (is_nothrow_assignable_v<_T1&, _U1>)
585 return is_nothrow_assignable_v<_T2&, _U2>;
589#if __glibcxx_tuple_like
590 template<
typename _UPair>
591 static constexpr bool
592 _S_assignable_from_tuple_like()
598 template<
typename _UPair>
599 static constexpr bool
600 _S_const_assignable_from_tuple_like()
610 pair& operator=(
const pair&) =
delete;
615 noexcept(_S_nothrow_assignable<const _T1&, const _T2&>())
616 requires (_S_assignable<const _T1&, const _T2&>())
626 noexcept(_S_nothrow_assignable<_T1, _T2>())
627 requires (_S_assignable<_T1, _T2>())
635 template<
typename _U1,
typename _U2>
638 noexcept(_S_nothrow_assignable<const _U1&, const _U2&>())
639 requires (_S_assignable<const _U1&, const _U2&>())
647 template<
typename _U1,
typename _U2>
650 noexcept(_S_nothrow_assignable<_U1, _U2>())
651 requires (_S_assignable<_U1, _U2>())
658#if __glibcxx_ranges_zip
660 constexpr const pair&
662 requires (_S_const_assignable<const first_type&, const second_type&>())
670 constexpr const pair&
672 requires (_S_const_assignable<first_type, second_type>())
680 template<
typename _U1,
typename _U2>
681 constexpr const pair&
683 requires (_S_const_assignable<const _U1&, const _U2&>())
691 template<
typename _U1,
typename _U2>
692 constexpr const pair&
694 requires (_S_const_assignable<_U1, _U2>())
702#if __glibcxx_tuple_like
703 template<__eligible_pair_like<pair> _UPair>
704 requires (_S_assignable_from_tuple_like<_UPair>())
706 operator=(_UPair&& __p)
713 template<__eligible_pair_like<pair> _UPair>
714 requires (_S_const_assignable_from_tuple_like<_UPair>())
715 constexpr const pair&
716 operator=(_UPair&& __p)
const
729#if __has_builtin(__reference_constructs_from_temporary) \
730 && defined _GLIBCXX_DEBUG
731# define __glibcxx_no_dangling_refs(_U1, _U2) \
732 static_assert(!__reference_constructs_from_temporary(_T1, _U1) \
733 && !__reference_constructs_from_temporary(_T2, _U2), \
734 "std::pair constructor creates a dangling reference")
736# define __glibcxx_no_dangling_refs(_U1, _U2)
742 template <
typename _U1 = _T1,
744 typename enable_if<__and_<
745 __is_implicitly_default_constructible<_U1>,
746 __is_implicitly_default_constructible<_U2>>
747 ::value,
bool>::type =
true>
751 template <
typename _U1 = _T1,
753 typename enable_if<__and_<
754 is_default_constructible<_U1>,
755 is_default_constructible<_U2>,
757 __and_<__is_implicitly_default_constructible<_U1>,
758 __is_implicitly_default_constructible<_U2>>>>
759 ::value,
bool>::type =
false>
760 explicit constexpr pair()
765 using _PCCP = _PCC<true, _T1, _T2>;
769 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
770 enable_if<_PCCP::template
771 _ConstructiblePair<_U1, _U2>()
773 _ImplicitlyConvertiblePair<_U1, _U2>(),
775 constexpr pair(
const _T1& __a,
const _T2& __b)
779 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
780 enable_if<_PCCP::template
781 _ConstructiblePair<_U1, _U2>()
783 _ImplicitlyConvertiblePair<_U1, _U2>(),
785 explicit constexpr pair(
const _T1& __a,
const _T2& __b)
790 template <
typename _U1,
typename _U2>
791 using _PCCFP = _PCC<!is_same<_T1, _U1>::value
792 || !is_same<_T2, _U2>::value,
796 template<
typename _U1,
typename _U2,
typename
797 enable_if<_PCCFP<_U1, _U2>::template
798 _ConstructiblePair<_U1, _U2>()
799 && _PCCFP<_U1, _U2>::template
800 _ImplicitlyConvertiblePair<_U1, _U2>(),
804 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
806 template<
typename _U1,
typename _U2,
typename
807 enable_if<_PCCFP<_U1, _U2>::template
808 _ConstructiblePair<_U1, _U2>()
809 && !_PCCFP<_U1, _U2>::template
810 _ImplicitlyConvertiblePair<_U1, _U2>(),
814 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
816#if _GLIBCXX_USE_DEPRECATED
817#if defined(__DEPRECATED)
818# define _GLIBCXX_DEPRECATED_PAIR_CTOR \
819 __attribute__ ((__deprecated__ ("use 'nullptr' instead of '0' to " \
820 "initialize std::pair of move-only " \
821 "type and pointer")))
823# define _GLIBCXX_DEPRECATED_PAIR_CTOR
830 struct __zero_as_null_pointer_constant
832 __zero_as_null_pointer_constant(
int __zero_as_null_pointer_constant::*)
834 template<
typename _Tp,
835 typename = __enable_if_t<is_null_pointer<_Tp>::value>>
836 __zero_as_null_pointer_constant(_Tp) =
delete;
844 template<
typename _U1,
845 __enable_if_t<__and_<__not_<is_reference<_U1>>,
847 is_constructible<_T1, _U1>,
848 __not_<is_constructible<_T1, const _U1&>>,
849 is_convertible<_U1, _T1>>::value,
851 _GLIBCXX_DEPRECATED_PAIR_CTOR
853 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
855 { __glibcxx_no_dangling_refs(_U1&&, std::nullptr_t); }
857 template<
typename _U1,
858 __enable_if_t<__and_<__not_<is_reference<_U1>>,
860 is_constructible<_T1, _U1>,
861 __not_<is_constructible<_T1, const _U1&>>,
862 __not_<is_convertible<_U1, _T1>>>::value,
864 _GLIBCXX_DEPRECATED_PAIR_CTOR
866 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
868 { __glibcxx_no_dangling_refs(_U1&&, std::nullptr_t); }
870 template<
typename _U2,
871 __enable_if_t<__and_<is_pointer<_T1>,
872 __not_<is_reference<_U2>>,
873 is_constructible<_T2, _U2>,
874 __not_<is_constructible<_T2, const _U2&>>,
875 is_convertible<_U2, _T2>>::value,
877 _GLIBCXX_DEPRECATED_PAIR_CTOR
879 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
881 { __glibcxx_no_dangling_refs(std::nullptr_t, _U2&&); }
883 template<
typename _U2,
884 __enable_if_t<__and_<is_pointer<_T1>,
885 __not_<is_reference<_U2>>,
886 is_constructible<_T2, _U2>,
887 __not_<is_constructible<_T2, const _U2&>>,
888 __not_<is_convertible<_U2, _T2>>>::value,
890 _GLIBCXX_DEPRECATED_PAIR_CTOR
892 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
894 { __glibcxx_no_dangling_refs(std::nullptr_t, _U2&&); }
895#undef _GLIBCXX_DEPRECATED_PAIR_CTOR
898 template<
typename _U1,
typename _U2,
typename
899 enable_if<_PCCP::template
900 _MoveConstructiblePair<_U1, _U2>()
902 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
904 constexpr pair(_U1&& __x, _U2&& __y)
906 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
908 template<
typename _U1,
typename _U2,
typename
909 enable_if<_PCCP::template
910 _MoveConstructiblePair<_U1, _U2>()
912 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
914 explicit constexpr pair(_U1&& __x, _U2&& __y)
916 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
919 template<
typename _U1,
typename _U2,
typename
920 enable_if<_PCCFP<_U1, _U2>::template
921 _MoveConstructiblePair<_U1, _U2>()
922 && _PCCFP<_U1, _U2>::template
923 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
928 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
930 template<
typename _U1,
typename _U2,
typename
931 enable_if<_PCCFP<_U1, _U2>::template
932 _MoveConstructiblePair<_U1, _U2>()
933 && !_PCCFP<_U1, _U2>::template
934 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
939 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
941#undef __glibcxx_no_dangling_refs
944 operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
945 is_copy_assignable<_T2>>::value,
946 const pair&,
const __nonesuch&> __p)
954 operator=(__conditional_t<__and_<is_move_assignable<_T1>,
955 is_move_assignable<_T2>>::value,
956 pair&&, __nonesuch&&> __p)
957 noexcept(__and_<is_nothrow_move_assignable<_T1>,
958 is_nothrow_move_assignable<_T2>>::value)
965 template<
typename _U1,
typename _U2>
966 typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
967 is_assignable<_T2&, const _U2&>>::value,
976 template<
typename _U1,
typename _U2>
977 typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
978 is_assignable<_T2&, _U2&&>>::value,
997 pair(
const _T1& __a,
const _T2& __b)
1001 template<
typename _U1,
typename _U2>
1005#if __has_builtin(__reference_constructs_from_temporary)
1006#pragma GCC diagnostic push
1007#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
1008 typedef int _DanglingCheck1[
1009 __reference_constructs_from_temporary(_T1,
const _U1&) ? -1 : 1
1011 typedef int _DanglingCheck2[
1012 __reference_constructs_from_temporary(_T2,
const _U2&) ? -1 : 1
1014#pragma GCC diagnostic pop