59 #if __cplusplus >= 201103L
64 #if __cplusplus >= 202002L
66 # define __cpp_lib_constexpr_utility 201811L
69 namespace std _GLIBCXX_VISIBILITY(default)
71 _GLIBCXX_BEGIN_NAMESPACE_VERSION
78 #if __cplusplus >= 201103L
95 #if ! __cpp_lib_concepts
101 template <
bool,
typename _T1,
typename _T2>
104 template <
typename _U1,
typename _U2>
105 static constexpr
bool _ConstructiblePair()
107 return __and_<is_constructible<_T1, const _U1&>,
111 template <
typename _U1,
typename _U2>
112 static constexpr
bool _ImplicitlyConvertiblePair()
114 return __and_<is_convertible<const _U1&, _T1>,
115 is_convertible<const _U2&, _T2>>::value;
118 template <
typename _U1,
typename _U2>
119 static constexpr
bool _MoveConstructiblePair()
121 return __and_<is_constructible<_T1, _U1&&>,
122 is_constructible<_T2, _U2&&>>::value;
125 template <
typename _U1,
typename _U2>
126 static constexpr
bool _ImplicitlyMoveConvertiblePair()
128 return __and_<is_convertible<_U1&&, _T1>,
129 is_convertible<_U2&&, _T2>>::value;
132 template <
bool __implicit,
typename _U1,
typename _U2>
133 static constexpr
bool _DeprConsPair()
135 using __do_converts = __and_<is_convertible<_U1&&, _T1>,
136 is_convertible<_U2&&, _T2>>;
137 using __converts = __conditional_t<__implicit,
139 __not_<__do_converts>>;
140 return __and_<is_constructible<_T1, _U1&&>,
141 is_constructible<_T2, _U2&&>,
147 template <
typename _T1,
typename _T2>
148 struct _PCC<false, _T1, _T2>
150 template <
typename _U1,
typename _U2>
151 static constexpr
bool _ConstructiblePair()
156 template <
typename _U1,
typename _U2>
157 static constexpr
bool _ImplicitlyConvertiblePair()
162 template <
typename _U1,
typename _U2>
163 static constexpr
bool _MoveConstructiblePair()
168 template <
typename _U1,
typename _U2>
169 static constexpr
bool _ImplicitlyMoveConvertiblePair()
177 template<
typename _U1,
typename _U2>
class __pair_base
179 #if __cplusplus >= 201103L && ! __cpp_lib_concepts
180 template<
typename _T1,
typename _T2>
friend struct pair;
181 __pair_base() =
default;
182 ~__pair_base() =
default;
183 __pair_base(
const __pair_base&) =
default;
184 __pair_base& operator=(
const __pair_base&) =
delete;
198 template<
typename _T1,
typename _T2>
200 :
public __pair_base<_T1, _T2>
208 #if __cplusplus >= 201103L
212 template<
typename... _Args1,
typename... _Args2>
217 _GLIBCXX20_CONSTEXPR
void
219 noexcept(__and_<__is_nothrow_swappable<_T1>,
220 __is_nothrow_swappable<_T2>>::value)
228 template<
typename... _Args1,
size_t... _Indexes1,
229 typename... _Args2,
size_t... _Indexes2>
232 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
235 #if __cpp_lib_concepts
240 explicit(__not_<__and_<__is_implicitly_default_constructible<_T1>,
241 __is_implicitly_default_constructible<_T2>>>())
243 requires is_default_constructible_v<_T1>
244 && is_default_constructible_v<_T2>
251 template<
typename _U1,
typename _U2>
252 static constexpr
bool
255 if constexpr (is_constructible_v<_T1, _U1>)
256 return is_constructible_v<_T2, _U2>;
260 template<
typename _U1,
typename _U2>
261 static constexpr
bool
262 _S_nothrow_constructible()
264 if constexpr (is_nothrow_constructible_v<_T1, _U1>)
265 return is_nothrow_constructible_v<_T2, _U2>;
269 template<
typename _U1,
typename _U2>
270 static constexpr
bool
273 if constexpr (is_convertible_v<_U1, _T1>)
274 return is_convertible_v<_U2, _T2>;
282 constexpr
explicit(!_S_convertible<const _T1&, const _T2&>())
283 pair(
const _T1& __x,
const _T2& __y)
284 noexcept(_S_nothrow_constructible<const _T1&, const _T2&>())
285 requires (_S_constructible<const _T1&, const _T2&>())
290 template<
typename _U1,
typename _U2>
291 requires (_S_constructible<_U1, _U2>())
292 constexpr explicit(!_S_convertible<_U1, _U2>())
293 pair(_U1&& __x, _U2&& __y)
294 noexcept(_S_nothrow_constructible<_U1, _U2>())
299 template<
typename _U1,
typename _U2>
300 requires (_S_constructible<const _U1&, const _U2&>())
301 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
303 noexcept(_S_nothrow_constructible<const _U1&, const _U2&>())
308 template<
typename _U1,
typename _U2>
309 requires (_S_constructible<_U1, _U2>())
310 constexpr explicit(!_S_convertible<_U1, _U2>())
312 noexcept(_S_nothrow_constructible<_U1, _U2>())
319 template<
typename _U1,
typename _U2>
320 static constexpr
bool
323 if constexpr (is_assignable_v<_T1&, _U1>)
324 return is_assignable_v<_T2&, _U2>;
328 template<
typename _U1,
typename _U2>
329 static constexpr
bool
330 _S_nothrow_assignable()
332 if constexpr (is_nothrow_assignable_v<_T1&, _U1>)
333 return is_nothrow_assignable_v<_T2&, _U2>;
340 pair& operator=(
const pair&) =
delete;
344 operator=(
const pair& __p)
345 noexcept(_S_nothrow_assignable<const _T1&, const _T2&>())
346 requires (_S_assignable<const _T1&, const _T2&>())
355 operator=(
pair&& __p)
356 noexcept(_S_nothrow_assignable<_T1, _T2>())
357 requires (_S_assignable<_T1, _T2>())
359 first = std::forward<first_type>(__p.first);
360 second = std::forward<second_type>(__p.second);
365 template<
typename _U1,
typename _U2>
367 operator=(
const pair<_U1, _U2>& __p)
368 noexcept(_S_nothrow_assignable<const _U1&, const _U2&>())
369 requires (_S_assignable<const _U1&, const _U2&>())
377 template<
typename _U1,
typename _U2>
379 operator=(pair<_U1, _U2>&& __p)
380 noexcept(_S_nothrow_assignable<_U1, _U2>())
381 requires (_S_assignable<_U1, _U2>())
383 first = std::forward<_U1>(__p.first);
384 second = std::forward<_U2>(__p.second);
392 template <
typename _U1 = _T1,
394 typename enable_if<__and_<
395 __is_implicitly_default_constructible<_U1>,
396 __is_implicitly_default_constructible<_U2>>
397 ::value,
bool>::type =
true>
401 template <
typename _U1 = _T1,
407 __and_<__is_implicitly_default_constructible<_U1>,
408 __is_implicitly_default_constructible<_U2>>>>
409 ::value,
bool>::type =
false>
410 explicit constexpr
pair()
415 using _PCCP = _PCC<true, _T1, _T2>;
419 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
420 enable_if<_PCCP::template
421 _ConstructiblePair<_U1, _U2>()
423 _ImplicitlyConvertiblePair<_U1, _U2>(),
425 constexpr
pair(
const _T1& __a,
const _T2& __b)
429 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
431 _ConstructiblePair<_U1, _U2>()
433 _ImplicitlyConvertiblePair<_U1, _U2>(),
435 explicit constexpr
pair(
const _T1& __a,
const _T2& __b)
440 template <
typename _U1,
typename _U2>
441 using _PCCFP = _PCC<!is_same<_T1, _U1>::value
446 template<
typename _U1,
typename _U2,
typename
448 _ConstructiblePair<_U1, _U2>()
449 && _PCCFP<_U1, _U2>::template
450 _ImplicitlyConvertiblePair<_U1, _U2>(),
455 template<
typename _U1,
typename _U2,
typename
456 enable_if<_PCCFP<_U1, _U2>::template
457 _ConstructiblePair<_U1, _U2>()
458 && !_PCCFP<_U1, _U2>::template
459 _ImplicitlyConvertiblePair<_U1, _U2>(),
461 explicit constexpr
pair(
const pair<_U1, _U2>& __p)
464 #if _GLIBCXX_USE_DEPRECATED
465 #if defined(__DEPRECATED)
466 # define _GLIBCXX_DEPRECATED_PAIR_CTOR \
467 __attribute__ ((__deprecated__ ("use 'nullptr' instead of '0' to " \
468 "initialize std::pair of move-only " \
469 "type and pointer")))
471 # define _GLIBCXX_DEPRECATED_PAIR_CTOR
478 struct __zero_as_null_pointer_constant
480 __zero_as_null_pointer_constant(
int __zero_as_null_pointer_constant::*)
482 template<
typename _Tp,
483 typename = __enable_if_t<is_null_pointer<_Tp>::value>>
484 __zero_as_null_pointer_constant(_Tp) =
delete;
492 template<
typename _U1,
493 __enable_if_t<__and_<__not_<is_reference<_U1>>,
495 is_constructible<_T1, _U1>,
496 __not_<is_constructible<_T1, const _U1&>>,
497 is_convertible<_U1, _T1>>::value,
499 _GLIBCXX_DEPRECATED_PAIR_CTOR
501 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
504 template<
typename _U1,
505 __enable_if_t<__and_<__not_<is_reference<_U1>>,
507 is_constructible<_T1, _U1>,
508 __not_<is_constructible<_T1, const _U1&>>,
509 __not_<is_convertible<_U1, _T1>>>::value,
511 _GLIBCXX_DEPRECATED_PAIR_CTOR
513 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
516 template<
typename _U2,
517 __enable_if_t<__and_<is_pointer<_T1>,
518 __not_<is_reference<_U2>>,
519 is_constructible<_T2, _U2>,
520 __not_<is_constructible<_T2, const _U2&>>,
521 is_convertible<_U2, _T2>>::value,
523 _GLIBCXX_DEPRECATED_PAIR_CTOR
525 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
528 template<
typename _U2,
529 __enable_if_t<__and_<is_pointer<_T1>,
530 __not_<is_reference<_U2>>,
531 is_constructible<_T2, _U2>,
532 __not_<is_constructible<_T2, const _U2&>>,
533 __not_<is_convertible<_U2, _T2>>>::value,
535 _GLIBCXX_DEPRECATED_PAIR_CTOR
537 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
539 #undef _GLIBCXX_DEPRECATED_PAIR_CTOR
542 template<
typename _U1,
typename _U2,
typename
543 enable_if<_PCCP::template
544 _MoveConstructiblePair<_U1, _U2>()
546 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
548 constexpr
pair(_U1&& __x, _U2&& __y)
551 template<
typename _U1,
typename _U2,
typename
552 enable_if<_PCCP::template
553 _MoveConstructiblePair<_U1, _U2>()
555 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
557 explicit constexpr
pair(_U1&& __x, _U2&& __y)
561 template<
typename _U1,
typename _U2,
typename
562 enable_if<_PCCFP<_U1, _U2>::template
563 _MoveConstructiblePair<_U1, _U2>()
564 && _PCCFP<_U1, _U2>::template
565 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
567 constexpr
pair(pair<_U1, _U2>&& __p)
571 template<
typename _U1,
typename _U2,
typename
572 enable_if<_PCCFP<_U1, _U2>::template
573 _MoveConstructiblePair<_U1, _U2>()
574 && !_PCCFP<_U1, _U2>::template
575 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
577 explicit constexpr
pair(pair<_U1, _U2>&& __p)
582 operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
583 is_copy_assignable<_T2>>::value,
584 const pair&,
const __nonesuch&> __p)
592 operator=(__conditional_t<__and_<is_move_assignable<_T1>,
593 is_move_assignable<_T2>>::value,
594 pair&&, __nonesuch&&> __p)
595 noexcept(__and_<is_nothrow_move_assignable<_T1>,
596 is_nothrow_move_assignable<_T2>>::value)
598 first = std::forward<first_type>(__p.first);
599 second = std::forward<second_type>(__p.second);
603 template<
typename _U1,
typename _U2>
604 typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
605 is_assignable<_T2&, const _U2&>>::value,
607 operator=(
const pair<_U1, _U2>& __p)
614 template<
typename _U1,
typename _U2>
615 typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
616 is_assignable<_T2&, _U2&&>>::value,
618 operator=(pair<_U1, _U2>&& __p)
620 first = std::forward<_U1>(__p.first);
621 second = std::forward<_U2>(__p.second);
635 pair(
const _T1& __a,
const _T2& __b)
639 template<
typename _U1,
typename _U2>
640 pair(
const pair<_U1, _U2>& __p)
647 #if __cpp_deduction_guides >= 201606
652 template<
typename _T1,
typename _T2>
653 inline _GLIBCXX_CONSTEXPR
bool
657 #if __cpp_lib_three_way_comparison && __cpp_lib_concepts
658 template<
typename _T1,
typename _T2>
659 constexpr common_comparison_category_t<__detail::__synth3way_t<_T1>,
660 __detail::__synth3way_t<_T2>>
663 if (
auto __c = __detail::__synth3way(__x.
first, __y.
first); __c != 0)
675 template<
typename _T1,
typename _T2>
676 inline _GLIBCXX_CONSTEXPR
bool
682 template<
typename _T1,
typename _T2>
683 inline _GLIBCXX_CONSTEXPR
bool
685 {
return !(__x == __y); }
688 template<
typename _T1,
typename _T2>
689 inline _GLIBCXX_CONSTEXPR
bool
691 {
return __y < __x; }
694 template<
typename _T1,
typename _T2>
695 inline _GLIBCXX_CONSTEXPR
bool
697 {
return !(__y < __x); }
700 template<
typename _T1,
typename _T2>
701 inline _GLIBCXX_CONSTEXPR
bool
703 {
return !(__x < __y); }
706 #if __cplusplus >= 201103L
712 template<
typename _T1,
typename _T2>
713 _GLIBCXX20_CONSTEXPR
inline
714 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
717 __is_swappable<_T2>>::value>::type
722 noexcept(noexcept(__x.
swap(__y)))
725 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
726 template<
typename _T1,
typename _T2>
728 __is_swappable<_T2>>::value>::type
750 #if __cplusplus >= 201103L
752 template<
typename _T1,
typename _T2>
754 typename __decay_and_strip<_T2>::__type>
757 typedef typename __decay_and_strip<_T1>::__type __ds_type1;
758 typedef typename __decay_and_strip<_T2>::__type __ds_type2;
760 return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
763 template<
typename _T1,
typename _T2>
765 make_pair(_T1 __x, _T2 __y)
771 #if __cplusplus >= 201103L
774 template<
typename _T1,
typename _T2>
775 struct __is_tuple_like_impl<pair<_T1, _T2>> :
true_type
779 template<
class _Tp1,
class _Tp2>
784 template<
class _Tp1,
class _Tp2>
786 {
typedef _Tp1 type; };
789 template<
class _Tp1,
class _Tp2>
791 {
typedef _Tp2 type; };
793 #if __cplusplus >= 201703L
794 template<
typename _Tp1,
typename _Tp2>
795 inline constexpr
size_t tuple_size_v<pair<_Tp1, _Tp2>> = 2;
797 template<
typename _Tp1,
typename _Tp2>
798 inline constexpr
size_t tuple_size_v<const pair<_Tp1, _Tp2>> = 2;
800 template<
typename _Tp>
801 inline constexpr
bool __is_pair =
false;
803 template<
typename _Tp,
typename _Up>
804 inline constexpr
bool __is_pair<pair<_Tp, _Up>> =
true;
806 template<
typename _Tp,
typename _Up>
807 inline constexpr
bool __is_pair<const pair<_Tp, _Up>> =
true;
811 template<
size_t _Int>
817 template<
typename _Tp1,
typename _Tp2>
818 static constexpr _Tp1&
820 {
return __pair.first; }
822 template<
typename _Tp1,
typename _Tp2>
823 static constexpr _Tp1&&
824 __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept
825 {
return std::forward<_Tp1>(__pair.first); }
827 template<
typename _Tp1,
typename _Tp2>
828 static constexpr
const _Tp1&
829 __const_get(
const pair<_Tp1, _Tp2>& __pair) noexcept
830 {
return __pair.first; }
832 template<
typename _Tp1,
typename _Tp2>
833 static constexpr
const _Tp1&&
834 __const_move_get(
const pair<_Tp1, _Tp2>&& __pair) noexcept
835 {
return std::forward<const _Tp1>(__pair.first); }
841 template<
typename _Tp1,
typename _Tp2>
842 static constexpr _Tp2&
843 __get(pair<_Tp1, _Tp2>& __pair) noexcept
844 {
return __pair.second; }
846 template<
typename _Tp1,
typename _Tp2>
847 static constexpr _Tp2&&
848 __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept
849 {
return std::forward<_Tp2>(__pair.second); }
851 template<
typename _Tp1,
typename _Tp2>
852 static constexpr
const _Tp2&
853 __const_get(
const pair<_Tp1, _Tp2>& __pair) noexcept
854 {
return __pair.second; }
856 template<
typename _Tp1,
typename _Tp2>
857 static constexpr
const _Tp2&&
858 __const_move_get(
const pair<_Tp1, _Tp2>&& __pair) noexcept
859 {
return std::forward<const _Tp2>(__pair.second); }
867 template<
size_t _Int,
class _Tp1,
class _Tp2>
868 constexpr
typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&
870 {
return __pair_get<_Int>::__get(__in); }
872 template<
size_t _Int,
class _Tp1,
class _Tp2>
873 constexpr
typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&&
875 {
return __pair_get<_Int>::__move_get(
std::move(__in)); }
877 template<
size_t _Int,
class _Tp1,
class _Tp2>
878 constexpr
const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&
880 {
return __pair_get<_Int>::__const_get(__in); }
882 template<
size_t _Int,
class _Tp1,
class _Tp2>
883 constexpr
const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&&
885 {
return __pair_get<_Int>::__const_move_get(
std::move(__in)); }
887 #if __cplusplus >= 201402L
889 #define __cpp_lib_tuples_by_type 201304L
891 template <
typename _Tp,
typename _Up>
894 {
return __p.first; }
896 template <
typename _Tp,
typename _Up>
899 {
return __p.first; }
901 template <
typename _Tp,
typename _Up>
906 template <
typename _Tp,
typename _Up>
907 constexpr
const _Tp&&
911 template <
typename _Tp,
typename _Up>
914 {
return __p.second; }
916 template <
typename _Tp,
typename _Up>
919 {
return __p.second; }
921 template <
typename _Tp,
typename _Up>
926 template <
typename _Tp,
typename _Up>
927 constexpr
const _Tp&&
935 _GLIBCXX_END_NAMESPACE_VERSION
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
pair(_T1, _T2) -> pair< _T1, _T2 >
Two pairs of the same type are equal iff their members are equal.
constexpr bool operator>(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
Uses operator< to find the result.
constexpr bool operator!=(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
Uses operator== to find the result.
constexpr bool operator==(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
Two pairs of the same type are equal iff their members are equal.
constexpr bool operator>=(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
Uses operator< to find the result.
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.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
ISO C++ entities toplevel namespace is std.
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.