59 #if __cplusplus >= 201103L
64 #if __cplusplus >= 202002L
68 namespace std _GLIBCXX_VISIBILITY(default)
70 _GLIBCXX_BEGIN_NAMESPACE_VERSION
77 #if __cplusplus >= 201103L
88 template<
typename _T1,
typename _T2>
98 template<
typename _Tp,
size_t _Nm>
104 template<
typename _Tp>
107 template<
size_t _Int,
class _Tp1,
class _Tp2>
111 template<
size_t _Int,
class _Tp1,
class _Tp2>
115 template<
size_t _Int,
class _Tp1,
class _Tp2>
119 template<
size_t _Int,
class _Tp1,
class _Tp2>
123 template<
size_t __i,
typename... _Elements>
124 constexpr __tuple_element_t<__i,
tuple<_Elements...>>&
127 template<
size_t __i,
typename... _Elements>
128 constexpr
const __tuple_element_t<__i,
tuple<_Elements...>>&
131 template<
size_t __i,
typename... _Elements>
132 constexpr __tuple_element_t<__i,
tuple<_Elements...>>&&
135 template<
size_t __i,
typename... _Elements>
136 constexpr
const __tuple_element_t<__i,
tuple<_Elements...>>&&
139 template<
size_t _Int,
typename _Tp,
size_t _Nm>
143 template<
size_t _Int,
typename _Tp,
size_t _Nm>
147 template<
size_t _Int, typename _Tp,
size_t _Nm>
149 get(const
array<_Tp, _Nm>&) noexcept;
151 template<
size_t _Int, typename _Tp,
size_t _Nm>
152 constexpr const _Tp&&
153 get(const
array<_Tp, _Nm>&&) noexcept;
155 #if __glibcxx_tuple_like >= 202311
156 template<
size_t _Int,
typename _Tp>
159 template<
size_t _Int,
typename _Tp>
162 template<
size_t _Int, typename _Tp>
165 template<
size_t _Int, typename _Tp>
166 constexpr const _Tp&&
170 #if ! __cpp_lib_concepts
176 template <
bool,
typename _T1,
typename _T2>
179 template <
typename _U1,
typename _U2>
180 static constexpr
bool _ConstructiblePair()
182 return __and_<is_constructible<_T1, const _U1&>,
186 template <
typename _U1,
typename _U2>
187 static constexpr
bool _ImplicitlyConvertiblePair()
189 return __and_<is_convertible<const _U1&, _T1>,
190 is_convertible<const _U2&, _T2>>::value;
193 template <
typename _U1,
typename _U2>
194 static constexpr
bool _MoveConstructiblePair()
196 return __and_<is_constructible<_T1, _U1&&>,
197 is_constructible<_T2, _U2&&>>::value;
200 template <
typename _U1,
typename _U2>
201 static constexpr
bool _ImplicitlyMoveConvertiblePair()
203 return __and_<is_convertible<_U1&&, _T1>,
204 is_convertible<_U2&&, _T2>>::value;
208 template <
typename _T1,
typename _T2>
209 struct _PCC<false, _T1, _T2>
211 template <
typename _U1,
typename _U2>
212 static constexpr
bool _ConstructiblePair()
217 template <
typename _U1,
typename _U2>
218 static constexpr
bool _ImplicitlyConvertiblePair()
223 template <
typename _U1,
typename _U2>
224 static constexpr
bool _MoveConstructiblePair()
229 template <
typename _U1,
typename _U2>
230 static constexpr
bool _ImplicitlyMoveConvertiblePair()
238 #if __glibcxx_tuple_like
239 template<
typename _Tp>
240 inline constexpr
bool __is_tuple_v =
false;
242 template<
typename... _Ts>
243 inline constexpr
bool __is_tuple_v<tuple<_Ts...>> =
true;
246 template<
typename _Tp>
247 inline constexpr
bool __is_tuple_like_v =
false;
249 template<
typename... _Elements>
250 inline constexpr
bool __is_tuple_like_v<tuple<_Elements...>> =
true;
252 template<
typename _T1,
typename _T2>
253 inline constexpr
bool __is_tuple_like_v<pair<_T1, _T2>> =
true;
255 template<
typename _Tp,
size_t _Nm>
256 inline constexpr
bool __is_tuple_like_v<array<_Tp, _Nm>> =
true;
260 template<
typename _Tp>
261 concept __tuple_like = __is_tuple_like_v<remove_cvref_t<_Tp>>;
263 template<
typename _Tp>
264 concept __pair_like = __tuple_like<_Tp> && tuple_size_v<remove_cvref_t<_Tp>> == 2;
266 template<
typename _Tp,
typename _Tuple>
267 concept __eligible_tuple_like
268 = __detail::__different_from<_Tp, _Tuple> && __tuple_like<_Tp>
269 && (tuple_size_v<remove_cvref_t<_Tp>> == tuple_size_v<_Tuple>)
270 && !ranges::__detail::__is_subrange<remove_cvref_t<_Tp>>;
272 template<
typename _Tp,
typename _Pair>
273 concept __eligible_pair_like
274 = __detail::__different_from<_Tp, _Pair> && __pair_like<_Tp>
275 && !ranges::__detail::__is_subrange<remove_cvref_t<_Tp>>;
278 template<
typename _U1,
typename _U2>
class __pair_base
280 #if __cplusplus >= 201103L && ! __cpp_lib_concepts
281 template<
typename _T1,
typename _T2>
friend struct pair;
282 __pair_base() =
default;
283 ~__pair_base() =
default;
284 __pair_base(
const __pair_base&) =
default;
285 __pair_base& operator=(
const __pair_base&) =
delete;
301 template<
typename _T1,
typename _T2>
303 :
public __pair_base<_T1, _T2>
311 #if __cplusplus >= 201103L
315 template<
typename... _Args1,
typename... _Args2>
320 _GLIBCXX20_CONSTEXPR
void
322 noexcept(__and_<__is_nothrow_swappable<_T1>,
323 __is_nothrow_swappable<_T2>>::value)
330 #if __glibcxx_ranges_zip
339 noexcept(__and_v<__is_nothrow_swappable<const _T1>,
340 __is_nothrow_swappable<const _T2>>)
341 requires is_swappable_v<const _T1> && is_swappable_v<const _T2>
350 template<
typename... _Args1,
size_t... _Indexes1,
351 typename... _Args2,
size_t... _Indexes2>
353 pair(tuple<_Args1...>&, tuple<_Args2...>&,
354 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
357 #if __cpp_lib_concepts
362 explicit(__not_<__and_<__is_implicitly_default_constructible<_T1>,
363 __is_implicitly_default_constructible<_T2>>>())
365 noexcept(is_nothrow_default_constructible_v<_T1>
366 && is_nothrow_default_constructible_v<_T2>)
367 requires is_default_constructible_v<_T1>
368 && is_default_constructible_v<_T2>
375 template<
typename _U1,
typename _U2>
376 static constexpr
bool
379 if constexpr (is_constructible_v<_T1, _U1>)
380 return is_constructible_v<_T2, _U2>;
384 template<
typename _U1,
typename _U2>
385 static constexpr
bool
386 _S_nothrow_constructible()
388 if constexpr (is_nothrow_constructible_v<_T1, _U1>)
389 return is_nothrow_constructible_v<_T2, _U2>;
393 template<
typename _U1,
typename _U2>
394 static constexpr
bool
397 if constexpr (is_convertible_v<_U1, _T1>)
398 return is_convertible_v<_U2, _T2>;
403 template<
typename _U1,
typename _U2>
404 static constexpr
bool
407 #if __has_builtin(__reference_constructs_from_temporary)
408 if constexpr (__reference_constructs_from_temporary(_T1, _U1&&))
411 return __reference_constructs_from_temporary(_T2, _U2&&);
417 #if __glibcxx_tuple_like
418 template<
typename _UPair>
419 static constexpr
bool
420 _S_constructible_from_pair_like()
422 return _S_constructible<decltype(std::get<0>(std::declval<_UPair>())),
423 decltype(std::get<1>(std::declval<_UPair>()))>();
426 template<
typename _UPair>
427 static constexpr
bool
428 _S_convertible_from_pair_like()
430 return _S_convertible<decltype(std::get<0>(std::declval<_UPair>())),
431 decltype(std::get<1>(std::declval<_UPair>()))>();
434 template<
typename _UPair>
435 static constexpr
bool
436 _S_dangles_from_pair_like()
438 return _S_dangles<decltype(std::get<0>(std::declval<_UPair>())),
439 decltype(std::get<1>(std::declval<_UPair>()))>();
447 constexpr
explicit(!_S_convertible<const _T1&, const _T2&>())
448 pair(
const _T1& __x,
const _T2& __y)
449 noexcept(_S_nothrow_constructible<const _T1&, const _T2&>())
450 requires (_S_constructible<const _T1&, const _T2&>())
455 #if __cplusplus > 202002L
456 template<
typename _U1 = _T1,
typename _U2 = _T2>
458 template<
typename _U1,
typename _U2>
460 requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
461 constexpr
explicit(!_S_convertible<_U1, _U2>())
462 pair(_U1&& __x, _U2&& __y)
463 noexcept(_S_nothrow_constructible<_U1, _U2>())
467 #if __cplusplus > 202002L
468 template<
typename _U1 = _T1,
typename _U2 = _T2>
470 template<
typename _U1,
typename _U2>
472 requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
473 constexpr
explicit(!_S_convertible<_U1, _U2>())
474 pair(_U1&&, _U2&&) =
delete;
477 template<
typename _U1,
typename _U2>
478 requires (_S_constructible<const _U1&, const _U2&>())
479 && (!_S_dangles<_U1, _U2>())
480 constexpr
explicit(!_S_convertible<const _U1&, const _U2&>())
481 pair(
const pair<_U1, _U2>& __p)
482 noexcept(_S_nothrow_constructible<const _U1&, const _U2&>())
486 template<
typename _U1,
typename _U2>
487 requires (_S_constructible<const _U1&, const _U2&>())
488 && (_S_dangles<const _U1&, const _U2&>())
489 constexpr
explicit(!_S_convertible<const _U1&, const _U2&>())
490 pair(
const pair<_U1, _U2>&) =
delete;
493 template<
typename _U1,
typename _U2>
494 requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
495 constexpr
explicit(!_S_convertible<_U1, _U2>())
496 pair(pair<_U1, _U2>&& __p)
497 noexcept(_S_nothrow_constructible<_U1, _U2>())
502 template<
typename _U1,
typename _U2>
503 requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
504 constexpr
explicit(!_S_convertible<_U1, _U2>())
505 pair(pair<_U1, _U2>&&) =
delete;
507 #if __glibcxx_ranges_zip
509 template<typename _U1, typename _U2>
510 requires (_S_constructible<_U1&, _U2&>()) && (!_S_dangles<_U1&, _U2&>())
511 constexpr
explicit(!_S_convertible<_U1&, _U2&>())
512 pair(pair<_U1, _U2>& __p)
513 noexcept(_S_nothrow_constructible<_U1&, _U2&>())
517 template<
typename _U1,
typename _U2>
518 requires (_S_constructible<_U1&, _U2&>()) && (_S_dangles<_U1&, _U2&>())
519 constexpr
explicit(!_S_convertible<_U1&, _U2&>())
520 pair(pair<_U1, _U2>&) =
delete;
523 template<
typename _U1,
typename _U2>
524 requires (_S_constructible<const _U1, const _U2>())
525 && (!_S_dangles<const _U1, const _U2>())
526 constexpr
explicit(!_S_convertible<const _U1, const _U2>())
527 pair(
const pair<_U1, _U2>&& __p)
528 noexcept(_S_nothrow_constructible<const _U1, const _U2>())
533 template<
typename _U1,
typename _U2>
534 requires (_S_constructible<const _U1, const _U2>())
535 && (_S_dangles<const _U1, const _U2>())
536 constexpr
explicit(!_S_convertible<const _U1, const _U2>())
537 pair(
const pair<_U1, _U2>&&) =
delete;
540 #if __glibcxx_tuple_like
541 template<__eligible_pair_like<pair> _UPair>
542 requires (_S_constructible_from_pair_like<_UPair>())
543 && (!_S_dangles_from_pair_like<_UPair>())
544 constexpr
explicit(!_S_convertible_from_pair_like<_UPair>())
546 :
first(std::get<0>(std::forward<_UPair>(__p))),
547 second(std::get<1>(std::forward<_UPair>(__p)))
550 template<__eligible_pair_like<pair> _UPair>
551 requires (_S_constructible_from_pair_like<_UPair>())
552 && (_S_dangles_from_pair_like<_UPair>())
553 constexpr
explicit(!_S_convertible_from_pair_like<_UPair>())
554 pair(_UPair&&) =
delete;
559 template<
typename _U1,
typename _U2>
560 static constexpr
bool
563 if constexpr (is_assignable_v<_T1&, _U1>)
564 return is_assignable_v<_T2&, _U2>;
568 template<
typename _U1,
typename _U2>
569 static constexpr
bool
570 _S_const_assignable()
572 if constexpr (is_assignable_v<const _T1&, _U1>)
573 return is_assignable_v<const _T2&, _U2>;
577 template<
typename _U1,
typename _U2>
578 static constexpr
bool
579 _S_nothrow_assignable()
581 if constexpr (is_nothrow_assignable_v<_T1&, _U1>)
582 return is_nothrow_assignable_v<_T2&, _U2>;
586 #if __glibcxx_tuple_like
587 template<
typename _UPair>
588 static constexpr
bool
589 _S_assignable_from_tuple_like()
591 return _S_assignable<decltype(std::get<0>(std::declval<_UPair>())),
592 decltype(std::get<1>(std::declval<_UPair>()))>();
595 template<
typename _UPair>
596 static constexpr
bool
597 _S_const_assignable_from_tuple_like()
599 return _S_const_assignable<decltype(std::get<0>(std::declval<_UPair>())),
600 decltype(std::get<1>(std::declval<_UPair>()))>();
607 pair& operator=(
const pair&) =
delete;
611 operator=(
const pair& __p)
612 noexcept(_S_nothrow_assignable<const _T1&, const _T2&>())
613 requires (_S_assignable<const _T1&, const _T2&>())
622 operator=(
pair&& __p)
623 noexcept(_S_nothrow_assignable<_T1, _T2>())
624 requires (_S_assignable<_T1, _T2>())
626 first = std::forward<first_type>(__p.first);
627 second = std::forward<second_type>(__p.second);
632 template<
typename _U1,
typename _U2>
634 operator=(
const pair<_U1, _U2>& __p)
635 noexcept(_S_nothrow_assignable<const _U1&, const _U2&>())
636 requires (_S_assignable<const _U1&, const _U2&>())
644 template<
typename _U1,
typename _U2>
646 operator=(pair<_U1, _U2>&& __p)
647 noexcept(_S_nothrow_assignable<_U1, _U2>())
648 requires (_S_assignable<_U1, _U2>())
650 first = std::forward<_U1>(__p.first);
651 second = std::forward<_U2>(__p.second);
655 #if __glibcxx_ranges_zip
657 constexpr const pair&
658 operator=(
const pair& __p)
const
659 requires (_S_const_assignable<const first_type&, const second_type&>())
667 constexpr
const pair&
668 operator=(
pair&& __p)
const
669 requires (_S_const_assignable<first_type, second_type>())
671 first = std::forward<first_type>(__p.first);
672 second = std::forward<second_type>(__p.second);
677 template<
typename _U1,
typename _U2>
678 constexpr
const pair&
679 operator=(
const pair<_U1, _U2>& __p)
const
680 requires (_S_const_assignable<const _U1&, const _U2&>())
688 template<
typename _U1,
typename _U2>
689 constexpr
const pair&
690 operator=(pair<_U1, _U2>&& __p)
const
691 requires (_S_const_assignable<_U1, _U2>())
693 first = std::forward<_U1>(__p.first);
694 second = std::forward<_U2>(__p.second);
699 #if __glibcxx_tuple_like
700 template<__eligible_pair_like<pair> _UPair>
701 requires (_S_assignable_from_tuple_like<_UPair>())
705 first = std::get<0>(std::forward<_UPair>(__p));
706 second = std::get<1>(std::forward<_UPair>(__p));
710 template<__eligible_pair_like<pair> _UPair>
711 requires (_S_const_assignable_from_tuple_like<_UPair>())
712 constexpr const
pair&
715 first = std::get<0>(std::forward<_UPair>(__p));
716 second = std::get<1>(std::forward<_UPair>(__p));
726 #if __has_builtin(__reference_constructs_from_temporary) \
727 && defined _GLIBCXX_DEBUG
728 # define __glibcxx_no_dangling_refs(_U1, _U2) \
729 static_assert(!__reference_constructs_from_temporary(_T1, _U1) \
730 && !__reference_constructs_from_temporary(_T2, _U2), \
731 "std::pair constructor creates a dangling reference")
733 # define __glibcxx_no_dangling_refs(_U1, _U2)
739 template <
typename _U1 = _T1,
741 typename enable_if<__and_<
742 __is_implicitly_default_constructible<_U1>,
743 __is_implicitly_default_constructible<_U2>>
744 ::value,
bool>::type =
true>
748 template <
typename _U1 = _T1,
754 __and_<__is_implicitly_default_constructible<_U1>,
755 __is_implicitly_default_constructible<_U2>>>>
756 ::value,
bool>::type =
false>
757 explicit constexpr
pair()
762 using _PCCP = _PCC<true, _T1, _T2>;
766 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
767 enable_if<_PCCP::template
768 _ConstructiblePair<_U1, _U2>()
770 _ImplicitlyConvertiblePair<_U1, _U2>(),
772 constexpr
pair(
const _T1& __a,
const _T2& __b)
776 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
778 _ConstructiblePair<_U1, _U2>()
780 _ImplicitlyConvertiblePair<_U1, _U2>(),
782 explicit constexpr
pair(
const _T1& __a,
const _T2& __b)
787 template <
typename _U1,
typename _U2>
788 using _PCCFP = _PCC<!is_same<_T1, _U1>::value
793 template<
typename _U1,
typename _U2,
typename
795 _ConstructiblePair<_U1, _U2>()
796 && _PCCFP<_U1, _U2>::template
797 _ImplicitlyConvertiblePair<_U1, _U2>(),
801 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
803 template<
typename _U1,
typename _U2,
typename
804 enable_if<_PCCFP<_U1, _U2>::template
805 _ConstructiblePair<_U1, _U2>()
806 && !_PCCFP<_U1, _U2>::template
807 _ImplicitlyConvertiblePair<_U1, _U2>(),
809 explicit constexpr
pair(
const pair<_U1, _U2>& __p)
811 { __glibcxx_no_dangling_refs(
const _U1&,
const _U2&); }
813 #if _GLIBCXX_USE_DEPRECATED
814 #if defined(__DEPRECATED)
815 # define _GLIBCXX_DEPRECATED_PAIR_CTOR \
816 __attribute__ ((__deprecated__ ("use 'nullptr' instead of '0' to " \
817 "initialize std::pair of move-only " \
818 "type and pointer")))
820 # define _GLIBCXX_DEPRECATED_PAIR_CTOR
827 struct __zero_as_null_pointer_constant
829 __zero_as_null_pointer_constant(
int __zero_as_null_pointer_constant::*)
831 template<
typename _Tp,
832 typename = __enable_if_t<is_null_pointer<_Tp>::value>>
833 __zero_as_null_pointer_constant(_Tp) =
delete;
841 template<
typename _U1,
842 __enable_if_t<__and_<__not_<is_reference<_U1>>,
844 is_constructible<_T1, _U1>,
845 __not_<is_constructible<_T1, const _U1&>>,
846 is_convertible<_U1, _T1>>::value,
848 _GLIBCXX_DEPRECATED_PAIR_CTOR
850 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
852 { __glibcxx_no_dangling_refs(_U1&&, std::nullptr_t); }
854 template<
typename _U1,
855 __enable_if_t<__and_<__not_<is_reference<_U1>>,
857 is_constructible<_T1, _U1>,
858 __not_<is_constructible<_T1, const _U1&>>,
859 __not_<is_convertible<_U1, _T1>>>::value,
861 _GLIBCXX_DEPRECATED_PAIR_CTOR
863 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
865 { __glibcxx_no_dangling_refs(_U1&&, std::nullptr_t); }
867 template<
typename _U2,
868 __enable_if_t<__and_<is_pointer<_T1>,
869 __not_<is_reference<_U2>>,
870 is_constructible<_T2, _U2>,
871 __not_<is_constructible<_T2, const _U2&>>,
872 is_convertible<_U2, _T2>>::value,
874 _GLIBCXX_DEPRECATED_PAIR_CTOR
876 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
878 { __glibcxx_no_dangling_refs(std::nullptr_t, _U2&&); }
880 template<
typename _U2,
881 __enable_if_t<__and_<is_pointer<_T1>,
882 __not_<is_reference<_U2>>,
883 is_constructible<_T2, _U2>,
884 __not_<is_constructible<_T2, const _U2&>>,
885 __not_<is_convertible<_U2, _T2>>>::value,
887 _GLIBCXX_DEPRECATED_PAIR_CTOR
889 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
891 { __glibcxx_no_dangling_refs(std::nullptr_t, _U2&&); }
892 #undef _GLIBCXX_DEPRECATED_PAIR_CTOR
895 template<
typename _U1,
typename _U2,
typename
896 enable_if<_PCCP::template
897 _MoveConstructiblePair<_U1, _U2>()
899 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
901 constexpr
pair(_U1&& __x, _U2&& __y)
903 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
905 template<
typename _U1,
typename _U2,
typename
906 enable_if<_PCCP::template
907 _MoveConstructiblePair<_U1, _U2>()
909 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
911 explicit constexpr
pair(_U1&& __x, _U2&& __y)
913 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
916 template<
typename _U1,
typename _U2,
typename
917 enable_if<_PCCFP<_U1, _U2>::template
918 _MoveConstructiblePair<_U1, _U2>()
919 && _PCCFP<_U1, _U2>::template
920 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
922 constexpr
pair(pair<_U1, _U2>&& __p)
925 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
927 template<
typename _U1,
typename _U2,
typename
928 enable_if<_PCCFP<_U1, _U2>::template
929 _MoveConstructiblePair<_U1, _U2>()
930 && !_PCCFP<_U1, _U2>::template
931 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
933 explicit constexpr
pair(pair<_U1, _U2>&& __p)
936 { __glibcxx_no_dangling_refs(_U1&&, _U2&&); }
938 #undef __glibcxx_no_dangling_refs
941 operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
942 is_copy_assignable<_T2>>::value,
943 const pair&,
const __nonesuch&> __p)
951 operator=(__conditional_t<__and_<is_move_assignable<_T1>,
952 is_move_assignable<_T2>>::value,
953 pair&&, __nonesuch&&> __p)
954 noexcept(__and_<is_nothrow_move_assignable<_T1>,
955 is_nothrow_move_assignable<_T2>>::value)
957 first = std::forward<first_type>(__p.first);
958 second = std::forward<second_type>(__p.second);
962 template<
typename _U1,
typename _U2>
963 typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
964 is_assignable<_T2&, const _U2&>>::value,
966 operator=(
const pair<_U1, _U2>& __p)
973 template<
typename _U1,
typename _U2>
974 typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
975 is_assignable<_T2&, _U2&&>>::value,
977 operator=(pair<_U1, _U2>&& __p)
979 first = std::forward<_U1>(__p.first);
980 second = std::forward<_U2>(__p.second);
994 pair(
const _T1& __a,
const _T2& __b)
998 template<
typename _U1,
typename _U2>
999 pair(
const pair<_U1, _U2>& __p)
1002 #if __has_builtin(__reference_constructs_from_temporary)
1003 #pragma GCC diagnostic push
1004 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
1005 typedef int _DanglingCheck1[
1006 __reference_constructs_from_temporary(_T1,
const _U1&) ? -1 : 1
1008 typedef int _DanglingCheck2[
1009 __reference_constructs_from_temporary(_T2,
const _U2&) ? -1 : 1
1011 #pragma GCC diagnostic pop
1019 #if __cpp_deduction_guides >= 201606
1023 #if __cpp_lib_three_way_comparison
1028 template<
typename _T1,
typename _T2,
typename _U1,
typename _U2>
1033 { __x.first == __y.first } -> __detail::__boolean_testable;
1034 { __x.second == __y.second } -> __detail::__boolean_testable;
1036 {
return __x.first == __y.first && __x.second == __y.second; }
1045 template<
typename _T1,
typename _T2,
typename _U1,
typename _U2>
1047 constexpr common_comparison_category_t<__detail::__synth3way_t<_T1, _U1>,
1048 __detail::__synth3way_t<_T2, _U2>>
1049 operator<=>(
const pair<_T1, _T2>& __x,
const pair<_U1, _U2>& __y)
1051 if (
auto __c = __detail::__synth3way(__x.first, __y.first); __c != 0)
1053 return __detail::__synth3way(__x.second, __y.second);
1057 template<
typename _T1,
typename _T2>
1059 inline _GLIBCXX_CONSTEXPR
bool
1060 operator==(
const pair<_T1, _T2>& __x,
const pair<_T1, _T2>& __y)
1061 {
return __x.first == __y.first && __x.second == __y.second; }
1070 template<
typename _T1,
typename _T2>
1072 inline _GLIBCXX_CONSTEXPR
bool
1073 operator<(
const pair<_T1, _T2>& __x,
const pair<_T1, _T2>& __y)
1074 {
return __x.first < __y.first
1075 || (!(__y.first < __x.first) && __x.second < __y.second); }
1078 template<
typename _T1,
typename _T2>
1080 inline _GLIBCXX_CONSTEXPR
bool
1081 operator!=(
const pair<_T1, _T2>& __x,
const pair<_T1, _T2>& __y)
1082 {
return !(__x == __y); }
1085 template<
typename _T1,
typename _T2>
1087 inline _GLIBCXX_CONSTEXPR
bool
1088 operator>(
const pair<_T1, _T2>& __x,
const pair<_T1, _T2>& __y)
1089 {
return __y < __x; }
1092 template<
typename _T1,
typename _T2>
1094 inline _GLIBCXX_CONSTEXPR
bool
1095 operator<=(
const pair<_T1, _T2>& __x,
const pair<_T1, _T2>& __y)
1096 {
return !(__y < __x); }
1099 template<
typename _T1,
typename _T2>
1101 inline _GLIBCXX_CONSTEXPR
bool
1102 operator>=(
const pair<_T1, _T2>& __x,
const pair<_T1, _T2>& __y)
1103 {
return !(__x < __y); }
1106 #if __cplusplus >= 201103L
1112 template<
typename _T1,
typename _T2>
1113 _GLIBCXX20_CONSTEXPR
inline
1114 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
1116 typename enable_if<__and_<__is_swappable<_T1>,
1117 __is_swappable<_T2>>::value>::type
1122 noexcept(noexcept(__x.swap(__y)))
1125 #if __glibcxx_ranges_zip
1126 template<
typename _T1,
typename _T2>
1127 requires is_swappable_v<const _T1> && is_swappable_v<const _T2>
1130 noexcept(noexcept(__x.swap(__y)))
1134 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
1135 template<
typename _T1,
typename _T2>
1136 typename enable_if<!__and_<__is_swappable<_T1>,
1137 __is_swappable<_T2>>::value>::type
1138 swap(pair<_T1, _T2>&, pair<_T1, _T2>&) =
delete;
1159 #if __cplusplus >= 201103L
1161 template<
typename _T1,
typename _T2>
1162 constexpr pair<typename __decay_and_strip<_T1>::__type,
1163 typename __decay_and_strip<_T2>::__type>
1166 typedef typename __decay_and_strip<_T1>::__type __ds_type1;
1167 typedef typename __decay_and_strip<_T2>::__type __ds_type2;
1169 return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
1172 template<
typename _T1,
typename _T2>
1174 make_pair(_T1 __x, _T2 __y)
1180 #if __cplusplus >= 201103L
1184 template<
typename _T1,
typename _T2>
1185 struct __is_tuple_like_impl<pair<_T1, _T2>> :
true_type
1190 template<
class _Tp1,
class _Tp2>
1195 template<
class _Tp1,
class _Tp2>
1197 {
typedef _Tp1 type; };
1200 template<
class _Tp1,
class _Tp2>
1202 {
typedef _Tp2 type; };
1204 #if __cplusplus >= 201703L
1205 template<
typename _Tp1,
typename _Tp2>
1206 inline constexpr
size_t tuple_size_v<pair<_Tp1, _Tp2>> = 2;
1208 template<
typename _Tp1,
typename _Tp2>
1209 inline constexpr
size_t tuple_size_v<const pair<_Tp1, _Tp2>> = 2;
1212 #if __cplusplus >= 201103L
1213 #pragma GCC diagnostic push
1214 #pragma GCC diagnostic ignored "-Wc++14-extensions"
1215 #pragma GCC diagnostic ignored "-Wc++17-extensions"
1216 template<
typename _Tp>
1217 inline constexpr
bool __is_pair =
false;
1219 template<
typename _Tp,
typename _Up>
1220 inline constexpr
bool __is_pair<pair<_Tp, _Up>> =
true;
1221 #pragma GCC diagnostic pop
1225 template<
size_t _Int>
1229 struct __pair_get<0>
1231 template<
typename _Tp1,
typename _Tp2>
1232 static constexpr _Tp1&
1234 {
return __pair.first; }
1236 template<
typename _Tp1,
typename _Tp2>
1237 static constexpr _Tp1&&
1238 __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept
1239 {
return std::forward<_Tp1>(__pair.first); }
1241 template<
typename _Tp1,
typename _Tp2>
1242 static constexpr
const _Tp1&
1243 __const_get(
const pair<_Tp1, _Tp2>& __pair) noexcept
1244 {
return __pair.first; }
1246 template<
typename _Tp1,
typename _Tp2>
1247 static constexpr
const _Tp1&&
1248 __const_move_get(
const pair<_Tp1, _Tp2>&& __pair) noexcept
1249 {
return std::forward<const _Tp1>(__pair.first); }
1253 struct __pair_get<1>
1255 template<
typename _Tp1,
typename _Tp2>
1256 static constexpr _Tp2&
1257 __get(pair<_Tp1, _Tp2>& __pair) noexcept
1258 {
return __pair.second; }
1260 template<
typename _Tp1,
typename _Tp2>
1261 static constexpr _Tp2&&
1262 __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept
1263 {
return std::forward<_Tp2>(__pair.second); }
1265 template<
typename _Tp1,
typename _Tp2>
1266 static constexpr
const _Tp2&
1267 __const_get(
const pair<_Tp1, _Tp2>& __pair) noexcept
1268 {
return __pair.second; }
1270 template<
typename _Tp1,
typename _Tp2>
1271 static constexpr
const _Tp2&&
1272 __const_move_get(
const pair<_Tp1, _Tp2>&& __pair) noexcept
1273 {
return std::forward<const _Tp2>(__pair.second); }
1281 template<
size_t _Int,
class _Tp1,
class _Tp2>
1282 constexpr
typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&
1284 {
return __pair_get<_Int>::__get(__in); }
1286 template<
size_t _Int,
class _Tp1,
class _Tp2>
1287 constexpr
typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&&
1289 {
return __pair_get<_Int>::__move_get(
std::move(__in)); }
1291 template<
size_t _Int,
class _Tp1,
class _Tp2>
1292 constexpr
const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&
1294 {
return __pair_get<_Int>::__const_get(__in); }
1296 template<
size_t _Int,
class _Tp1,
class _Tp2>
1297 constexpr
const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&&
1299 {
return __pair_get<_Int>::__const_move_get(
std::move(__in)); }
1302 #ifdef __glibcxx_tuples_by_type
1303 template <
typename _Tp,
typename _Up>
1306 {
return __p.first; }
1308 template <
typename _Tp,
typename _Up>
1309 constexpr
const _Tp&
1311 {
return __p.first; }
1313 template <
typename _Tp,
typename _Up>
1318 template <
typename _Tp,
typename _Up>
1319 constexpr
const _Tp&&
1323 template <
typename _Tp,
typename _Up>
1326 {
return __p.second; }
1328 template <
typename _Tp,
typename _Up>
1329 constexpr
const _Tp&
1331 {
return __p.second; }
1333 template <
typename _Tp,
typename _Up>
1338 template <
typename _Tp,
typename _Up>
1339 constexpr
const _Tp&&
1345 #if __glibcxx_ranges_zip
1346 template<
typename _T1,
typename _T2,
typename _U1,
typename _U2,
1347 template<
typename>
class _TQual,
template<
typename>
class _UQual>
1348 requires requires {
typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>,
1349 common_reference_t<_TQual<_T2>, _UQual<_U2>>>; }
1350 struct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual>
1352 using type = pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>,
1353 common_reference_t<_TQual<_T2>, _UQual<_U2>>>;
1356 template<
typename _T1,
typename _T2,
typename _U1,
typename _U2>
1357 requires requires {
typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; }
1358 struct common_type<pair<_T1, _T2>, pair<_U1, _U2>>
1359 {
using type = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; };
1365 _GLIBCXX_END_NAMESPACE_VERSION
constexpr bool operator<=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator<(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
pair(_T1, _T2) -> pair< _T1, _T2 >
Two pairs are equal iff their members are equal.
constexpr enable_if< __and_< __is_swappable< _T1 >, __is_swappable< _T2 > >::value >::type swap(pair< _T1, _T2 > &__x, pair< _T1, _T2 > &__y) noexcept(noexcept(__x.swap(__y)))
constexpr piecewise_construct_t piecewise_construct
Tag for piecewise construction of std::pair objects.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
constexpr common_comparison_category_t< __detail::__synth3way_t< _T1, _U1 >, __detail::__synth3way_t< _T2, _U2 > > operator(const pair< _T1, _T2 > &__x, const pair< _U1, _U2 > &__y)
ISO C++ entities toplevel namespace is std.
constexpr const _Tp && get(const pair< _Up, _Tp > &&__p) noexcept
A standard container for storing a fixed size sequence of elements.
Primary class template, tuple.
Define a member typedef type only if a boolean constant is true.
Struct holding two objects of arbitrary type.
constexpr pair(const _T1 &__a, const _T2 &__b)
Construct from two const lvalues, allowing implicit conversions.
_T1 first
The first member.
_T1 first_type
The type of the first member.
constexpr void swap(pair &__p) noexcept(__and_< __is_nothrow_swappable< _T1 >, __is_nothrow_swappable< _T2 >>::value)
Swap the first members and then the second members.
constexpr pair(const pair &)=default
Copy constructor.
_T2 second_type
The type of the second member.
constexpr pair(pair &&)=default
Move constructor.
_T2 second
The second member.
Tag type for piecewise construction of std::pair objects.
Finds the size of a given tuple type.
Gives the type of the ith element of a given tuple type.