188 :
public __pair_base<_T1, _T2>
196#if __cplusplus >= 201103L
211 swap(
first, __p.first);
215#if __cplusplus > 202002L
223 swap(
const pair& __p)
const
229 swap(
first, __p.first);
235 template<
typename... _Args1,
size_t... _Indexes1,
236 typename... _Args2,
size_t... _Indexes2>
238 pair(tuple<_Args1...>&, tuple<_Args2...>&,
239 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
242#if __cpp_lib_concepts
247 explicit(__not_<__and_<__is_implicitly_default_constructible<_T1>,
248 __is_implicitly_default_constructible<_T2>>>())
250 requires is_default_constructible_v<_T1>
251 && is_default_constructible_v<_T2>
258 template<
typename _U1,
typename _U2>
259 static constexpr bool
262 if constexpr (is_constructible_v<_T1, _U1>)
263 return is_constructible_v<_T2, _U2>;
267 template<
typename _U1,
typename _U2>
268 static constexpr bool
269 _S_nothrow_constructible()
271 if constexpr (is_nothrow_constructible_v<_T1, _U1>)
272 return is_nothrow_constructible_v<_T2, _U2>;
276 template<
typename _U1,
typename _U2>
277 static constexpr bool
280 if constexpr (is_convertible_v<_U1, _T1>)
281 return is_convertible_v<_U2, _T2>;
286 template<
typename _U1,
typename _U2>
287 static constexpr bool
290#if __has_builtin(__reference_constructs_from_temporary)
291 if constexpr (__reference_constructs_from_temporary(_T1, _U1&&))
294 return __reference_constructs_from_temporary(_T2, _U2&&);
304 constexpr explicit(!_S_convertible<const _T1&, const _T2&>())
305 pair(
const _T1& __x,
const _T2& __y)
306 noexcept(_S_nothrow_constructible<const _T1&, const _T2&>())
307 requires (_S_constructible<const _T1&, const _T2&>())
312 template<
typename _U1,
typename _U2>
313 requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
314 constexpr explicit(!_S_convertible<_U1, _U2>())
315 pair(_U1&& __x, _U2&& __y)
316 noexcept(_S_nothrow_constructible<_U1, _U2>())
320 template<
typename _U1,
typename _U2>
321 requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
322 constexpr explicit(!_S_convertible<_U1, _U2>())
323 pair(_U1&&, _U2&&) =
delete;
326 template<
typename _U1,
typename _U2>
327 requires (_S_constructible<const _U1&, const _U2&>())
328 && (!_S_dangles<_U1, _U2>())
329 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
330 pair(
const pair<_U1, _U2>& __p)
331 noexcept(_S_nothrow_constructible<const _U1&, const _U2&>())
335 template<
typename _U1,
typename _U2>
336 requires (_S_constructible<const _U1&, const _U2&>())
337 && (_S_dangles<const _U1&, const _U2&>())
338 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
339 pair(
const pair<_U1, _U2>&) =
delete;
342 template<
typename _U1,
typename _U2>
343 requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
344 constexpr explicit(!_S_convertible<_U1, _U2>())
345 pair(pair<_U1, _U2>&& __p)
346 noexcept(_S_nothrow_constructible<_U1, _U2>())
351 template<
typename _U1,
typename _U2>
352 requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
353 constexpr explicit(!_S_convertible<_U1, _U2>())
354 pair(pair<_U1, _U2>&&) =
delete;
356#if __cplusplus > 202002L
358 template<
typename _U1,
typename _U2>
359 requires (_S_constructible<_U1&, _U2&>()) && (!_S_dangles<_U1&, _U2&>())
360 constexpr explicit(!_S_convertible<_U1&, _U2&>())
361 pair(pair<_U1, _U2>& __p)
362 noexcept(_S_nothrow_constructible<_U1&, _U2&>())
366 template<
typename _U1,
typename _U2>
367 requires (_S_constructible<_U1&, _U2&>()) && (_S_dangles<_U1&, _U2&>())
368 constexpr explicit(!_S_convertible<_U1&, _U2&>())
369 pair(pair<_U1, _U2>&) =
delete;
372 template<
typename _U1,
typename _U2>
373 requires (_S_constructible<const _U1, const _U2>())
374 && (!_S_dangles<const _U1, const _U2>())
375 constexpr explicit(!_S_convertible<const _U1, const _U2>())
376 pair(
const pair<_U1, _U2>&& __p)
377 noexcept(_S_nothrow_constructible<const _U1, const _U2>())
382 template<
typename _U1,
typename _U2>
383 requires (_S_constructible<const _U1, const _U2>())
384 && (_S_dangles<const _U1, const _U2>())
385 constexpr explicit(!_S_convertible<const _U1, const _U2>())
386 pair(
const pair<_U1, _U2>&&) =
delete;
391 template<
typename _U1,
typename _U2>
392 static constexpr bool
395 if constexpr (is_assignable_v<_T1&, _U1>)
396 return is_assignable_v<_T2&, _U2>;
400 template<
typename _U1,
typename _U2>
401 static constexpr bool
402 _S_nothrow_assignable()
404 if constexpr (is_nothrow_assignable_v<_T1&, _U1>)
405 return is_nothrow_assignable_v<_T2&, _U2>;
412 pair& operator=(
const pair&) =
delete;
416 operator=(
const pair& __p)
417 noexcept(_S_nothrow_assignable<const _T1&, const _T2&>())
418 requires (_S_assignable<const _T1&, const _T2&>())
427 operator=(
pair&& __p)
428 noexcept(_S_nothrow_assignable<_T1, _T2>())
429 requires (_S_assignable<_T1, _T2>())
437 template<
typename _U1,
typename _U2>
439 operator=(
const pair<_U1, _U2>& __p)
440 noexcept(_S_nothrow_assignable<const _U1&, const _U2&>())
441 requires (_S_assignable<const _U1&, const _U2&>())
449 template<
typename _U1,
typename _U2>
451 operator=(pair<_U1, _U2>&& __p)
452 noexcept(_S_nothrow_assignable<_U1, _U2>())
453 requires (_S_assignable<_U1, _U2>())
460#if __cplusplus > 202002L
462 constexpr const pair&
463 operator=(
const pair& __p)
const
464 requires is_copy_assignable_v<const first_type>
465 && is_copy_assignable_v<const second_type>
473 constexpr const pair&
474 operator=(
pair&& __p)
const
475 requires is_assignable_v<const first_type&, first_type>
476 && is_assignable_v<const second_type&, second_type>
484 template<
typename _U1,
typename _U2>
485 constexpr const pair&
486 operator=(
const pair<_U1, _U2>& __p)
const
487 requires is_assignable_v<const first_type&, const _U1&>
488 && is_assignable_v<const second_type&, const _U2&>
496 template<
typename _U1,
typename _U2>
497 constexpr const pair&
498 operator=(pair<_U1, _U2>&& __p)
const
499 requires is_assignable_v<const first_type&, _U1>
500 && is_assignable_v<const second_type&, _U2>
512#if __has_builtin(__reference_constructs_from_temporary) \
513 && defined _GLIBCXX_DEBUG
514# define __glibcxx_no_dangling_refs(_U1, _U2) \
515 static_assert(!__reference_constructs_from_temporary(_T1, _U1) \
516 && !__reference_constructs_from_temporary(_T2, _U2), \
517 "std::pair constructor creates a dangling reference")
519# define __glibcxx_no_dangling_refs(_U1, _U2)
525 template <
typename _U1 = _T1,
527 typename enable_if<__and_<
528 __is_implicitly_default_constructible<_U1>,
529 __is_implicitly_default_constructible<_U2>>
530 ::value,
bool>::type =
true>
534 template <
typename _U1 = _T1,
542 ::value,
bool>::type =
false>
543 explicit constexpr pair()
548 using _PCCP = _PCC<true, _T1, _T2>;
552 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
553 enable_if<_PCCP::template
554 _ConstructiblePair<_U1, _U2>()
556 _ImplicitlyConvertiblePair<_U1, _U2>(),
558 constexpr pair(
const _T1& __a,
const _T2& __b)
562 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
568 explicit constexpr pair(
const _T1& __a,
const _T2& __b)
573 template <
typename _U1,
typename _U2>
579 template<
typename _U1,
typename _U2,
typename
589 template<
typename _U1,
typename _U2,
typename
590 enable_if<_PCCFP<_U1, _U2>::template
591 _ConstructiblePair<_U1, _U2>()
592 && !_PCCFP<_U1, _U2>::template
593 _ImplicitlyConvertiblePair<_U1, _U2>(),
595 explicit constexpr pair(
const pair<_U1, _U2>& __p)
597 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
599#if _GLIBCXX_USE_DEPRECATED
600#if defined(__DEPRECATED)
601# define _GLIBCXX_DEPRECATED_PAIR_CTOR \
602 __attribute__ ((__deprecated__ ("use 'nullptr' instead of '0' to " \
603 "initialize std::pair of move-only " \
604 "type and pointer")))
606# define _GLIBCXX_DEPRECATED_PAIR_CTOR
613 struct __zero_as_null_pointer_constant
615 __zero_as_null_pointer_constant(
int __zero_as_null_pointer_constant::*)
617 template<
typename _Tp,
618 typename = __enable_if_t<is_null_pointer<_Tp>::value>>
619 __zero_as_null_pointer_constant(_Tp) =
delete;
627 template<
typename _U1,
628 __enable_if_t<__and_<__not_<is_reference<_U1>>,
630 is_constructible<_T1, _U1>,
631 __not_<is_constructible<_T1, const _U1&>>,
632 is_convertible<_U1, _T1>>::value,
634 _GLIBCXX_DEPRECATED_PAIR_CTOR
636 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
640 template<
typename _U1,
641 __enable_if_t<__and_<__not_<is_reference<_U1>>,
643 is_constructible<_T1, _U1>,
644 __not_<is_constructible<_T1, const _U1&>>,
645 __not_<is_convertible<_U1, _T1>>>::value,
647 _GLIBCXX_DEPRECATED_PAIR_CTOR
649 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
653 template<
typename _U2,
654 __enable_if_t<__and_<is_pointer<_T1>,
655 __not_<is_reference<_U2>>,
656 is_constructible<_T2, _U2>,
657 __not_<is_constructible<_T2, const _U2&>>,
658 is_convertible<_U2, _T2>>::value,
660 _GLIBCXX_DEPRECATED_PAIR_CTOR
662 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
666 template<
typename _U2,
667 __enable_if_t<__and_<is_pointer<_T1>,
668 __not_<is_reference<_U2>>,
669 is_constructible<_T2, _U2>,
670 __not_<is_constructible<_T2, const _U2&>>,
671 __not_<is_convertible<_U2, _T2>>>::value,
673 _GLIBCXX_DEPRECATED_PAIR_CTOR
675 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
678#undef _GLIBCXX_DEPRECATED_PAIR_CTOR
681 template<
typename _U1,
typename _U2,
typename
682 enable_if<_PCCP::template
683 _MoveConstructiblePair<_U1, _U2>()
685 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
687 constexpr pair(_U1&& __x, _U2&& __y)
689 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
691 template<
typename _U1,
typename _U2,
typename
692 enable_if<_PCCP::template
693 _MoveConstructiblePair<_U1, _U2>()
695 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
697 explicit constexpr pair(_U1&& __x, _U2&& __y)
699 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
702 template<
typename _U1,
typename _U2,
typename
703 enable_if<_PCCFP<_U1, _U2>::template
704 _MoveConstructiblePair<_U1, _U2>()
705 && _PCCFP<_U1, _U2>::template
706 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
708 constexpr pair(pair<_U1, _U2>&& __p)
711 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
713 template<
typename _U1,
typename _U2,
typename
714 enable_if<_PCCFP<_U1, _U2>::template
715 _MoveConstructiblePair<_U1, _U2>()
716 && !_PCCFP<_U1, _U2>::template
717 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
719 explicit constexpr pair(pair<_U1, _U2>&& __p)
722 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
724#undef __glibcxx_no_dangling_refs
727 operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
728 is_copy_assignable<_T2>>::value,
729 const pair&,
const __nonesuch&> __p)
737 operator=(__conditional_t<__and_<is_move_assignable<_T1>,
738 is_move_assignable<_T2>>::value,
739 pair&&, __nonesuch&&> __p)
740 noexcept(__and_<is_nothrow_move_assignable<_T1>,
741 is_nothrow_move_assignable<_T2>>::value)
748 template<
typename _U1,
typename _U2>
749 typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
750 is_assignable<_T2&, const _U2&>>::value,
752 operator=(
const pair<_U1, _U2>& __p)
759 template<
typename _U1,
typename _U2>
760 typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
761 is_assignable<_T2&, _U2&&>>::value,
763 operator=(pair<_U1, _U2>&& __p)
780 pair(
const _T1& __a,
const _T2& __b)
784 template<
typename _U1,
typename _U2>
785 pair(
const pair<_U1, _U2>& __p)
788#if __has_builtin(__reference_constructs_from_temporary)
789#pragma GCC diagnostic push
790#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
791 typedef int _DanglingCheck1[
792 __reference_constructs_from_temporary(_T1,
const _U1&) ? -1 : 1
794 typedef int _DanglingCheck2[
795 __reference_constructs_from_temporary(_T2,
const _U2&) ? -1 : 1
797#pragma GCC diagnostic pop