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<
size_t _Int,
class _Tp1,
class _Tp2>
108 template<
size_t _Int,
class _Tp1,
class _Tp2>
112 template<
size_t _Int,
class _Tp1,
class _Tp2>
116 template<
size_t _Int,
class _Tp1,
class _Tp2>
120 template<
size_t __i,
typename... _Elements>
121 constexpr __tuple_element_t<__i,
tuple<_Elements...>>&
124 template<
size_t __i,
typename... _Elements>
125 constexpr
const __tuple_element_t<__i,
tuple<_Elements...>>&
128 template<
size_t __i,
typename... _Elements>
129 constexpr __tuple_element_t<__i,
tuple<_Elements...>>&&
132 template<
size_t __i,
typename... _Elements>
133 constexpr
const __tuple_element_t<__i,
tuple<_Elements...>>&&
136 template<
size_t _Int,
typename _Tp,
size_t _Nm>
140 template<
size_t _Int,
typename _Tp,
size_t _Nm>
144 template<
size_t _Int, typename _Tp,
size_t _Nm>
146 get(const
array<_Tp, _Nm>&) noexcept;
148 template<
size_t _Int, typename _Tp,
size_t _Nm>
149 constexpr const _Tp&&
150 get(const
array<_Tp, _Nm>&&) noexcept;
152 #if __glibcxx_tuple_like >= 202311
153 template<
typename _Tp>
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()
241 #if __glibcxx_tuple_like
242 template<
typename _Tp>
243 inline constexpr
bool __is_tuple_v =
false;
245 template<
typename... _Ts>
246 inline constexpr
bool __is_tuple_v<tuple<_Ts...>> =
true;
249 template<
typename _Tp>
250 inline constexpr
bool __is_tuple_like_v =
false;
252 template<
typename... _Elements>
253 inline constexpr
bool __is_tuple_like_v<tuple<_Elements...>> =
true;
255 template<
typename _T1,
typename _T2>
256 inline constexpr
bool __is_tuple_like_v<pair<_T1, _T2>> =
true;
258 template<
typename _Tp,
size_t _Nm>
259 inline constexpr
bool __is_tuple_like_v<array<_Tp, _Nm>> =
true;
263 template<
typename _Tp>
264 concept __tuple_like = __is_tuple_like_v<remove_cvref_t<_Tp>>;
266 template<
typename _Tp>
267 concept __pair_like = __tuple_like<_Tp> && tuple_size_v<remove_cvref_t<_Tp>> == 2;
269 template<
typename _Tp,
typename _Tuple>
270 concept __eligible_tuple_like
271 = __detail::__different_from<_Tp, _Tuple> && __tuple_like<_Tp>
272 && (tuple_size_v<remove_cvref_t<_Tp>> == tuple_size_v<_Tuple>)
273 && !ranges::__detail::__is_subrange<remove_cvref_t<_Tp>>;
275 template<
typename _Tp,
typename _Pair>
276 concept __eligible_pair_like
277 = __detail::__different_from<_Tp, _Pair> && __pair_like<_Tp>
278 && !ranges::__detail::__is_subrange<remove_cvref_t<_Tp>>;
281 template<
typename _U1,
typename _U2>
class __pair_base
283 #if __cplusplus >= 201103L && ! __cpp_lib_concepts
284 template<
typename _T1,
typename _T2>
friend struct pair;
285 __pair_base() =
default;
286 ~__pair_base() =
default;
287 __pair_base(
const __pair_base&) =
default;
288 __pair_base& operator=(
const __pair_base&) =
delete;
304 template<
typename _T1,
typename _T2>
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()
425 return _S_constructible<decltype(std::get<0>(std::declval<_UPair>())),
426 decltype(std::get<1>(std::declval<_UPair>()))>();
429 template<
typename _UPair>
430 static constexpr
bool
431 _S_convertible_from_pair_like()
433 return _S_convertible<decltype(std::get<0>(std::declval<_UPair>())),
434 decltype(std::get<1>(std::declval<_UPair>()))>();
437 template<
typename _UPair>
438 static constexpr
bool
439 _S_dangles_from_pair_like()
441 return _S_dangles<decltype(std::get<0>(std::declval<_UPair>())),
442 decltype(std::get<1>(std::declval<_UPair>()))>();
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>())
549 :
first(std::get<0>(std::forward<_UPair>(__p))),
550 second(std::get<1>(std::forward<_UPair>(__p)))
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()
594 return _S_assignable<decltype(std::get<0>(std::declval<_UPair>())),
595 decltype(std::get<1>(std::declval<_UPair>()))>();
598 template<
typename _UPair>
599 static constexpr
bool
600 _S_const_assignable_from_tuple_like()
602 return _S_const_assignable<decltype(std::get<0>(std::declval<_UPair>())),
603 decltype(std::get<1>(std::declval<_UPair>()))>();
610 pair& operator=(
const pair&) =
delete;
614 operator=(
const pair& __p)
615 noexcept(_S_nothrow_assignable<const _T1&, const _T2&>())
616 requires (_S_assignable<const _T1&, const _T2&>())
625 operator=(
pair&& __p)
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&
661 operator=(
const pair& __p)
const
662 requires (_S_const_assignable<const first_type&, const second_type&>())
670 constexpr
const pair&
671 operator=(
pair&& __p)
const
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>())
708 first = std::get<0>(std::forward<_UPair>(__p));
709 second = std::get<1>(std::forward<_UPair>(__p));
713 template<__eligible_pair_like<pair> _UPair>
714 requires (_S_const_assignable_from_tuple_like<_UPair>())
715 constexpr const
pair&
718 first = std::get<0>(std::forward<_UPair>(__p));
719 second = std::get<1>(std::forward<_UPair>(__p));
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>(),
802 constexpr
pair(
const pair<_U1, _U2>& __p)
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>(),
812 explicit constexpr
pair(
const pair<_U1, _U2>& __p)
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>(),
925 constexpr
pair(pair<_U1, _U2>&& __p)
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>(),
936 explicit constexpr
pair(pair<_U1, _U2>&& __p)
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)
960 first = std::forward<first_type>(__p.first);
961 second = std::forward<second_type>(__p.second);
965 template<
typename _U1,
typename _U2>
966 typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
967 is_assignable<_T2&, const _U2&>>::value,
969 operator=(
const pair<_U1, _U2>& __p)
976 template<
typename _U1,
typename _U2>
977 typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
978 is_assignable<_T2&, _U2&&>>::value,
980 operator=(pair<_U1, _U2>&& __p)
982 first = std::forward<_U1>(__p.first);
983 second = std::forward<_U2>(__p.second);
997 pair(
const _T1& __a,
const _T2& __b)
1001 template<
typename _U1,
typename _U2>
1002 pair(
const pair<_U1, _U2>& __p)
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
1022 #if __cpp_deduction_guides >= 201606
1026 #if __cpp_lib_three_way_comparison
1031 template<
typename _T1,
typename _T2,
typename _U1,
typename _U2>
1036 { __x.first == __y.first } -> __detail::__boolean_testable;
1037 { __x.second == __y.second } -> __detail::__boolean_testable;
1039 {
return __x.first == __y.first && __x.second == __y.second; }
1048 template<
typename _T1,
typename _T2,
typename _U1,
typename _U2>
1050 constexpr common_comparison_category_t<__detail::__synth3way_t<_T1, _U1>,
1051 __detail::__synth3way_t<_T2, _U2>>
1052 operator<=>(
const pair<_T1, _T2>& __x,
const pair<_U1, _U2>& __y)
1054 if (
auto __c = __detail::__synth3way(__x.first, __y.first); __c != 0)
1056 return __detail::__synth3way(__x.second, __y.second);
1060 template<
typename _T1,
typename _T2>
1062 inline _GLIBCXX_CONSTEXPR
bool
1063 operator==(
const pair<_T1, _T2>& __x,
const pair<_T1, _T2>& __y)
1064 {
return __x.first == __y.first && __x.second == __y.second; }
1073 template<
typename _T1,
typename _T2>
1075 inline _GLIBCXX_CONSTEXPR
bool
1076 operator<(
const pair<_T1, _T2>& __x,
const pair<_T1, _T2>& __y)
1077 {
return __x.first < __y.first
1078 || (!(__y.first < __x.first) && __x.second < __y.second); }
1081 template<
typename _T1,
typename _T2>
1083 inline _GLIBCXX_CONSTEXPR
bool
1084 operator!=(
const pair<_T1, _T2>& __x,
const pair<_T1, _T2>& __y)
1085 {
return !(__x == __y); }
1088 template<
typename _T1,
typename _T2>
1090 inline _GLIBCXX_CONSTEXPR
bool
1091 operator>(
const pair<_T1, _T2>& __x,
const pair<_T1, _T2>& __y)
1092 {
return __y < __x; }
1095 template<
typename _T1,
typename _T2>
1097 inline _GLIBCXX_CONSTEXPR
bool
1098 operator<=(
const pair<_T1, _T2>& __x,
const pair<_T1, _T2>& __y)
1099 {
return !(__y < __x); }
1102 template<
typename _T1,
typename _T2>
1104 inline _GLIBCXX_CONSTEXPR
bool
1105 operator>=(
const pair<_T1, _T2>& __x,
const pair<_T1, _T2>& __y)
1106 {
return !(__x < __y); }
1109 #if __cplusplus >= 201103L
1115 template<
typename _T1,
typename _T2>
1116 _GLIBCXX20_CONSTEXPR
inline
1117 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
1119 typename enable_if<__and_<__is_swappable<_T1>,
1120 __is_swappable<_T2>>::value>::type
1125 noexcept(noexcept(__x.swap(__y)))
1128 #if __glibcxx_ranges_zip
1129 template<
typename _T1,
typename _T2>
1130 requires is_swappable_v<const _T1> && is_swappable_v<const _T2>
1133 noexcept(noexcept(__x.swap(__y)))
1137 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
1140 template<
typename _T1,
typename _T2>
1141 typename enable_if<!__and_<__is_swappable<_T1>,
1142 __is_swappable<_T2>>::value>::type
1143 swap(pair<_T1, _T2>&, pair<_T1, _T2>&) =
delete;
1164 #if __cplusplus >= 201103L
1166 template<
typename _T1,
typename _T2>
1167 constexpr pair<typename __decay_and_strip<_T1>::__type,
1168 typename __decay_and_strip<_T2>::__type>
1171 typedef typename __decay_and_strip<_T1>::__type __ds_type1;
1172 typedef typename __decay_and_strip<_T2>::__type __ds_type2;
1174 return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
1177 template<
typename _T1,
typename _T2>
1179 make_pair(_T1 __x, _T2 __y)
1185 #if __cplusplus >= 201103L
1189 template<
typename _T1,
typename _T2>
1190 struct __is_tuple_like_impl<pair<_T1, _T2>> :
true_type
1195 template<
class _Tp1,
class _Tp2>
1200 template<
class _Tp1,
class _Tp2>
1202 {
typedef _Tp1 type; };
1205 template<
class _Tp1,
class _Tp2>
1207 {
typedef _Tp2 type; };
1209 #if __cplusplus >= 201703L
1210 template<
typename _Tp1,
typename _Tp2>
1211 inline constexpr
size_t tuple_size_v<pair<_Tp1, _Tp2>> = 2;
1213 template<
typename _Tp1,
typename _Tp2>
1214 inline constexpr
size_t tuple_size_v<const pair<_Tp1, _Tp2>> = 2;
1217 #if __cplusplus >= 201103L
1218 #pragma GCC diagnostic push
1219 #pragma GCC diagnostic ignored "-Wc++14-extensions"
1220 #pragma GCC diagnostic ignored "-Wc++17-extensions"
1221 template<
typename _Tp>
1222 inline constexpr
bool __is_pair =
false;
1224 template<
typename _Tp,
typename _Up>
1225 inline constexpr
bool __is_pair<pair<_Tp, _Up>> =
true;
1226 #pragma GCC diagnostic pop
1230 template<
size_t _Int>
1234 struct __pair_get<0>
1236 template<
typename _Tp1,
typename _Tp2>
1237 static constexpr _Tp1&
1239 {
return __pair.first; }
1241 template<
typename _Tp1,
typename _Tp2>
1242 static constexpr _Tp1&&
1243 __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept
1244 {
return std::forward<_Tp1>(__pair.first); }
1246 template<
typename _Tp1,
typename _Tp2>
1247 static constexpr
const _Tp1&
1248 __const_get(
const pair<_Tp1, _Tp2>& __pair) noexcept
1249 {
return __pair.first; }
1251 template<
typename _Tp1,
typename _Tp2>
1252 static constexpr
const _Tp1&&
1253 __const_move_get(
const pair<_Tp1, _Tp2>&& __pair) noexcept
1254 {
return std::forward<const _Tp1>(__pair.first); }
1258 struct __pair_get<1>
1260 template<
typename _Tp1,
typename _Tp2>
1261 static constexpr _Tp2&
1262 __get(pair<_Tp1, _Tp2>& __pair) noexcept
1263 {
return __pair.second; }
1265 template<
typename _Tp1,
typename _Tp2>
1266 static constexpr _Tp2&&
1267 __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept
1268 {
return std::forward<_Tp2>(__pair.second); }
1270 template<
typename _Tp1,
typename _Tp2>
1271 static constexpr
const _Tp2&
1272 __const_get(
const pair<_Tp1, _Tp2>& __pair) noexcept
1273 {
return __pair.second; }
1275 template<
typename _Tp1,
typename _Tp2>
1276 static constexpr
const _Tp2&&
1277 __const_move_get(
const pair<_Tp1, _Tp2>&& __pair) noexcept
1278 {
return std::forward<const _Tp2>(__pair.second); }
1286 template<
size_t _Int,
class _Tp1,
class _Tp2>
1287 constexpr
typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&
1289 {
return __pair_get<_Int>::__get(__in); }
1291 template<
size_t _Int,
class _Tp1,
class _Tp2>
1292 constexpr
typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&&
1294 {
return __pair_get<_Int>::__move_get(
std::move(__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_get(__in); }
1301 template<
size_t _Int,
class _Tp1,
class _Tp2>
1302 constexpr
const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&&
1304 {
return __pair_get<_Int>::__const_move_get(
std::move(__in)); }
1307 #ifdef __glibcxx_tuples_by_type
1308 template <
typename _Tp,
typename _Up>
1311 {
return __p.first; }
1313 template <
typename _Tp,
typename _Up>
1314 constexpr
const _Tp&
1316 {
return __p.first; }
1318 template <
typename _Tp,
typename _Up>
1321 {
return std::forward<_Tp>(__p.first); }
1323 template <
typename _Tp,
typename _Up>
1324 constexpr
const _Tp&&
1326 {
return std::forward<const _Tp>(__p.first); }
1328 template <
typename _Tp,
typename _Up>
1331 {
return __p.second; }
1333 template <
typename _Tp,
typename _Up>
1334 constexpr
const _Tp&
1336 {
return __p.second; }
1338 template <
typename _Tp,
typename _Up>
1341 {
return std::forward<_Tp>(__p.second); }
1343 template <
typename _Tp,
typename _Up>
1344 constexpr
const _Tp&&
1346 {
return std::forward<const _Tp>(__p.second); }
1350 #if __glibcxx_ranges_zip
1351 template<
typename _T1,
typename _T2,
typename _U1,
typename _U2,
1352 template<
typename>
class _TQual,
template<
typename>
class _UQual>
1353 requires requires {
typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>,
1354 common_reference_t<_TQual<_T2>, _UQual<_U2>>>; }
1355 struct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual>
1357 using type = pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>,
1358 common_reference_t<_TQual<_T2>, _UQual<_U2>>>;
1361 template<
typename _T1,
typename _T2,
typename _U1,
typename _U2>
1362 requires requires {
typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; }
1363 struct common_type<pair<_T1, _T2>, pair<_U1, _U2>>
1364 {
using type = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; };
1370 _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)
constexpr const _Tp && get(const pair< _Up, _Tp > &&__p) noexcept
__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.
A standard container for storing a fixed size sequence of elements.
Primary class template, tuple.
Struct holding two objects (or references) of arbitrary type.
_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.
requires(_S_constructible< _U1, _U2 >()) &&(!_S_dangles< _U1
Constructor accepting two values of arbitrary types.
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.