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;
186 template<
typename _T1,
typename _T2>
188 :
public __pair_base<_T1, _T2>
196#if __cplusplus >= 201103L
200 template<
typename... _Args1,
typename... _Args2>
205 _GLIBCXX20_CONSTEXPR
void
207 noexcept(__and_<__is_nothrow_swappable<_T1>,
208 __is_nothrow_swappable<_T2>>::value)
216 template<
typename... _Args1,
size_t... _Indexes1,
217 typename... _Args2,
size_t... _Indexes2>
220 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
223#if __cpp_lib_concepts
228 explicit(__not_<__and_<__is_implicitly_default_constructible<_T1>,
229 __is_implicitly_default_constructible<_T2>>>())
231 requires is_default_constructible_v<_T1>
232 && is_default_constructible_v<_T2>
239 template<
typename _U1,
typename _U2>
240 static constexpr bool
243 if constexpr (is_constructible_v<_T1, _U1>)
244 return is_constructible_v<_T2, _U2>;
248 template<
typename _U1,
typename _U2>
249 static constexpr bool
250 _S_nothrow_constructible()
252 if constexpr (is_nothrow_constructible_v<_T1, _U1>)
253 return is_nothrow_constructible_v<_T2, _U2>;
257 template<
typename _U1,
typename _U2>
258 static constexpr bool
261 if constexpr (is_convertible_v<_U1, _T1>)
262 return is_convertible_v<_U2, _T2>;
270 constexpr explicit(!_S_convertible<const _T1&, const _T2&>())
271 pair(
const _T1& __x,
const _T2& __y)
272 noexcept(_S_nothrow_constructible<const _T1&, const _T2&>())
273 requires (_S_constructible<const _T1&, const _T2&>())
278 template<
typename _U1,
typename _U2>
279 requires (_S_constructible<_U1, _U2>())
280 constexpr explicit(!_S_convertible<_U1, _U2>())
281 pair(_U1&& __x, _U2&& __y)
282 noexcept(_S_nothrow_constructible<_U1, _U2>())
283 :
first(std::forward<_U1>(__x)),
second(std::forward<_U2>(__y))
287 template<
typename _U1,
typename _U2>
288 requires (_S_constructible<const _U1&, const _U2&>())
289 constexpr explicit(!_S_convertible<const _U1&, const _U2&>())
290 pair(
const pair<_U1, _U2>& __p)
291 noexcept(_S_nothrow_constructible<const _U1&, const _U2&>())
296 template<
typename _U1,
typename _U2>
297 requires (_S_constructible<_U1, _U2>())
298 constexpr explicit(!_S_convertible<_U1, _U2>())
299 pair(pair<_U1, _U2>&& __p)
300 noexcept(_S_nothrow_constructible<_U1, _U2>())
301 :
first(std::forward<_U1>(__p.first)),
302 second(std::forward<_U2>(__p.second))
307 template<
typename _U1,
typename _U2>
308 static constexpr bool
311 if constexpr (is_assignable_v<_T1&, _U1>)
312 return is_assignable_v<_T2&, _U2>;
316 template<
typename _U1,
typename _U2>
317 static constexpr bool
318 _S_nothrow_assignable()
320 if constexpr (is_nothrow_assignable_v<_T1&, _U1>)
321 return is_nothrow_assignable_v<_T2&, _U2>;
328 pair& operator=(
const pair&) =
delete;
332 operator=(
const pair& __p)
333 noexcept(_S_nothrow_assignable<const _T1&, const _T2&>())
334 requires (_S_assignable<const _T1&, const _T2&>())
343 operator=(
pair&& __p)
344 noexcept(_S_nothrow_assignable<_T1, _T2>())
345 requires (_S_assignable<_T1, _T2>())
347 first = std::forward<first_type>(__p.first);
348 second = std::forward<second_type>(__p.second);
353 template<
typename _U1,
typename _U2>
355 operator=(
const pair<_U1, _U2>& __p)
356 noexcept(_S_nothrow_assignable<const _U1&, const _U2&>())
357 requires (_S_assignable<const _U1&, const _U2&>())
365 template<
typename _U1,
typename _U2>
367 operator=(pair<_U1, _U2>&& __p)
368 noexcept(_S_nothrow_assignable<_U1, _U2>())
369 requires (_S_assignable<_U1, _U2>())
371 first = std::forward<_U1>(__p.first);
372 second = std::forward<_U2>(__p.second);
380 template <
typename _U1 = _T1,
382 typename enable_if<__and_<
383 __is_implicitly_default_constructible<_U1>,
384 __is_implicitly_default_constructible<_U2>>
385 ::value,
bool>::type =
true>
389 template <
typename _U1 = _T1,
395 __and_<__is_implicitly_default_constructible<_U1>,
396 __is_implicitly_default_constructible<_U2>>>>
397 ::value,
bool>::type =
false>
398 explicit constexpr pair()
403 using _PCCP = _PCC<true, _T1, _T2>;
407 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
408 enable_if<_PCCP::template
409 _ConstructiblePair<_U1, _U2>()
411 _ImplicitlyConvertiblePair<_U1, _U2>(),
413 constexpr pair(
const _T1& __a,
const _T2& __b)
417 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
419 _ConstructiblePair<_U1, _U2>()
421 _ImplicitlyConvertiblePair<_U1, _U2>(),
423 explicit constexpr pair(
const _T1& __a,
const _T2& __b)
428 template <
typename _U1,
typename _U2>
429 using _PCCFP = _PCC<!is_same<_T1, _U1>::value
434 template<
typename _U1,
typename _U2,
typename
436 _ConstructiblePair<_U1, _U2>()
437 && _PCCFP<_U1, _U2>::template
438 _ImplicitlyConvertiblePair<_U1, _U2>(),
443 template<
typename _U1,
typename _U2,
typename
444 enable_if<_PCCFP<_U1, _U2>::template
445 _ConstructiblePair<_U1, _U2>()
446 && !_PCCFP<_U1, _U2>::template
447 _ImplicitlyConvertiblePair<_U1, _U2>(),
449 explicit constexpr pair(
const pair<_U1, _U2>& __p)
452#if _GLIBCXX_USE_DEPRECATED
453#if defined(__DEPRECATED)
454# define _GLIBCXX_DEPRECATED_PAIR_CTOR \
455 __attribute__ ((__deprecated__ ("use 'nullptr' instead of '0' to " \
456 "initialize std::pair of move-only " \
457 "type and pointer")))
459# define _GLIBCXX_DEPRECATED_PAIR_CTOR
466 struct __zero_as_null_pointer_constant
468 __zero_as_null_pointer_constant(
int __zero_as_null_pointer_constant::*)
470 template<
typename _Tp,
471 typename = __enable_if_t<is_null_pointer<_Tp>::value>>
472 __zero_as_null_pointer_constant(_Tp) =
delete;
480 template<
typename _U1,
481 __enable_if_t<__and_<__not_<is_reference<_U1>>,
483 is_constructible<_T1, _U1>,
484 __not_<is_constructible<_T1, const _U1&>>,
485 is_convertible<_U1, _T1>>::value,
487 _GLIBCXX_DEPRECATED_PAIR_CTOR
489 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
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 __not_<is_convertible<_U1, _T1>>>::value,
499 _GLIBCXX_DEPRECATED_PAIR_CTOR
501 pair(_U1&& __x, __zero_as_null_pointer_constant, ...)
504 template<
typename _U2,
505 __enable_if_t<__and_<is_pointer<_T1>,
506 __not_<is_reference<_U2>>,
507 is_constructible<_T2, _U2>,
508 __not_<is_constructible<_T2, const _U2&>>,
509 is_convertible<_U2, _T2>>::value,
511 _GLIBCXX_DEPRECATED_PAIR_CTOR
513 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
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 __not_<is_convertible<_U2, _T2>>>::value,
523 _GLIBCXX_DEPRECATED_PAIR_CTOR
525 pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
527#undef _GLIBCXX_DEPRECATED_PAIR_CTOR
530 template<
typename _U1,
typename _U2,
typename
531 enable_if<_PCCP::template
532 _MoveConstructiblePair<_U1, _U2>()
534 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
536 constexpr pair(_U1&& __x, _U2&& __y)
539 template<
typename _U1,
typename _U2,
typename
540 enable_if<_PCCP::template
541 _MoveConstructiblePair<_U1, _U2>()
543 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
545 explicit constexpr pair(_U1&& __x, _U2&& __y)
549 template<
typename _U1,
typename _U2,
typename
550 enable_if<_PCCFP<_U1, _U2>::template
551 _MoveConstructiblePair<_U1, _U2>()
552 && _PCCFP<_U1, _U2>::template
553 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
555 constexpr pair(pair<_U1, _U2>&& __p)
559 template<
typename _U1,
typename _U2,
typename
560 enable_if<_PCCFP<_U1, _U2>::template
561 _MoveConstructiblePair<_U1, _U2>()
562 && !_PCCFP<_U1, _U2>::template
563 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
565 explicit constexpr pair(pair<_U1, _U2>&& __p)
570 operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
571 is_copy_assignable<_T2>>::value,
572 const pair&,
const __nonesuch&> __p)
580 operator=(__conditional_t<__and_<is_move_assignable<_T1>,
581 is_move_assignable<_T2>>::value,
582 pair&&, __nonesuch&&> __p)
583 noexcept(__and_<is_nothrow_move_assignable<_T1>,
584 is_nothrow_move_assignable<_T2>>::value)
586 first = std::forward<first_type>(__p.first);
587 second = std::forward<second_type>(__p.second);
591 template<
typename _U1,
typename _U2>
592 typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
593 is_assignable<_T2&, const _U2&>>::value,
595 operator=(
const pair<_U1, _U2>& __p)
602 template<
typename _U1,
typename _U2>
603 typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
604 is_assignable<_T2&, _U2&&>>::value,
606 operator=(pair<_U1, _U2>&& __p)
608 first = std::forward<_U1>(__p.first);
609 second = std::forward<_U2>(__p.second);
623 pair(
const _T1& __a,
const _T2& __b)
627 template<
typename _U1,
typename _U2>
628 pair(
const pair<_U1, _U2>& __p)
635#if __cpp_deduction_guides >= 201606
640 template<
typename _T1,
typename _T2>
641 inline _GLIBCXX_CONSTEXPR
bool
643 {
return __x.
first == __y.first && __x.
second == __y.second; }
645#if __cpp_lib_three_way_comparison && __cpp_lib_concepts
646 template<
typename _T1,
typename _T2>
647 constexpr common_comparison_category_t<__detail::__synth3way_t<_T1>,
648 __detail::__synth3way_t<_T2>>
651 if (
auto __c = __detail::__synth3way(__x.
first, __y.first); __c != 0)
653 return __detail::__synth3way(__x.
second, __y.second);
663 template<
typename _T1,
typename _T2>
664 inline _GLIBCXX_CONSTEXPR
bool
666 {
return __x.
first < __y.first
667 || (!(__y.first < __x.
first) && __x.
second < __y.second); }
670 template<
typename _T1,
typename _T2>
671 inline _GLIBCXX_CONSTEXPR
bool
673 {
return !(__x == __y); }
676 template<
typename _T1,
typename _T2>
677 inline _GLIBCXX_CONSTEXPR
bool
679 {
return __y < __x; }
682 template<
typename _T1,
typename _T2>
683 inline _GLIBCXX_CONSTEXPR
bool
685 {
return !(__y < __x); }
688 template<
typename _T1,
typename _T2>
689 inline _GLIBCXX_CONSTEXPR
bool
691 {
return !(__x < __y); }
694#if __cplusplus >= 201103L
700 template<
typename _T1,
typename _T2>
701 _GLIBCXX20_CONSTEXPR
inline
702#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
705 __is_swappable<_T2>>::value>::type
710 noexcept(
noexcept(__x.
swap(__y)))
713#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
714 template<
typename _T1,
typename _T2>
716 __is_swappable<_T2>>::value>::type
738#if __cplusplus >= 201103L
740 template<
typename _T1,
typename _T2>
742 typename __decay_and_strip<_T2>::__type>
745 typedef typename __decay_and_strip<_T1>::__type __ds_type1;
746 typedef typename __decay_and_strip<_T2>::__type __ds_type2;
748 return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
751 template<
typename _T1,
typename _T2>
753 make_pair(_T1 __x, _T2 __y)
759#if __cplusplus >= 201103L
763 template<
typename _T1,
typename _T2>
764 struct __is_tuple_like_impl<pair<_T1, _T2>> :
true_type
769 template<
class _Tp1,
class _Tp2>
774 template<
class _Tp1,
class _Tp2>
776 {
typedef _Tp1 type; };
779 template<
class _Tp1,
class _Tp2>
781 {
typedef _Tp2 type; };
783#if __cplusplus >= 201703L
784 template<
typename _Tp1,
typename _Tp2>
785 inline constexpr size_t tuple_size_v<pair<_Tp1, _Tp2>> = 2;
787 template<
typename _Tp1,
typename _Tp2>
788 inline constexpr size_t tuple_size_v<const pair<_Tp1, _Tp2>> = 2;
790 template<
typename _Tp>
791 inline constexpr bool __is_pair =
false;
793 template<
typename _Tp,
typename _Up>
794 inline constexpr bool __is_pair<pair<_Tp, _Up>> =
true;
796 template<
typename _Tp,
typename _Up>
797 inline constexpr bool __is_pair<const pair<_Tp, _Up>> =
true;
801 template<
size_t _Int>
807 template<
typename _Tp1,
typename _Tp2>
808 static constexpr _Tp1&
810 {
return __pair.first; }
812 template<
typename _Tp1,
typename _Tp2>
813 static constexpr _Tp1&&
814 __move_get(pair<_Tp1, _Tp2>&& __pair)
noexcept
815 {
return std::forward<_Tp1>(__pair.first); }
817 template<
typename _Tp1,
typename _Tp2>
818 static constexpr const _Tp1&
819 __const_get(
const pair<_Tp1, _Tp2>& __pair)
noexcept
820 {
return __pair.first; }
822 template<
typename _Tp1,
typename _Tp2>
823 static constexpr const _Tp1&&
824 __const_move_get(
const pair<_Tp1, _Tp2>&& __pair)
noexcept
825 {
return std::forward<const _Tp1>(__pair.first); }
831 template<
typename _Tp1,
typename _Tp2>
832 static constexpr _Tp2&
833 __get(pair<_Tp1, _Tp2>& __pair)
noexcept
834 {
return __pair.second; }
836 template<
typename _Tp1,
typename _Tp2>
837 static constexpr _Tp2&&
838 __move_get(pair<_Tp1, _Tp2>&& __pair)
noexcept
839 {
return std::forward<_Tp2>(__pair.second); }
841 template<
typename _Tp1,
typename _Tp2>
842 static constexpr const _Tp2&
843 __const_get(
const pair<_Tp1, _Tp2>& __pair)
noexcept
844 {
return __pair.second; }
846 template<
typename _Tp1,
typename _Tp2>
847 static constexpr const _Tp2&&
848 __const_move_get(
const pair<_Tp1, _Tp2>&& __pair)
noexcept
849 {
return std::forward<const _Tp2>(__pair.second); }
857 template<
size_t _Int,
class _Tp1,
class _Tp2>
858 constexpr typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&
860 {
return __pair_get<_Int>::__get(__in); }
862 template<
size_t _Int,
class _Tp1,
class _Tp2>
863 constexpr typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&&
865 {
return __pair_get<_Int>::__move_get(
std::move(__in)); }
867 template<
size_t _Int,
class _Tp1,
class _Tp2>
868 constexpr const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&
870 {
return __pair_get<_Int>::__const_get(__in); }
872 template<
size_t _Int,
class _Tp1,
class _Tp2>
873 constexpr const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&&
875 {
return __pair_get<_Int>::__const_move_get(
std::move(__in)); }
877#if __cplusplus >= 201402L
879#define __cpp_lib_tuples_by_type 201304L
881 template <
typename _Tp,
typename _Up>
884 {
return __p.first; }
886 template <
typename _Tp,
typename _Up>
889 {
return __p.first; }
891 template <
typename _Tp,
typename _Up>
896 template <
typename _Tp,
typename _Up>
897 constexpr const _Tp&&
901 template <
typename _Tp,
typename _Up>
904 {
return __p.second; }
906 template <
typename _Tp,
typename _Up>
909 {
return __p.second; }
911 template <
typename _Tp,
typename _Up>
916 template <
typename _Tp,
typename _Up>
917 constexpr const _Tp&&
925_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.