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
469 struct __null_ptr_constant
471 __null_ptr_constant(
int __null_ptr_constant::*) { }
472 template<
typename _Tp,
473 typename = __enable_if_t<is_null_pointer<_Tp>::value>>
474 __null_ptr_constant(_Tp) =
delete;
478 template<
typename _Up,
typename _Tp>
480 = __or_<is_same<_Up, const _Tp&>, is_same<_Up, _Tp&>>;
486 template<
typename _U1,
487 __enable_if_t<!__is_lvalue_of<_U1, _T1>::value
489 _DeprConsPair<true, _U1, nullptr_t>(),
491 _GLIBCXX_DEPRECATED_SUGGEST(
"nullptr")
492 constexpr
pair(_U1&& __x, __null_ptr_constant)
495 template<
typename _U1,
496 __enable_if_t<!__is_lvalue_of<_U1, _T1>::value
498 _DeprConsPair<false, _U1, nullptr_t>(),
500 _GLIBCXX_DEPRECATED_SUGGEST(
"nullptr")
501 explicit constexpr
pair(_U1&& __x, __null_ptr_constant)
504 template<
typename _U2,
505 __enable_if_t<!__is_lvalue_of<_U2, _T2>::value
507 _DeprConsPair<true, nullptr_t, _U2>(),
509 _GLIBCXX_DEPRECATED_SUGGEST(
"nullptr")
510 constexpr
pair(__null_ptr_constant, _U2&& __y)
513 template<
typename _U2,
514 __enable_if_t<!__is_lvalue_of<_U2, _T2>::value
516 _DeprConsPair<false, nullptr_t, _U2>(),
518 _GLIBCXX_DEPRECATED_SUGGEST(
"nullptr")
519 explicit
pair(__null_ptr_constant, _U2&& __y)
523 template<
typename _U1,
typename _U2,
typename
524 enable_if<_PCCP::template
525 _MoveConstructiblePair<_U1, _U2>()
527 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
529 constexpr
pair(_U1&& __x, _U2&& __y)
532 template<
typename _U1,
typename _U2,
typename
533 enable_if<_PCCP::template
534 _MoveConstructiblePair<_U1, _U2>()
536 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
538 explicit constexpr
pair(_U1&& __x, _U2&& __y)
542 template<
typename _U1,
typename _U2,
typename
543 enable_if<_PCCFP<_U1, _U2>::template
544 _MoveConstructiblePair<_U1, _U2>()
545 && _PCCFP<_U1, _U2>::template
546 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
548 constexpr
pair(pair<_U1, _U2>&& __p)
552 template<
typename _U1,
typename _U2,
typename
553 enable_if<_PCCFP<_U1, _U2>::template
554 _MoveConstructiblePair<_U1, _U2>()
555 && !_PCCFP<_U1, _U2>::template
556 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
558 explicit constexpr
pair(pair<_U1, _U2>&& __p)
563 operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
564 is_copy_assignable<_T2>>::value,
565 const pair&,
const __nonesuch&> __p)
573 operator=(__conditional_t<__and_<is_move_assignable<_T1>,
574 is_move_assignable<_T2>>::value,
575 pair&&, __nonesuch&&> __p)
576 noexcept(__and_<is_nothrow_move_assignable<_T1>,
577 is_nothrow_move_assignable<_T2>>::value)
579 first = std::forward<first_type>(__p.first);
580 second = std::forward<second_type>(__p.second);
584 template<
typename _U1,
typename _U2>
585 typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
586 is_assignable<_T2&, const _U2&>>::value,
588 operator=(
const pair<_U1, _U2>& __p)
595 template<
typename _U1,
typename _U2>
596 typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
597 is_assignable<_T2&, _U2&&>>::value,
599 operator=(pair<_U1, _U2>&& __p)
601 first = std::forward<_U1>(__p.first);
602 second = std::forward<_U2>(__p.second);
616 pair(
const _T1& __a,
const _T2& __b)
620 template<
typename _U1,
typename _U2>
621 pair(
const pair<_U1, _U2>& __p)
628 #if __cpp_deduction_guides >= 201606
633 template<
typename _T1,
typename _T2>
634 inline _GLIBCXX_CONSTEXPR
bool
638 #if __cpp_lib_three_way_comparison && __cpp_lib_concepts
639 template<
typename _T1,
typename _T2>
640 constexpr common_comparison_category_t<__detail::__synth3way_t<_T1>,
641 __detail::__synth3way_t<_T2>>
644 if (
auto __c = __detail::__synth3way(__x.
first, __y.
first); __c != 0)
656 template<
typename _T1,
typename _T2>
657 inline _GLIBCXX_CONSTEXPR
bool
663 template<
typename _T1,
typename _T2>
664 inline _GLIBCXX_CONSTEXPR
bool
666 {
return !(__x == __y); }
669 template<
typename _T1,
typename _T2>
670 inline _GLIBCXX_CONSTEXPR
bool
672 {
return __y < __x; }
675 template<
typename _T1,
typename _T2>
676 inline _GLIBCXX_CONSTEXPR
bool
678 {
return !(__y < __x); }
681 template<
typename _T1,
typename _T2>
682 inline _GLIBCXX_CONSTEXPR
bool
684 {
return !(__x < __y); }
687 #if __cplusplus >= 201103L
693 template<
typename _T1,
typename _T2>
694 _GLIBCXX20_CONSTEXPR
inline
695 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
698 __is_swappable<_T2>>::value>::type
703 noexcept(noexcept(__x.
swap(__y)))
706 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
707 template<
typename _T1,
typename _T2>
709 __is_swappable<_T2>>::value>::type
731 #if __cplusplus >= 201103L
733 template<
typename _T1,
typename _T2>
735 typename __decay_and_strip<_T2>::__type>
738 typedef typename __decay_and_strip<_T1>::__type __ds_type1;
739 typedef typename __decay_and_strip<_T2>::__type __ds_type2;
741 return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
744 template<
typename _T1,
typename _T2>
746 make_pair(_T1 __x, _T2 __y)
752 #if __cplusplus >= 201103L
755 template<
typename _T1,
typename _T2>
756 struct __is_tuple_like_impl<pair<_T1, _T2>> :
true_type
760 template<
class _Tp1,
class _Tp2>
765 template<
class _Tp1,
class _Tp2>
767 {
typedef _Tp1 type; };
770 template<
class _Tp1,
class _Tp2>
772 {
typedef _Tp2 type; };
774 #if __cplusplus >= 201703L
775 template<
typename _Tp1,
typename _Tp2>
776 inline constexpr
size_t tuple_size_v<pair<_Tp1, _Tp2>> = 2;
778 template<
typename _Tp1,
typename _Tp2>
779 inline constexpr
size_t tuple_size_v<const pair<_Tp1, _Tp2>> = 2;
783 template<
size_t _Int>
789 template<
typename _Tp1,
typename _Tp2>
790 static constexpr _Tp1&
792 {
return __pair.first; }
794 template<
typename _Tp1,
typename _Tp2>
795 static constexpr _Tp1&&
796 __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept
797 {
return std::forward<_Tp1>(__pair.first); }
799 template<
typename _Tp1,
typename _Tp2>
800 static constexpr
const _Tp1&
801 __const_get(
const pair<_Tp1, _Tp2>& __pair) noexcept
802 {
return __pair.first; }
804 template<
typename _Tp1,
typename _Tp2>
805 static constexpr
const _Tp1&&
806 __const_move_get(
const pair<_Tp1, _Tp2>&& __pair) noexcept
807 {
return std::forward<const _Tp1>(__pair.first); }
813 template<
typename _Tp1,
typename _Tp2>
814 static constexpr _Tp2&
815 __get(pair<_Tp1, _Tp2>& __pair) noexcept
816 {
return __pair.second; }
818 template<
typename _Tp1,
typename _Tp2>
819 static constexpr _Tp2&&
820 __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept
821 {
return std::forward<_Tp2>(__pair.second); }
823 template<
typename _Tp1,
typename _Tp2>
824 static constexpr
const _Tp2&
825 __const_get(
const pair<_Tp1, _Tp2>& __pair) noexcept
826 {
return __pair.second; }
828 template<
typename _Tp1,
typename _Tp2>
829 static constexpr
const _Tp2&&
830 __const_move_get(
const pair<_Tp1, _Tp2>&& __pair) noexcept
831 {
return std::forward<const _Tp2>(__pair.second); }
839 template<
size_t _Int,
class _Tp1,
class _Tp2>
840 constexpr
typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&
842 {
return __pair_get<_Int>::__get(__in); }
844 template<
size_t _Int,
class _Tp1,
class _Tp2>
845 constexpr
typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&&
847 {
return __pair_get<_Int>::__move_get(
std::move(__in)); }
849 template<
size_t _Int,
class _Tp1,
class _Tp2>
850 constexpr
const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&
852 {
return __pair_get<_Int>::__const_get(__in); }
854 template<
size_t _Int,
class _Tp1,
class _Tp2>
855 constexpr
const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&&
857 {
return __pair_get<_Int>::__const_move_get(
std::move(__in)); }
859 #if __cplusplus >= 201402L
861 #define __cpp_lib_tuples_by_type 201304L
863 template <
typename _Tp,
typename _Up>
866 {
return __p.first; }
868 template <
typename _Tp,
typename _Up>
871 {
return __p.first; }
873 template <
typename _Tp,
typename _Up>
878 template <
typename _Tp,
typename _Up>
879 constexpr
const _Tp&&
883 template <
typename _Tp,
typename _Up>
886 {
return __p.second; }
888 template <
typename _Tp,
typename _Up>
891 {
return __p.second; }
893 template <
typename _Tp,
typename _Up>
898 template <
typename _Tp,
typename _Up>
899 constexpr
const _Tp&&
907 _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.