59#if __cplusplus >= 201103L
64#if __cplusplus >= 202002L
66# define __cpp_lib_constexpr_utility 201811L
69namespace 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;
133 template <
typename _T1,
typename _T2>
134 struct _PCC<false, _T1, _T2>
136 template <
typename _U1,
typename _U2>
137 static constexpr bool _ConstructiblePair()
142 template <
typename _U1,
typename _U2>
143 static constexpr bool _ImplicitlyConvertiblePair()
148 template <
typename _U1,
typename _U2>
149 static constexpr bool _MoveConstructiblePair()
154 template <
typename _U1,
typename _U2>
155 static constexpr bool _ImplicitlyMoveConvertiblePair()
163 template<
typename _U1,
typename _U2>
class __pair_base
165#if __cplusplus >= 201103L && ! __cpp_lib_concepts
166 template<
typename _T1,
typename _T2>
friend struct pair;
167 __pair_base() =
default;
168 ~__pair_base() =
default;
169 __pair_base(
const __pair_base&) =
default;
170 __pair_base& operator=(
const __pair_base&) =
delete;
184 template<
typename _T1,
typename _T2>
186 :
public __pair_base<_T1, _T2>
194#if __cplusplus >= 201103L
198 template<
typename... _Args1,
typename... _Args2>
203 _GLIBCXX20_CONSTEXPR
void
205 noexcept(__and_<__is_nothrow_swappable<_T1>,
206 __is_nothrow_swappable<_T2>>::value)
214 template<
typename... _Args1,
size_t... _Indexes1,
215 typename... _Args2,
size_t... _Indexes2>
218 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
221#if __cpp_lib_concepts
226 explicit(__not_<__and_<__is_implicitly_default_constructible<_T1>,
227 __is_implicitly_default_constructible<_T2>>>())
229 requires is_default_constructible_v<_T1>
230 && is_default_constructible_v<_T2>
237 template<
typename _U1,
typename _U2>
238 static constexpr bool
241 if constexpr (is_constructible_v<_T1, _U1>)
242 return is_constructible_v<_T2, _U2>;
246 template<
typename _U1,
typename _U2>
247 static constexpr bool
248 _S_nothrow_constructible()
250 if constexpr (is_nothrow_constructible_v<_T1, _U1>)
251 return is_nothrow_constructible_v<_T2, _U2>;
255 template<
typename _U1,
typename _U2>
256 static constexpr bool
259 if constexpr (is_convertible_v<_U1, _T1>)
260 return is_convertible_v<_U2, _T2>;
268 constexpr explicit(!_S_convertible<const _T1&, const _T2&>())
269 pair(
const _T1& __x,
const _T2& __y)
270 noexcept(_S_nothrow_constructible<const _T1&, const _T2&>())
271 requires (_S_constructible<const _T1&, const _T2&>())
276 template<
typename _U1,
typename _U2>
277 requires (_S_constructible<_U1, _U2>())
278 constexpr explicit(!_S_convertible<_U1, _U2>())
279 pair(_U1&& __x, _U2&& __y)
280 noexcept(_S_nothrow_constructible<_U1, _U2>())
285 template<
typename _U1,
typename _U2>
286 requires (_S_constructible<const _U1&, const _U2&>())
287 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
288 pair(
const pair<_U1, _U2>& __p)
289 noexcept(_S_nothrow_constructible<const _U1&, const _U2&>())
294 template<
typename _U1,
typename _U2>
295 requires (_S_constructible<_U1, _U2>())
296 constexpr explicit(!_S_convertible<_U1, _U2>())
297 pair(pair<_U1, _U2>&& __p)
298 noexcept(_S_nothrow_constructible<_U1, _U2>())
305 template<
typename _U1,
typename _U2>
306 static constexpr bool
309 if constexpr (is_assignable_v<_T1&, _U1>)
310 return is_assignable_v<_T2&, _U2>;
314 template<
typename _U1,
typename _U2>
315 static constexpr bool
316 _S_nothrow_assignable()
318 if constexpr (is_nothrow_assignable_v<_T1&, _U1>)
319 return is_nothrow_assignable_v<_T2&, _U2>;
326 pair& operator=(
const pair&) =
delete;
330 operator=(
const pair& __p)
331 noexcept(_S_nothrow_assignable<const _T1&, const _T2&>())
332 requires (_S_assignable<const _T1&, const _T2&>())
341 operator=(
pair&& __p)
342 noexcept(_S_nothrow_assignable<_T1, _T2>())
343 requires (_S_assignable<_T1, _T2>())
345 first = std::forward<first_type>(__p.first);
346 second = std::forward<second_type>(__p.second);
351 template<
typename _U1,
typename _U2>
353 operator=(
const pair<_U1, _U2>& __p)
354 noexcept(_S_nothrow_assignable<const _U1&, const _U2&>())
355 requires (_S_assignable<const _U1&, const _U2&>())
363 template<
typename _U1,
typename _U2>
365 operator=(pair<_U1, _U2>&& __p)
366 noexcept(_S_nothrow_assignable<_U1, _U2>())
367 requires (_S_assignable<_U1, _U2>())
369 first = std::forward<_U1>(__p.first);
370 second = std::forward<_U2>(__p.second);
378 template <
typename _U1 = _T1,
380 typename enable_if<__and_<
381 __is_implicitly_default_constructible<_U1>,
382 __is_implicitly_default_constructible<_U2>>
383 ::value,
bool>::type =
true>
387 template <
typename _U1 = _T1,
393 __and_<__is_implicitly_default_constructible<_U1>,
394 __is_implicitly_default_constructible<_U2>>>>
395 ::value,
bool>::type =
false>
396 explicit constexpr pair()
401 using _PCCP = _PCC<true, _T1, _T2>;
405 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
406 enable_if<_PCCP::template
407 _ConstructiblePair<_U1, _U2>()
409 _ImplicitlyConvertiblePair<_U1, _U2>(),
411 constexpr pair(
const _T1& __a,
const _T2& __b)
415 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
417 _ConstructiblePair<_U1, _U2>()
419 _ImplicitlyConvertiblePair<_U1, _U2>(),
421 explicit constexpr pair(
const _T1& __a,
const _T2& __b)
426 template <
typename _U1,
typename _U2>
427 using _PCCFP = _PCC<!is_same<_T1, _U1>::value
432 template<
typename _U1,
typename _U2,
typename
434 _ConstructiblePair<_U1, _U2>()
435 && _PCCFP<_U1, _U2>::template
436 _ImplicitlyConvertiblePair<_U1, _U2>(),
441 template<
typename _U1,
typename _U2,
typename
442 enable_if<_PCCFP<_U1, _U2>::template
443 _ConstructiblePair<_U1, _U2>()
444 && !_PCCFP<_U1, _U2>::template
445 _ImplicitlyConvertiblePair<_U1, _U2>(),
447 explicit constexpr pair(
const pair<_U1, _U2>& __p)
450#if _GLIBCXX_USE_DEPRECATED
451#if defined(__DEPRECATED)
452# define _GLIBCXX_DEPRECATED_PAIR_CTOR \
453 __attribute__ ((__deprecated__ ("use 'nullptr' instead of '0' to " \
454 "initialize std::pair of move-only " \
455 "type and pointer")))
457# define _GLIBCXX_DEPRECATED_PAIR_CTOR
464 struct __zero_as_null_pointer_constant
466 __zero_as_null_pointer_constant(
int __zero_as_null_pointer_constant::*)
468 template<
typename _Tp,
469 typename = __enable_if_t<is_null_pointer<_Tp>::value>>
470 __zero_as_null_pointer_constant(_Tp) =
delete;
478 template<
typename _U1,
479 __enable_if_t<__and_<__not_<is_reference<_U1>>,
481 is_constructible<_T1, _U1>,
482 __not_<is_constructible<_T1, const _U1&>>,
483 is_convertible<_U1, _T1>>::value,
485 _GLIBCXX_DEPRECATED_PAIR_CTOR
487 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
490 template<
typename _U1,
491 __enable_if_t<__and_<__not_<is_reference<_U1>>,
493 is_constructible<_T1, _U1>,
494 __not_<is_constructible<_T1, const _U1&>>,
495 __not_<is_convertible<_U1, _T1>>>::value,
497 _GLIBCXX_DEPRECATED_PAIR_CTOR
499 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
502 template<
typename _U2,
503 __enable_if_t<__and_<is_pointer<_T1>,
504 __not_<is_reference<_U2>>,
505 is_constructible<_T2, _U2>,
506 __not_<is_constructible<_T2, const _U2&>>,
507 is_convertible<_U2, _T2>>::value,
509 _GLIBCXX_DEPRECATED_PAIR_CTOR
511 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
514 template<
typename _U2,
515 __enable_if_t<__and_<is_pointer<_T1>,
516 __not_<is_reference<_U2>>,
517 is_constructible<_T2, _U2>,
518 __not_<is_constructible<_T2, const _U2&>>,
519 __not_<is_convertible<_U2, _T2>>>::value,
521 _GLIBCXX_DEPRECATED_PAIR_CTOR
523 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
525#undef _GLIBCXX_DEPRECATED_PAIR_CTOR
528 template<
typename _U1,
typename _U2,
typename
529 enable_if<_PCCP::template
530 _MoveConstructiblePair<_U1, _U2>()
532 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
534 constexpr pair(_U1&& __x, _U2&& __y)
537 template<
typename _U1,
typename _U2,
typename
538 enable_if<_PCCP::template
539 _MoveConstructiblePair<_U1, _U2>()
541 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
543 explicit constexpr pair(_U1&& __x, _U2&& __y)
547 template<
typename _U1,
typename _U2,
typename
548 enable_if<_PCCFP<_U1, _U2>::template
549 _MoveConstructiblePair<_U1, _U2>()
550 && _PCCFP<_U1, _U2>::template
551 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
553 constexpr pair(pair<_U1, _U2>&& __p)
557 template<
typename _U1,
typename _U2,
typename
558 enable_if<_PCCFP<_U1, _U2>::template
559 _MoveConstructiblePair<_U1, _U2>()
560 && !_PCCFP<_U1, _U2>::template
561 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
563 explicit constexpr pair(pair<_U1, _U2>&& __p)
568 operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
569 is_copy_assignable<_T2>>::value,
570 const pair&,
const __nonesuch&> __p)
578 operator=(__conditional_t<__and_<is_move_assignable<_T1>,
579 is_move_assignable<_T2>>::value,
580 pair&&, __nonesuch&&> __p)
581 noexcept(__and_<is_nothrow_move_assignable<_T1>,
582 is_nothrow_move_assignable<_T2>>::value)
584 first = std::forward<first_type>(__p.first);
585 second = std::forward<second_type>(__p.second);
589 template<
typename _U1,
typename _U2>
590 typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
591 is_assignable<_T2&, const _U2&>>::value,
593 operator=(
const pair<_U1, _U2>& __p)
600 template<
typename _U1,
typename _U2>
601 typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
602 is_assignable<_T2&, _U2&&>>::value,
604 operator=(pair<_U1, _U2>&& __p)
606 first = std::forward<_U1>(__p.first);
607 second = std::forward<_U2>(__p.second);
621 pair(
const _T1& __a,
const _T2& __b)
625 template<
typename _U1,
typename _U2>
626 pair(
const pair<_U1, _U2>& __p)
633#if __cpp_deduction_guides >= 201606
638 template<
typename _T1,
typename _T2>
639 inline _GLIBCXX_CONSTEXPR
bool
643#if __cpp_lib_three_way_comparison && __cpp_lib_concepts
644 template<
typename _T1,
typename _T2>
645 constexpr common_comparison_category_t<__detail::__synth3way_t<_T1>,
646 __detail::__synth3way_t<_T2>>
649 if (
auto __c = __detail::__synth3way(__x.
first, __y.
first); __c != 0)
661 template<
typename _T1,
typename _T2>
662 inline _GLIBCXX_CONSTEXPR
bool
668 template<
typename _T1,
typename _T2>
669 inline _GLIBCXX_CONSTEXPR
bool
671 {
return !(__x == __y); }
674 template<
typename _T1,
typename _T2>
675 inline _GLIBCXX_CONSTEXPR
bool
677 {
return __y < __x; }
680 template<
typename _T1,
typename _T2>
681 inline _GLIBCXX_CONSTEXPR
bool
683 {
return !(__y < __x); }
686 template<
typename _T1,
typename _T2>
687 inline _GLIBCXX_CONSTEXPR
bool
689 {
return !(__x < __y); }
692#if __cplusplus >= 201103L
698 template<
typename _T1,
typename _T2>
699 _GLIBCXX20_CONSTEXPR
inline
700#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
703 __is_swappable<_T2>>::value>::type
708 noexcept(
noexcept(__x.
swap(__y)))
711#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
712 template<
typename _T1,
typename _T2>
714 __is_swappable<_T2>>::value>::type
736#if __cplusplus >= 201103L
738 template<
typename _T1,
typename _T2>
740 typename __decay_and_strip<_T2>::__type>
743 typedef typename __decay_and_strip<_T1>::__type __ds_type1;
744 typedef typename __decay_and_strip<_T2>::__type __ds_type2;
746 return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
749 template<
typename _T1,
typename _T2>
751 make_pair(_T1 __x, _T2 __y)
757#if __cplusplus >= 201103L
760 template<
typename _T1,
typename _T2>
761 struct __is_tuple_like_impl<pair<_T1, _T2>> :
true_type
765 template<
class _Tp1,
class _Tp2>
770 template<
class _Tp1,
class _Tp2>
772 {
typedef _Tp1 type; };
775 template<
class _Tp1,
class _Tp2>
777 {
typedef _Tp2 type; };
779#if __cplusplus >= 201703L
780 template<
typename _Tp1,
typename _Tp2>
781 inline constexpr size_t tuple_size_v<pair<_Tp1, _Tp2>> = 2;
783 template<
typename _Tp1,
typename _Tp2>
784 inline constexpr size_t tuple_size_v<const pair<_Tp1, _Tp2>> = 2;
786 template<
typename _Tp>
787 inline constexpr bool __is_pair =
false;
789 template<
typename _Tp,
typename _Up>
790 inline constexpr bool __is_pair<pair<_Tp, _Up>> =
true;
792 template<
typename _Tp,
typename _Up>
793 inline constexpr bool __is_pair<const pair<_Tp, _Up>> =
true;
797 template<
size_t _Int>
803 template<
typename _Tp1,
typename _Tp2>
804 static constexpr _Tp1&
806 {
return __pair.first; }
808 template<
typename _Tp1,
typename _Tp2>
809 static constexpr _Tp1&&
810 __move_get(pair<_Tp1, _Tp2>&& __pair)
noexcept
811 {
return std::forward<_Tp1>(__pair.first); }
813 template<
typename _Tp1,
typename _Tp2>
814 static constexpr const _Tp1&
815 __const_get(
const pair<_Tp1, _Tp2>& __pair)
noexcept
816 {
return __pair.first; }
818 template<
typename _Tp1,
typename _Tp2>
819 static constexpr const _Tp1&&
820 __const_move_get(
const pair<_Tp1, _Tp2>&& __pair)
noexcept
821 {
return std::forward<const _Tp1>(__pair.first); }
827 template<
typename _Tp1,
typename _Tp2>
828 static constexpr _Tp2&
829 __get(pair<_Tp1, _Tp2>& __pair)
noexcept
830 {
return __pair.second; }
832 template<
typename _Tp1,
typename _Tp2>
833 static constexpr _Tp2&&
834 __move_get(pair<_Tp1, _Tp2>&& __pair)
noexcept
835 {
return std::forward<_Tp2>(__pair.second); }
837 template<
typename _Tp1,
typename _Tp2>
838 static constexpr const _Tp2&
839 __const_get(
const pair<_Tp1, _Tp2>& __pair)
noexcept
840 {
return __pair.second; }
842 template<
typename _Tp1,
typename _Tp2>
843 static constexpr const _Tp2&&
844 __const_move_get(
const pair<_Tp1, _Tp2>&& __pair)
noexcept
845 {
return std::forward<const _Tp2>(__pair.second); }
853 template<
size_t _Int,
class _Tp1,
class _Tp2>
854 constexpr typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&
856 {
return __pair_get<_Int>::__get(__in); }
858 template<
size_t _Int,
class _Tp1,
class _Tp2>
859 constexpr typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&&
861 {
return __pair_get<_Int>::__move_get(
std::move(__in)); }
863 template<
size_t _Int,
class _Tp1,
class _Tp2>
864 constexpr const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&
866 {
return __pair_get<_Int>::__const_get(__in); }
868 template<
size_t _Int,
class _Tp1,
class _Tp2>
869 constexpr const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&&
871 {
return __pair_get<_Int>::__const_move_get(
std::move(__in)); }
873#if __cplusplus >= 201402L
875#define __cpp_lib_tuples_by_type 201304L
877 template <
typename _Tp,
typename _Up>
880 {
return __p.first; }
882 template <
typename _Tp,
typename _Up>
885 {
return __p.first; }
887 template <
typename _Tp,
typename _Up>
892 template <
typename _Tp,
typename _Up>
893 constexpr const _Tp&&
897 template <
typename _Tp,
typename _Up>
900 {
return __p.second; }
902 template <
typename _Tp,
typename _Up>
905 {
return __p.second; }
907 template <
typename _Tp,
typename _Up>
912 template <
typename _Tp,
typename _Up>
913 constexpr const _Tp&&
921_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 std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
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 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.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
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.