285 :
public __pair_base<_T1, _T2>
293#if __cplusplus >= 201103L
297 template<
typename... _Args1,
typename... _Args2>
302 _GLIBCXX20_CONSTEXPR
void
304 noexcept(__and_<__is_nothrow_swappable<_T1>,
305 __is_nothrow_swappable<_T2>>::value)
312#if __glibcxx_ranges_zip
321 noexcept(__and_v<__is_nothrow_swappable<const _T1>,
322 __is_nothrow_swappable<const _T2>>)
323 requires is_swappable_v<const _T1> && is_swappable_v<const _T2>
332 template<
typename... _Args1,
size_t... _Indexes1,
333 typename... _Args2,
size_t... _Indexes2>
335 pair(tuple<_Args1...>&, tuple<_Args2...>&,
336 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
339#if __cpp_lib_concepts
344 explicit(__not_<__and_<__is_implicitly_default_constructible<_T1>,
345 __is_implicitly_default_constructible<_T2>>>())
347 noexcept(is_nothrow_default_constructible_v<_T1>
348 && is_nothrow_default_constructible_v<_T2>)
349 requires is_default_constructible_v<_T1>
350 && is_default_constructible_v<_T2>
357 template<
typename _U1,
typename _U2>
358 static constexpr bool
361 if constexpr (is_constructible_v<_T1, _U1>)
362 return is_constructible_v<_T2, _U2>;
366 template<
typename _U1,
typename _U2>
367 static constexpr bool
368 _S_nothrow_constructible()
370 if constexpr (is_nothrow_constructible_v<_T1, _U1>)
371 return is_nothrow_constructible_v<_T2, _U2>;
375 template<
typename _U1,
typename _U2>
376 static constexpr bool
379 if constexpr (is_convertible_v<_U1, _T1>)
380 return is_convertible_v<_U2, _T2>;
385 template<
typename _U1,
typename _U2>
386 static constexpr bool
389#if __has_builtin(__reference_constructs_from_temporary)
390 if constexpr (__reference_constructs_from_temporary(_T1, _U1&&))
393 return __reference_constructs_from_temporary(_T2, _U2&&);
399#if __glibcxx_tuple_like
400 template<
typename _UPair>
401 static constexpr bool
402 _S_constructible_from_pair_like()
408 template<
typename _UPair>
409 static constexpr bool
410 _S_convertible_from_pair_like()
416 template<
typename _UPair>
417 static constexpr bool
418 _S_dangles_from_pair_like()
429 constexpr explicit(!_S_convertible<const _T1&, const _T2&>())
430 pair(
const _T1& __x,
const _T2& __y)
431 noexcept(_S_nothrow_constructible<const _T1&, const _T2&>())
432 requires (_S_constructible<const _T1&, const _T2&>())
437#if __cplusplus > 202002L
438 template<
typename _U1 = _T1,
typename _U2 = _T2>
440 template<
typename _U1,
typename _U2>
442 requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
443 constexpr explicit(!_S_convertible<_U1, _U2>())
444 pair(_U1&& __x, _U2&& __y)
445 noexcept(_S_nothrow_constructible<_U1, _U2>())
449#if __cplusplus > 202002L
450 template<
typename _U1 = _T1,
typename _U2 = _T2>
452 template<
typename _U1,
typename _U2>
454 requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
455 constexpr explicit(!_S_convertible<_U1, _U2>())
456 pair(_U1&&, _U2&&) =
delete;
459 template<
typename _U1,
typename _U2>
460 requires (_S_constructible<const _U1&, const _U2&>())
461 && (!_S_dangles<_U1, _U2>())
462 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
464 noexcept(_S_nothrow_constructible<const _U1&, const _U2&>())
468 template<
typename _U1,
typename _U2>
469 requires (_S_constructible<const _U1&, const _U2&>())
470 && (_S_dangles<const _U1&, const _U2&>())
471 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
475 template<
typename _U1,
typename _U2>
476 requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
477 constexpr explicit(!_S_convertible<_U1, _U2>())
479 noexcept(_S_nothrow_constructible<_U1, _U2>())
484 template<
typename _U1,
typename _U2>
485 requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
486 constexpr explicit(!_S_convertible<_U1, _U2>())
489#if __glibcxx_ranges_zip
491 template<typename _U1, typename _U2>
492 requires (_S_constructible<_U1&, _U2&>()) && (!_S_dangles<_U1&, _U2&>())
493 constexpr explicit(!_S_convertible<_U1&, _U2&>())
495 noexcept(_S_nothrow_constructible<_U1&, _U2&>())
499 template<
typename _U1,
typename _U2>
500 requires (_S_constructible<_U1&, _U2&>()) && (_S_dangles<_U1&, _U2&>())
501 constexpr explicit(!_S_convertible<_U1&, _U2&>())
505 template<
typename _U1,
typename _U2>
506 requires (_S_constructible<const _U1, const _U2>())
507 && (!_S_dangles<const _U1, const _U2>())
508 constexpr explicit(!_S_convertible<const _U1, const _U2>())
510 noexcept(_S_nothrow_constructible<const _U1, const _U2>())
515 template<
typename _U1,
typename _U2>
516 requires (_S_constructible<const _U1, const _U2>())
517 && (_S_dangles<const _U1, const _U2>())
518 constexpr explicit(!_S_convertible<const _U1, const _U2>())
522#if __glibcxx_tuple_like
523 template<__eligible_pair_like<pair> _UPair>
524 requires (_S_constructible_from_pair_like<_UPair>())
525 && (!_S_dangles_from_pair_like<_UPair>())
526 constexpr explicit(!_S_convertible_from_pair_like<_UPair>())
532 template<__eligible_pair_like<pair> _UPair>
533 requires (_S_constructible_from_pair_like<_UPair>())
534 && (_S_dangles_from_pair_like<_UPair>())
535 constexpr explicit(!_S_convertible_from_pair_like<_UPair>())
536 pair(_UPair&&) =
delete;
541 template<
typename _U1,
typename _U2>
542 static constexpr bool
545 if constexpr (is_assignable_v<_T1&, _U1>)
546 return is_assignable_v<_T2&, _U2>;
550 template<
typename _U1,
typename _U2>
551 static constexpr bool
552 _S_const_assignable()
554 if constexpr (is_assignable_v<const _T1&, _U1>)
555 return is_assignable_v<const _T2&, _U2>;
559 template<
typename _U1,
typename _U2>
560 static constexpr bool
561 _S_nothrow_assignable()
563 if constexpr (is_nothrow_assignable_v<_T1&, _U1>)
564 return is_nothrow_assignable_v<_T2&, _U2>;
568#if __glibcxx_tuple_like
569 template<
typename _UPair>
570 static constexpr bool
571 _S_assignable_from_tuple_like()
577 template<
typename _UPair>
578 static constexpr bool
579 _S_const_assignable_from_tuple_like()
589 pair& operator=(
const pair&) =
delete;
593 operator=(
const pair& __p)
594 noexcept(_S_nothrow_assignable<const _T1&, const _T2&>())
595 requires (_S_assignable<const _T1&, const _T2&>())
604 operator=(
pair&& __p)
605 noexcept(_S_nothrow_assignable<_T1, _T2>())
606 requires (_S_assignable<_T1, _T2>())
614 template<
typename _U1,
typename _U2>
617 noexcept(_S_nothrow_assignable<const _U1&, const _U2&>())
618 requires (_S_assignable<const _U1&, const _U2&>())
626 template<
typename _U1,
typename _U2>
629 noexcept(_S_nothrow_assignable<_U1, _U2>())
630 requires (_S_assignable<_U1, _U2>())
637#if __glibcxx_ranges_zip
639 constexpr const pair&
640 operator=(
const pair& __p)
const
641 requires (_S_const_assignable<const first_type&, const second_type&>())
649 constexpr const pair&
650 operator=(
pair&& __p)
const
651 requires (_S_const_assignable<first_type, second_type>())
659 template<
typename _U1,
typename _U2>
660 constexpr const pair&
662 requires (_S_const_assignable<const _U1&, const _U2&>())
670 template<
typename _U1,
typename _U2>
671 constexpr const pair&
673 requires (_S_const_assignable<_U1, _U2>())
681#if __glibcxx_tuple_like
682 template<__eligible_pair_like<pair> _UPair>
683 requires (_S_assignable_from_tuple_like<_UPair>())
685 operator=(_UPair&& __p)
692 template<__eligible_pair_like<pair> _UPair>
693 requires (_S_const_assignable_from_tuple_like<_UPair>())
694 constexpr const pair&
695 operator=(_UPair&& __p)
const
708#if __has_builtin(__reference_constructs_from_temporary) \
709 && defined _GLIBCXX_DEBUG
710# define __glibcxx_no_dangling_refs(_U1, _U2) \
711 static_assert(!__reference_constructs_from_temporary(_T1, _U1) \
712 && !__reference_constructs_from_temporary(_T2, _U2), \
713 "std::pair constructor creates a dangling reference")
715# define __glibcxx_no_dangling_refs(_U1, _U2)
721 template <
typename _U1 = _T1,
723 typename enable_if<__and_<
724 __is_implicitly_default_constructible<_U1>,
725 __is_implicitly_default_constructible<_U2>>
726 ::value,
bool>::type =
true>
730 template <
typename _U1 = _T1,
736 __and_<__is_implicitly_default_constructible<_U1>,
737 __is_implicitly_default_constructible<_U2>>>>
738 ::value,
bool>::type =
false>
739 explicit constexpr pair()
744 using _PCCP = _PCC<true, _T1, _T2>;
748 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
749 enable_if<_PCCP::template
750 _ConstructiblePair<_U1, _U2>()
752 _ImplicitlyConvertiblePair<_U1, _U2>(),
754 constexpr pair(
const _T1& __a,
const _T2& __b)
758 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
760 _ConstructiblePair<_U1, _U2>()
762 _ImplicitlyConvertiblePair<_U1, _U2>(),
764 explicit constexpr pair(
const _T1& __a,
const _T2& __b)
769 template <
typename _U1,
typename _U2>
770 using _PCCFP = _PCC<!is_same<_T1, _U1>::value
775 template<
typename _U1,
typename _U2,
typename
777 _ConstructiblePair<_U1, _U2>()
778 && _PCCFP<_U1, _U2>::template
779 _ImplicitlyConvertiblePair<_U1, _U2>(),
783 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
785 template<
typename _U1,
typename _U2,
typename
786 enable_if<_PCCFP<_U1, _U2>::template
787 _ConstructiblePair<_U1, _U2>()
788 && !_PCCFP<_U1, _U2>::template
789 _ImplicitlyConvertiblePair<_U1, _U2>(),
793 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
795#if _GLIBCXX_USE_DEPRECATED
796#if defined(__DEPRECATED)
797# define _GLIBCXX_DEPRECATED_PAIR_CTOR \
798 __attribute__ ((__deprecated__ ("use 'nullptr' instead of '0' to " \
799 "initialize std::pair of move-only " \
800 "type and pointer")))
802# define _GLIBCXX_DEPRECATED_PAIR_CTOR
809 struct __zero_as_null_pointer_constant
811 __zero_as_null_pointer_constant(
int __zero_as_null_pointer_constant::*)
813 template<
typename _Tp,
814 typename = __enable_if_t<is_null_pointer<_Tp>::value>>
815 __zero_as_null_pointer_constant(_Tp) =
delete;
823 template<
typename _U1,
824 __enable_if_t<__and_<__not_<is_reference<_U1>>,
826 is_constructible<_T1, _U1>,
827 __not_<is_constructible<_T1, const _U1&>>,
828 is_convertible<_U1, _T1>>::value,
830 _GLIBCXX_DEPRECATED_PAIR_CTOR
832 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
834 { __glibcxx_no_dangling_refs(_U1&&, std::nullptr_t); }
836 template<
typename _U1,
837 __enable_if_t<__and_<__not_<is_reference<_U1>>,
839 is_constructible<_T1, _U1>,
840 __not_<is_constructible<_T1, const _U1&>>,
841 __not_<is_convertible<_U1, _T1>>>::value,
843 _GLIBCXX_DEPRECATED_PAIR_CTOR
845 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
847 { __glibcxx_no_dangling_refs(_U1&&, std::nullptr_t); }
849 template<
typename _U2,
850 __enable_if_t<__and_<is_pointer<_T1>,
851 __not_<is_reference<_U2>>,
852 is_constructible<_T2, _U2>,
853 __not_<is_constructible<_T2, const _U2&>>,
854 is_convertible<_U2, _T2>>::value,
856 _GLIBCXX_DEPRECATED_PAIR_CTOR
858 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
860 { __glibcxx_no_dangling_refs(std::nullptr_t, _U2&&); }
862 template<
typename _U2,
863 __enable_if_t<__and_<is_pointer<_T1>,
864 __not_<is_reference<_U2>>,
865 is_constructible<_T2, _U2>,
866 __not_<is_constructible<_T2, const _U2&>>,
867 __not_<is_convertible<_U2, _T2>>>::value,
869 _GLIBCXX_DEPRECATED_PAIR_CTOR
871 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
873 { __glibcxx_no_dangling_refs(std::nullptr_t, _U2&&); }
874#undef _GLIBCXX_DEPRECATED_PAIR_CTOR
877 template<
typename _U1,
typename _U2,
typename
878 enable_if<_PCCP::template
879 _MoveConstructiblePair<_U1, _U2>()
881 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
883 constexpr pair(_U1&& __x, _U2&& __y)
885 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
887 template<
typename _U1,
typename _U2,
typename
888 enable_if<_PCCP::template
889 _MoveConstructiblePair<_U1, _U2>()
891 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
893 explicit constexpr pair(_U1&& __x, _U2&& __y)
895 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
898 template<
typename _U1,
typename _U2,
typename
899 enable_if<_PCCFP<_U1, _U2>::template
900 _MoveConstructiblePair<_U1, _U2>()
901 && _PCCFP<_U1, _U2>::template
902 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
907 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
909 template<
typename _U1,
typename _U2,
typename
910 enable_if<_PCCFP<_U1, _U2>::template
911 _MoveConstructiblePair<_U1, _U2>()
912 && !_PCCFP<_U1, _U2>::template
913 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
918 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
920#undef __glibcxx_no_dangling_refs
923 operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
924 is_copy_assignable<_T2>>::value,
925 const pair&,
const __nonesuch&> __p)
933 operator=(__conditional_t<__and_<is_move_assignable<_T1>,
934 is_move_assignable<_T2>>::value,
935 pair&&, __nonesuch&&> __p)
936 noexcept(__and_<is_nothrow_move_assignable<_T1>,
937 is_nothrow_move_assignable<_T2>>::value)
944 template<
typename _U1,
typename _U2>
945 typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
946 is_assignable<_T2&, const _U2&>>::value,
955 template<
typename _U1,
typename _U2>
956 typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
957 is_assignable<_T2&, _U2&&>>::value,
976 pair(
const _T1& __a,
const _T2& __b)
980 template<
typename _U1,
typename _U2>
984#if __has_builtin(__reference_constructs_from_temporary)
985#pragma GCC diagnostic push
986#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
987 typedef int _DanglingCheck1[
988 __reference_constructs_from_temporary(_T1,
const _U1&) ? -1 : 1
990 typedef int _DanglingCheck2[
991 __reference_constructs_from_temporary(_T2,
const _U2&) ? -1 : 1
993#pragma GCC diagnostic pop