187 :
public __pair_base<_T1, _T2>
195#if __cplusplus >= 201103L
199 template<
typename... _Args1,
typename... _Args2>
204 _GLIBCXX20_CONSTEXPR
void
206 noexcept(__and_<__is_nothrow_swappable<_T1>,
207 __is_nothrow_swappable<_T2>>::value)
214#if __glibcxx_ranges_zip
222 swap(
const pair& __p)
const
223 noexcept(__and_v<__is_nothrow_swappable<const _T1>,
224 __is_nothrow_swappable<const _T2>>)
225 requires is_swappable_v<const _T1> && is_swappable_v<const _T2>
228 swap(
first, __p.first);
234 template<
typename... _Args1,
size_t... _Indexes1,
235 typename... _Args2,
size_t... _Indexes2>
237 pair(tuple<_Args1...>&, tuple<_Args2...>&,
238 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
241#if __cpp_lib_concepts
246 explicit(__not_<__and_<__is_implicitly_default_constructible<_T1>,
247 __is_implicitly_default_constructible<_T2>>>())
249 requires is_default_constructible_v<_T1>
250 && is_default_constructible_v<_T2>
257 template<
typename _U1,
typename _U2>
258 static constexpr bool
261 if constexpr (is_constructible_v<_T1, _U1>)
262 return is_constructible_v<_T2, _U2>;
266 template<
typename _U1,
typename _U2>
267 static constexpr bool
268 _S_nothrow_constructible()
270 if constexpr (is_nothrow_constructible_v<_T1, _U1>)
271 return is_nothrow_constructible_v<_T2, _U2>;
275 template<
typename _U1,
typename _U2>
276 static constexpr bool
279 if constexpr (is_convertible_v<_U1, _T1>)
280 return is_convertible_v<_U2, _T2>;
285 template<
typename _U1,
typename _U2>
286 static constexpr bool
289#if __has_builtin(__reference_constructs_from_temporary)
290 if constexpr (__reference_constructs_from_temporary(_T1, _U1&&))
293 return __reference_constructs_from_temporary(_T2, _U2&&);
303 constexpr explicit(!_S_convertible<const _T1&, const _T2&>())
304 pair(
const _T1& __x,
const _T2& __y)
305 noexcept(_S_nothrow_constructible<const _T1&, const _T2&>())
306 requires (_S_constructible<const _T1&, const _T2&>())
311#if __cplusplus > 202002L
312 template<
typename _U1 = _T1,
typename _U2 = _T2>
314 template<
typename _U1,
typename _U2>
316 requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
317 constexpr explicit(!_S_convertible<_U1, _U2>())
318 pair(_U1&& __x, _U2&& __y)
319 noexcept(_S_nothrow_constructible<_U1, _U2>())
323#if __cplusplus > 202002L
324 template<
typename _U1 = _T1,
typename _U2 = _T2>
326 template<
typename _U1,
typename _U2>
328 requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
329 constexpr explicit(!_S_convertible<_U1, _U2>())
330 pair(_U1&&, _U2&&) =
delete;
333 template<
typename _U1,
typename _U2>
334 requires (_S_constructible<const _U1&, const _U2&>())
335 && (!_S_dangles<_U1, _U2>())
336 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
337 pair(
const pair<_U1, _U2>& __p)
338 noexcept(_S_nothrow_constructible<const _U1&, const _U2&>())
342 template<
typename _U1,
typename _U2>
343 requires (_S_constructible<const _U1&, const _U2&>())
344 && (_S_dangles<const _U1&, const _U2&>())
345 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
346 pair(
const pair<_U1, _U2>&) =
delete;
349 template<
typename _U1,
typename _U2>
350 requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
351 constexpr explicit(!_S_convertible<_U1, _U2>())
352 pair(pair<_U1, _U2>&& __p)
353 noexcept(_S_nothrow_constructible<_U1, _U2>())
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>&&) =
delete;
363#if __glibcxx_ranges_zip
365 template<typename _U1, typename _U2>
366 requires (_S_constructible<_U1&, _U2&>()) && (!_S_dangles<_U1&, _U2&>())
367 constexpr explicit(!_S_convertible<_U1&, _U2&>())
368 pair(pair<_U1, _U2>& __p)
369 noexcept(_S_nothrow_constructible<_U1&, _U2&>())
373 template<
typename _U1,
typename _U2>
374 requires (_S_constructible<_U1&, _U2&>()) && (_S_dangles<_U1&, _U2&>())
375 constexpr explicit(!_S_convertible<_U1&, _U2&>())
376 pair(pair<_U1, _U2>&) =
delete;
379 template<
typename _U1,
typename _U2>
380 requires (_S_constructible<const _U1, const _U2>())
381 && (!_S_dangles<const _U1, const _U2>())
382 constexpr explicit(!_S_convertible<const _U1, const _U2>())
383 pair(
const pair<_U1, _U2>&& __p)
384 noexcept(_S_nothrow_constructible<const _U1, const _U2>())
389 template<
typename _U1,
typename _U2>
390 requires (_S_constructible<const _U1, const _U2>())
391 && (_S_dangles<const _U1, const _U2>())
392 constexpr explicit(!_S_convertible<const _U1, const _U2>())
393 pair(
const pair<_U1, _U2>&&) =
delete;
398 template<
typename _U1,
typename _U2>
399 static constexpr bool
402 if constexpr (is_assignable_v<_T1&, _U1>)
403 return is_assignable_v<_T2&, _U2>;
407 template<
typename _U1,
typename _U2>
408 static constexpr bool
409 _S_nothrow_assignable()
411 if constexpr (is_nothrow_assignable_v<_T1&, _U1>)
412 return is_nothrow_assignable_v<_T2&, _U2>;
419 pair& operator=(
const pair&) =
delete;
423 operator=(
const pair& __p)
424 noexcept(_S_nothrow_assignable<const _T1&, const _T2&>())
425 requires (_S_assignable<const _T1&, const _T2&>())
434 operator=(
pair&& __p)
435 noexcept(_S_nothrow_assignable<_T1, _T2>())
436 requires (_S_assignable<_T1, _T2>())
438 first = std::forward<first_type>(__p.first);
439 second = std::forward<second_type>(__p.second);
444 template<
typename _U1,
typename _U2>
446 operator=(
const pair<_U1, _U2>& __p)
447 noexcept(_S_nothrow_assignable<const _U1&, const _U2&>())
448 requires (_S_assignable<const _U1&, const _U2&>())
456 template<
typename _U1,
typename _U2>
458 operator=(pair<_U1, _U2>&& __p)
459 noexcept(_S_nothrow_assignable<_U1, _U2>())
460 requires (_S_assignable<_U1, _U2>())
462 first = std::forward<_U1>(__p.first);
463 second = std::forward<_U2>(__p.second);
467#if __glibcxx_ranges_zip
469 constexpr const pair&
470 operator=(
const pair& __p)
const
471 requires is_copy_assignable_v<const first_type>
472 && is_copy_assignable_v<const second_type>
480 constexpr const pair&
481 operator=(
pair&& __p)
const
482 requires is_assignable_v<const first_type&, first_type>
483 && is_assignable_v<const second_type&, second_type>
485 first = std::forward<first_type>(__p.first);
486 second = std::forward<second_type>(__p.second);
491 template<
typename _U1,
typename _U2>
492 constexpr const pair&
493 operator=(
const pair<_U1, _U2>& __p)
const
494 requires is_assignable_v<const first_type&, const _U1&>
495 && is_assignable_v<const second_type&, const _U2&>
503 template<
typename _U1,
typename _U2>
504 constexpr const pair&
505 operator=(pair<_U1, _U2>&& __p)
const
506 requires is_assignable_v<const first_type&, _U1>
507 && is_assignable_v<const second_type&, _U2>
509 first = std::forward<_U1>(__p.first);
510 second = std::forward<_U2>(__p.second);
519#if __has_builtin(__reference_constructs_from_temporary) \
520 && defined _GLIBCXX_DEBUG
521# define __glibcxx_no_dangling_refs(_U1, _U2) \
522 static_assert(!__reference_constructs_from_temporary(_T1, _U1) \
523 && !__reference_constructs_from_temporary(_T2, _U2), \
524 "std::pair constructor creates a dangling reference")
526# define __glibcxx_no_dangling_refs(_U1, _U2)
532 template <
typename _U1 = _T1,
534 typename enable_if<__and_<
535 __is_implicitly_default_constructible<_U1>,
536 __is_implicitly_default_constructible<_U2>>
537 ::value,
bool>::type =
true>
541 template <
typename _U1 = _T1,
547 __and_<__is_implicitly_default_constructible<_U1>,
548 __is_implicitly_default_constructible<_U2>>>>
549 ::value,
bool>::type =
false>
550 explicit constexpr pair()
555 using _PCCP = _PCC<true, _T1, _T2>;
559 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
560 enable_if<_PCCP::template
561 _ConstructiblePair<_U1, _U2>()
563 _ImplicitlyConvertiblePair<_U1, _U2>(),
565 constexpr pair(
const _T1& __a,
const _T2& __b)
569 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
571 _ConstructiblePair<_U1, _U2>()
573 _ImplicitlyConvertiblePair<_U1, _U2>(),
575 explicit constexpr pair(
const _T1& __a,
const _T2& __b)
580 template <
typename _U1,
typename _U2>
581 using _PCCFP = _PCC<!is_same<_T1, _U1>::value
586 template<
typename _U1,
typename _U2,
typename
588 _ConstructiblePair<_U1, _U2>()
589 && _PCCFP<_U1, _U2>::template
590 _ImplicitlyConvertiblePair<_U1, _U2>(),
594 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
596 template<
typename _U1,
typename _U2,
typename
597 enable_if<_PCCFP<_U1, _U2>::template
598 _ConstructiblePair<_U1, _U2>()
599 && !_PCCFP<_U1, _U2>::template
600 _ImplicitlyConvertiblePair<_U1, _U2>(),
602 explicit constexpr pair(
const pair<_U1, _U2>& __p)
604 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
606#if _GLIBCXX_USE_DEPRECATED
607#if defined(__DEPRECATED)
608# define _GLIBCXX_DEPRECATED_PAIR_CTOR \
609 __attribute__ ((__deprecated__ ("use 'nullptr' instead of '0' to " \
610 "initialize std::pair of move-only " \
611 "type and pointer")))
613# define _GLIBCXX_DEPRECATED_PAIR_CTOR
620 struct __zero_as_null_pointer_constant
622 __zero_as_null_pointer_constant(
int __zero_as_null_pointer_constant::*)
624 template<
typename _Tp,
625 typename = __enable_if_t<is_null_pointer<_Tp>::value>>
626 __zero_as_null_pointer_constant(_Tp) =
delete;
634 template<
typename _U1,
635 __enable_if_t<__and_<__not_<is_reference<_U1>>,
637 is_constructible<_T1, _U1>,
638 __not_<is_constructible<_T1, const _U1&>>,
639 is_convertible<_U1, _T1>>::value,
641 _GLIBCXX_DEPRECATED_PAIR_CTOR
643 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
645 { __glibcxx_no_dangling_refs(_U1&&, std::nullptr_t); }
647 template<
typename _U1,
648 __enable_if_t<__and_<__not_<is_reference<_U1>>,
650 is_constructible<_T1, _U1>,
651 __not_<is_constructible<_T1, const _U1&>>,
652 __not_<is_convertible<_U1, _T1>>>::value,
654 _GLIBCXX_DEPRECATED_PAIR_CTOR
656 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
658 { __glibcxx_no_dangling_refs(_U1&&, std::nullptr_t); }
660 template<
typename _U2,
661 __enable_if_t<__and_<is_pointer<_T1>,
662 __not_<is_reference<_U2>>,
663 is_constructible<_T2, _U2>,
664 __not_<is_constructible<_T2, const _U2&>>,
665 is_convertible<_U2, _T2>>::value,
667 _GLIBCXX_DEPRECATED_PAIR_CTOR
669 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
671 { __glibcxx_no_dangling_refs(std::nullptr_t, _U2&&); }
673 template<
typename _U2,
674 __enable_if_t<__and_<is_pointer<_T1>,
675 __not_<is_reference<_U2>>,
676 is_constructible<_T2, _U2>,
677 __not_<is_constructible<_T2, const _U2&>>,
678 __not_<is_convertible<_U2, _T2>>>::value,
680 _GLIBCXX_DEPRECATED_PAIR_CTOR
682 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
684 { __glibcxx_no_dangling_refs(std::nullptr_t, _U2&&); }
685#undef _GLIBCXX_DEPRECATED_PAIR_CTOR
688 template<
typename _U1,
typename _U2,
typename
689 enable_if<_PCCP::template
690 _MoveConstructiblePair<_U1, _U2>()
692 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
694 constexpr pair(_U1&& __x, _U2&& __y)
696 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
698 template<
typename _U1,
typename _U2,
typename
699 enable_if<_PCCP::template
700 _MoveConstructiblePair<_U1, _U2>()
702 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
704 explicit constexpr pair(_U1&& __x, _U2&& __y)
706 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
709 template<
typename _U1,
typename _U2,
typename
710 enable_if<_PCCFP<_U1, _U2>::template
711 _MoveConstructiblePair<_U1, _U2>()
712 && _PCCFP<_U1, _U2>::template
713 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
715 constexpr pair(pair<_U1, _U2>&& __p)
718 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
720 template<
typename _U1,
typename _U2,
typename
721 enable_if<_PCCFP<_U1, _U2>::template
722 _MoveConstructiblePair<_U1, _U2>()
723 && !_PCCFP<_U1, _U2>::template
724 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
726 explicit constexpr pair(pair<_U1, _U2>&& __p)
729 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
731#undef __glibcxx_no_dangling_refs
734 operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
735 is_copy_assignable<_T2>>::value,
736 const pair&,
const __nonesuch&> __p)
744 operator=(__conditional_t<__and_<is_move_assignable<_T1>,
745 is_move_assignable<_T2>>::value,
746 pair&&, __nonesuch&&> __p)
747 noexcept(__and_<is_nothrow_move_assignable<_T1>,
748 is_nothrow_move_assignable<_T2>>::value)
750 first = std::forward<first_type>(__p.first);
751 second = std::forward<second_type>(__p.second);
755 template<
typename _U1,
typename _U2>
756 typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
757 is_assignable<_T2&, const _U2&>>::value,
759 operator=(
const pair<_U1, _U2>& __p)
766 template<
typename _U1,
typename _U2>
767 typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
768 is_assignable<_T2&, _U2&&>>::value,
770 operator=(pair<_U1, _U2>&& __p)
772 first = std::forward<_U1>(__p.first);
773 second = std::forward<_U2>(__p.second);
787 pair(
const _T1& __a,
const _T2& __b)
791 template<
typename _U1,
typename _U2>
792 pair(
const pair<_U1, _U2>& __p)
795#if __has_builtin(__reference_constructs_from_temporary)
796#pragma GCC diagnostic push
797#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
798 typedef int _DanglingCheck1[
799 __reference_constructs_from_temporary(_T1,
const _U1&) ? -1 : 1
801 typedef int _DanglingCheck2[
802 __reference_constructs_from_temporary(_T2,
const _U2&) ? -1 : 1
804#pragma GCC diagnostic pop