1fe6060f1SDimitry Andric //===----------------------------------------------------------------------===// 2fe6060f1SDimitry Andric // 3fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6fe6060f1SDimitry Andric // 7fe6060f1SDimitry Andric //===----------------------------------------------------------------------===// 8fe6060f1SDimitry Andric 9fe6060f1SDimitry Andric #ifndef _LIBCPP___UTILITY_PAIR_H 10fe6060f1SDimitry Andric #define _LIBCPP___UTILITY_PAIR_H 11fe6060f1SDimitry Andric 12349cc55cSDimitry Andric #include <__compare/common_comparison_category.h> 13349cc55cSDimitry Andric #include <__compare/synth_three_way.h> 14fe6060f1SDimitry Andric #include <__config> 15fe6060f1SDimitry Andric #include <__functional/unwrap_ref.h> 16*bdd1243dSDimitry Andric #include <__fwd/get.h> 17*bdd1243dSDimitry Andric #include <__fwd/tuple.h> 18*bdd1243dSDimitry Andric #include <__tuple_dir/sfinae_helpers.h> 19*bdd1243dSDimitry Andric #include <__tuple_dir/tuple_element.h> 20*bdd1243dSDimitry Andric #include <__tuple_dir/tuple_indices.h> 21*bdd1243dSDimitry Andric #include <__tuple_dir/tuple_size.h> 22*bdd1243dSDimitry Andric #include <__type_traits/common_reference.h> 23*bdd1243dSDimitry Andric #include <__type_traits/common_type.h> 24*bdd1243dSDimitry Andric #include <__type_traits/conditional.h> 25*bdd1243dSDimitry Andric #include <__type_traits/is_assignable.h> 26*bdd1243dSDimitry Andric #include <__type_traits/is_constructible.h> 27*bdd1243dSDimitry Andric #include <__type_traits/is_convertible.h> 28*bdd1243dSDimitry Andric #include <__type_traits/is_copy_assignable.h> 29*bdd1243dSDimitry Andric #include <__type_traits/is_default_constructible.h> 30*bdd1243dSDimitry Andric #include <__type_traits/is_implicitly_default_constructible.h> 31*bdd1243dSDimitry Andric #include <__type_traits/is_move_assignable.h> 32*bdd1243dSDimitry Andric #include <__type_traits/is_nothrow_assignable.h> 33*bdd1243dSDimitry Andric #include <__type_traits/is_nothrow_constructible.h> 34*bdd1243dSDimitry Andric #include <__type_traits/is_nothrow_copy_assignable.h> 35*bdd1243dSDimitry Andric #include <__type_traits/is_nothrow_copy_constructible.h> 36*bdd1243dSDimitry Andric #include <__type_traits/is_nothrow_default_constructible.h> 37*bdd1243dSDimitry Andric #include <__type_traits/is_nothrow_move_assignable.h> 38*bdd1243dSDimitry Andric #include <__type_traits/is_same.h> 39*bdd1243dSDimitry Andric #include <__type_traits/is_swappable.h> 40*bdd1243dSDimitry Andric #include <__type_traits/nat.h> 41fe6060f1SDimitry Andric #include <__utility/forward.h> 42fe6060f1SDimitry Andric #include <__utility/move.h> 43fe6060f1SDimitry Andric #include <__utility/piecewise_construct.h> 44fe6060f1SDimitry Andric #include <cstddef> 45fe6060f1SDimitry Andric 46fe6060f1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 47fe6060f1SDimitry Andric # pragma GCC system_header 48fe6060f1SDimitry Andric #endif 49fe6060f1SDimitry Andric 50fe6060f1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD 51fe6060f1SDimitry Andric 52fe6060f1SDimitry Andric #if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) 53fe6060f1SDimitry Andric template <class, class> 54fe6060f1SDimitry Andric struct __non_trivially_copyable_base { 55fe6060f1SDimitry Andric _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 56fe6060f1SDimitry Andric __non_trivially_copyable_base() _NOEXCEPT {} 57*bdd1243dSDimitry Andric _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY 58fe6060f1SDimitry Andric __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {} 59fe6060f1SDimitry Andric }; 60fe6060f1SDimitry Andric #endif 61fe6060f1SDimitry Andric 62fe6060f1SDimitry Andric template <class _T1, class _T2> 63fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS pair 64fe6060f1SDimitry Andric #if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) 65fe6060f1SDimitry Andric : private __non_trivially_copyable_base<_T1, _T2> 66fe6060f1SDimitry Andric #endif 67fe6060f1SDimitry Andric { 68fe6060f1SDimitry Andric typedef _T1 first_type; 69fe6060f1SDimitry Andric typedef _T2 second_type; 70fe6060f1SDimitry Andric 71fe6060f1SDimitry Andric _T1 first; 72fe6060f1SDimitry Andric _T2 second; 73fe6060f1SDimitry Andric 74fe6060f1SDimitry Andric pair(pair const&) = default; 75fe6060f1SDimitry Andric pair(pair&&) = default; 76fe6060f1SDimitry Andric 77fe6060f1SDimitry Andric #ifdef _LIBCPP_CXX03_LANG 78fe6060f1SDimitry Andric _LIBCPP_INLINE_VISIBILITY 79fe6060f1SDimitry Andric pair() : first(), second() {} 80fe6060f1SDimitry Andric 81fe6060f1SDimitry Andric _LIBCPP_INLINE_VISIBILITY 82fe6060f1SDimitry Andric pair(_T1 const& __t1, _T2 const& __t2) : first(__t1), second(__t2) {} 83fe6060f1SDimitry Andric 84fe6060f1SDimitry Andric template <class _U1, class _U2> 85fe6060f1SDimitry Andric _LIBCPP_INLINE_VISIBILITY 86fe6060f1SDimitry Andric pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {} 87fe6060f1SDimitry Andric 88fe6060f1SDimitry Andric _LIBCPP_INLINE_VISIBILITY 89fe6060f1SDimitry Andric pair& operator=(pair const& __p) { 90fe6060f1SDimitry Andric first = __p.first; 91fe6060f1SDimitry Andric second = __p.second; 92fe6060f1SDimitry Andric return *this; 93fe6060f1SDimitry Andric } 94fe6060f1SDimitry Andric #else 95fe6060f1SDimitry Andric struct _CheckArgs { 96fe6060f1SDimitry Andric template <int&...> 97fe6060f1SDimitry Andric static constexpr bool __enable_explicit_default() { 98fe6060f1SDimitry Andric return is_default_constructible<_T1>::value 99fe6060f1SDimitry Andric && is_default_constructible<_T2>::value 100fe6060f1SDimitry Andric && !__enable_implicit_default<>(); 101fe6060f1SDimitry Andric } 102fe6060f1SDimitry Andric 103fe6060f1SDimitry Andric template <int&...> 104fe6060f1SDimitry Andric static constexpr bool __enable_implicit_default() { 105fe6060f1SDimitry Andric return __is_implicitly_default_constructible<_T1>::value 106fe6060f1SDimitry Andric && __is_implicitly_default_constructible<_T2>::value; 107fe6060f1SDimitry Andric } 108fe6060f1SDimitry Andric 109fe6060f1SDimitry Andric template <class _U1, class _U2> 110*bdd1243dSDimitry Andric static constexpr bool __is_pair_constructible() { 111fe6060f1SDimitry Andric return is_constructible<first_type, _U1>::value 112*bdd1243dSDimitry Andric && is_constructible<second_type, _U2>::value; 113*bdd1243dSDimitry Andric } 114*bdd1243dSDimitry Andric 115*bdd1243dSDimitry Andric template <class _U1, class _U2> 116*bdd1243dSDimitry Andric static constexpr bool __is_implicit() { 117*bdd1243dSDimitry Andric return is_convertible<_U1, first_type>::value 118*bdd1243dSDimitry Andric && is_convertible<_U2, second_type>::value; 119*bdd1243dSDimitry Andric } 120*bdd1243dSDimitry Andric 121*bdd1243dSDimitry Andric template <class _U1, class _U2> 122*bdd1243dSDimitry Andric static constexpr bool __enable_explicit() { 123*bdd1243dSDimitry Andric return __is_pair_constructible<_U1, _U2>() && !__is_implicit<_U1, _U2>(); 124fe6060f1SDimitry Andric } 125fe6060f1SDimitry Andric 126fe6060f1SDimitry Andric template <class _U1, class _U2> 127fe6060f1SDimitry Andric static constexpr bool __enable_implicit() { 128*bdd1243dSDimitry Andric return __is_pair_constructible<_U1, _U2>() && __is_implicit<_U1, _U2>(); 129fe6060f1SDimitry Andric } 130fe6060f1SDimitry Andric }; 131fe6060f1SDimitry Andric 132fe6060f1SDimitry Andric template <bool _MaybeEnable> 133349cc55cSDimitry Andric using _CheckArgsDep _LIBCPP_NODEBUG = typename conditional< 134fe6060f1SDimitry Andric _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type; 135fe6060f1SDimitry Andric 136fe6060f1SDimitry Andric struct _CheckTupleLikeConstructor { 137fe6060f1SDimitry Andric template <class _Tuple> 138fe6060f1SDimitry Andric static constexpr bool __enable_implicit() { 139fe6060f1SDimitry Andric return __tuple_convertible<_Tuple, pair>::value; 140fe6060f1SDimitry Andric } 141fe6060f1SDimitry Andric 142fe6060f1SDimitry Andric template <class _Tuple> 143fe6060f1SDimitry Andric static constexpr bool __enable_explicit() { 144fe6060f1SDimitry Andric return __tuple_constructible<_Tuple, pair>::value 145fe6060f1SDimitry Andric && !__tuple_convertible<_Tuple, pair>::value; 146fe6060f1SDimitry Andric } 147fe6060f1SDimitry Andric 148fe6060f1SDimitry Andric template <class _Tuple> 149fe6060f1SDimitry Andric static constexpr bool __enable_assign() { 150fe6060f1SDimitry Andric return __tuple_assignable<_Tuple, pair>::value; 151fe6060f1SDimitry Andric } 152fe6060f1SDimitry Andric }; 153fe6060f1SDimitry Andric 154fe6060f1SDimitry Andric template <class _Tuple> 155*bdd1243dSDimitry Andric using _CheckTLC _LIBCPP_NODEBUG = __conditional_t< 156fe6060f1SDimitry Andric __tuple_like_with_size<_Tuple, 2>::value 157fe6060f1SDimitry Andric && !is_same<typename decay<_Tuple>::type, pair>::value, 158fe6060f1SDimitry Andric _CheckTupleLikeConstructor, 159fe6060f1SDimitry Andric __check_tuple_constructor_fail 160*bdd1243dSDimitry Andric >; 161fe6060f1SDimitry Andric 162349cc55cSDimitry Andric template<bool _Dummy = true, typename enable_if< 163fe6060f1SDimitry Andric _CheckArgsDep<_Dummy>::__enable_explicit_default() 164349cc55cSDimitry Andric >::type* = nullptr> 165fe6060f1SDimitry Andric explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 166fe6060f1SDimitry Andric pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value && 167fe6060f1SDimitry Andric is_nothrow_default_constructible<second_type>::value) 168fe6060f1SDimitry Andric : first(), second() {} 169fe6060f1SDimitry Andric 170349cc55cSDimitry Andric template<bool _Dummy = true, typename enable_if< 171fe6060f1SDimitry Andric _CheckArgsDep<_Dummy>::__enable_implicit_default() 172349cc55cSDimitry Andric >::type* = nullptr> 173fe6060f1SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 174fe6060f1SDimitry Andric pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value && 175fe6060f1SDimitry Andric is_nothrow_default_constructible<second_type>::value) 176fe6060f1SDimitry Andric : first(), second() {} 177fe6060f1SDimitry Andric 178349cc55cSDimitry Andric template <bool _Dummy = true, typename enable_if< 179fe6060f1SDimitry Andric _CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>() 180349cc55cSDimitry Andric >::type* = nullptr> 181*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 182fe6060f1SDimitry Andric explicit pair(_T1 const& __t1, _T2 const& __t2) 183fe6060f1SDimitry Andric _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value && 184fe6060f1SDimitry Andric is_nothrow_copy_constructible<second_type>::value) 185fe6060f1SDimitry Andric : first(__t1), second(__t2) {} 186fe6060f1SDimitry Andric 187349cc55cSDimitry Andric template<bool _Dummy = true, typename enable_if< 188fe6060f1SDimitry Andric _CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>() 189349cc55cSDimitry Andric >::type* = nullptr> 190*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 191fe6060f1SDimitry Andric pair(_T1 const& __t1, _T2 const& __t2) 192fe6060f1SDimitry Andric _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value && 193fe6060f1SDimitry Andric is_nothrow_copy_constructible<second_type>::value) 194fe6060f1SDimitry Andric : first(__t1), second(__t2) {} 195fe6060f1SDimitry Andric 196349cc55cSDimitry Andric template < 197349cc55cSDimitry Andric #if _LIBCPP_STD_VER > 20 // http://wg21.link/P1951 198349cc55cSDimitry Andric class _U1 = _T1, class _U2 = _T2, 199349cc55cSDimitry Andric #else 200349cc55cSDimitry Andric class _U1, class _U2, 201349cc55cSDimitry Andric #endif 202349cc55cSDimitry Andric typename enable_if<_CheckArgs::template __enable_explicit<_U1, _U2>()>::type* = nullptr 203349cc55cSDimitry Andric > 204*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 205fe6060f1SDimitry Andric explicit pair(_U1&& __u1, _U2&& __u2) 206fe6060f1SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value && 207fe6060f1SDimitry Andric is_nothrow_constructible<second_type, _U2>::value)) 208fe6060f1SDimitry Andric : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {} 209fe6060f1SDimitry Andric 210349cc55cSDimitry Andric template < 211349cc55cSDimitry Andric #if _LIBCPP_STD_VER > 20 // http://wg21.link/P1951 212349cc55cSDimitry Andric class _U1 = _T1, class _U2 = _T2, 213349cc55cSDimitry Andric #else 214349cc55cSDimitry Andric class _U1, class _U2, 215349cc55cSDimitry Andric #endif 216349cc55cSDimitry Andric typename enable_if<_CheckArgs::template __enable_implicit<_U1, _U2>()>::type* = nullptr 217349cc55cSDimitry Andric > 218*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 219fe6060f1SDimitry Andric pair(_U1&& __u1, _U2&& __u2) 220fe6060f1SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value && 221fe6060f1SDimitry Andric is_nothrow_constructible<second_type, _U2>::value)) 222fe6060f1SDimitry Andric : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {} 223fe6060f1SDimitry Andric 224*bdd1243dSDimitry Andric #if _LIBCPP_STD_VER > 20 225*bdd1243dSDimitry Andric template<class _U1, class _U2, __enable_if_t< 226*bdd1243dSDimitry Andric _CheckArgs::template __is_pair_constructible<_U1&, _U2&>() 227*bdd1243dSDimitry Andric >* = nullptr> 228*bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr 229*bdd1243dSDimitry Andric explicit(!_CheckArgs::template __is_implicit<_U1&, _U2&>()) pair(pair<_U1, _U2>& __p) 230*bdd1243dSDimitry Andric noexcept((is_nothrow_constructible<first_type, _U1&>::value && 231*bdd1243dSDimitry Andric is_nothrow_constructible<second_type, _U2&>::value)) 232*bdd1243dSDimitry Andric : first(__p.first), second(__p.second) {} 233*bdd1243dSDimitry Andric #endif 234*bdd1243dSDimitry Andric 235349cc55cSDimitry Andric template<class _U1, class _U2, typename enable_if< 236fe6060f1SDimitry Andric _CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>() 237349cc55cSDimitry Andric >::type* = nullptr> 238*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 239fe6060f1SDimitry Andric explicit pair(pair<_U1, _U2> const& __p) 240fe6060f1SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value && 241fe6060f1SDimitry Andric is_nothrow_constructible<second_type, _U2 const&>::value)) 242fe6060f1SDimitry Andric : first(__p.first), second(__p.second) {} 243fe6060f1SDimitry Andric 244349cc55cSDimitry Andric template<class _U1, class _U2, typename enable_if< 245fe6060f1SDimitry Andric _CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>() 246349cc55cSDimitry Andric >::type* = nullptr> 247*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 248fe6060f1SDimitry Andric pair(pair<_U1, _U2> const& __p) 249fe6060f1SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value && 250fe6060f1SDimitry Andric is_nothrow_constructible<second_type, _U2 const&>::value)) 251fe6060f1SDimitry Andric : first(__p.first), second(__p.second) {} 252fe6060f1SDimitry Andric 253349cc55cSDimitry Andric template<class _U1, class _U2, typename enable_if< 254fe6060f1SDimitry Andric _CheckArgs::template __enable_explicit<_U1, _U2>() 255349cc55cSDimitry Andric >::type* = nullptr> 256*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 257fe6060f1SDimitry Andric explicit pair(pair<_U1, _U2>&&__p) 258fe6060f1SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value && 259fe6060f1SDimitry Andric is_nothrow_constructible<second_type, _U2&&>::value)) 260fe6060f1SDimitry Andric : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {} 261fe6060f1SDimitry Andric 262349cc55cSDimitry Andric template<class _U1, class _U2, typename enable_if< 263fe6060f1SDimitry Andric _CheckArgs::template __enable_implicit<_U1, _U2>() 264349cc55cSDimitry Andric >::type* = nullptr> 265*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 266fe6060f1SDimitry Andric pair(pair<_U1, _U2>&& __p) 267fe6060f1SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value && 268fe6060f1SDimitry Andric is_nothrow_constructible<second_type, _U2&&>::value)) 269fe6060f1SDimitry Andric : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {} 270fe6060f1SDimitry Andric 271*bdd1243dSDimitry Andric #if _LIBCPP_STD_VER > 20 272*bdd1243dSDimitry Andric template<class _U1, class _U2, __enable_if_t< 273*bdd1243dSDimitry Andric _CheckArgs::template __is_pair_constructible<const _U1&&, const _U2&&>() 274*bdd1243dSDimitry Andric >* = nullptr> 275*bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr 276*bdd1243dSDimitry Andric explicit(!_CheckArgs::template __is_implicit<const _U1&&, const _U2&&>()) 277*bdd1243dSDimitry Andric pair(const pair<_U1, _U2>&& __p) 278*bdd1243dSDimitry Andric noexcept(is_nothrow_constructible<first_type, const _U1&&>::value && 279*bdd1243dSDimitry Andric is_nothrow_constructible<second_type, const _U2&&>::value) 280*bdd1243dSDimitry Andric : first(std::move(__p.first)), second(std::move(__p.second)) {} 281*bdd1243dSDimitry Andric #endif 282*bdd1243dSDimitry Andric 283349cc55cSDimitry Andric template<class _Tuple, typename enable_if< 284fe6060f1SDimitry Andric _CheckTLC<_Tuple>::template __enable_explicit<_Tuple>() 285349cc55cSDimitry Andric >::type* = nullptr> 286*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 287fe6060f1SDimitry Andric explicit pair(_Tuple&& __p) 288fe6060f1SDimitry Andric : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))), 289fe6060f1SDimitry Andric second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {} 290fe6060f1SDimitry Andric 291349cc55cSDimitry Andric template<class _Tuple, typename enable_if< 292fe6060f1SDimitry Andric _CheckTLC<_Tuple>::template __enable_implicit<_Tuple>() 293349cc55cSDimitry Andric >::type* = nullptr> 294*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 295fe6060f1SDimitry Andric pair(_Tuple&& __p) 296fe6060f1SDimitry Andric : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))), 297fe6060f1SDimitry Andric second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {} 298fe6060f1SDimitry Andric 299fe6060f1SDimitry Andric template <class... _Args1, class... _Args2> 300*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 301fe6060f1SDimitry Andric pair(piecewise_construct_t __pc, 302fe6060f1SDimitry Andric tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) 303fe6060f1SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value && 304fe6060f1SDimitry Andric is_nothrow_constructible<second_type, _Args2...>::value)) 305fe6060f1SDimitry Andric : pair(__pc, __first_args, __second_args, 306fe6060f1SDimitry Andric typename __make_tuple_indices<sizeof...(_Args1)>::type(), 307fe6060f1SDimitry Andric typename __make_tuple_indices<sizeof...(_Args2) >::type()) {} 308fe6060f1SDimitry Andric 309*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 310*bdd1243dSDimitry Andric pair& operator=(__conditional_t< 311fe6060f1SDimitry Andric is_copy_assignable<first_type>::value && 312fe6060f1SDimitry Andric is_copy_assignable<second_type>::value, 313*bdd1243dSDimitry Andric pair, __nat> const& __p) 314fe6060f1SDimitry Andric _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value && 315fe6060f1SDimitry Andric is_nothrow_copy_assignable<second_type>::value) 316fe6060f1SDimitry Andric { 317fe6060f1SDimitry Andric first = __p.first; 318fe6060f1SDimitry Andric second = __p.second; 319fe6060f1SDimitry Andric return *this; 320fe6060f1SDimitry Andric } 321fe6060f1SDimitry Andric 322*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 323*bdd1243dSDimitry Andric pair& operator=(__conditional_t< 324fe6060f1SDimitry Andric is_move_assignable<first_type>::value && 325fe6060f1SDimitry Andric is_move_assignable<second_type>::value, 326*bdd1243dSDimitry Andric pair, __nat>&& __p) 327fe6060f1SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value && 328fe6060f1SDimitry Andric is_nothrow_move_assignable<second_type>::value) 329fe6060f1SDimitry Andric { 330fe6060f1SDimitry Andric first = _VSTD::forward<first_type>(__p.first); 331fe6060f1SDimitry Andric second = _VSTD::forward<second_type>(__p.second); 332fe6060f1SDimitry Andric return *this; 333fe6060f1SDimitry Andric } 334fe6060f1SDimitry Andric 335*bdd1243dSDimitry Andric #if _LIBCPP_STD_VER > 20 336*bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr 337*bdd1243dSDimitry Andric const pair& operator=(pair const& __p) const 338*bdd1243dSDimitry Andric noexcept(is_nothrow_copy_assignable_v<const first_type> && 339*bdd1243dSDimitry Andric is_nothrow_copy_assignable_v<const second_type>) 340*bdd1243dSDimitry Andric requires(is_copy_assignable_v<const first_type> && 341*bdd1243dSDimitry Andric is_copy_assignable_v<const second_type>) { 342*bdd1243dSDimitry Andric first = __p.first; 343*bdd1243dSDimitry Andric second = __p.second; 344*bdd1243dSDimitry Andric return *this; 345*bdd1243dSDimitry Andric } 346*bdd1243dSDimitry Andric 347*bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr 348*bdd1243dSDimitry Andric const pair& operator=(pair&& __p) const 349*bdd1243dSDimitry Andric noexcept(is_nothrow_assignable_v<const first_type&, first_type> && 350*bdd1243dSDimitry Andric is_nothrow_assignable_v<const second_type&, second_type>) 351*bdd1243dSDimitry Andric requires(is_assignable_v<const first_type&, first_type> && 352*bdd1243dSDimitry Andric is_assignable_v<const second_type&, second_type>) { 353*bdd1243dSDimitry Andric first = std::forward<first_type>(__p.first); 354*bdd1243dSDimitry Andric second = std::forward<second_type>(__p.second); 355*bdd1243dSDimitry Andric return *this; 356*bdd1243dSDimitry Andric } 357*bdd1243dSDimitry Andric 358*bdd1243dSDimitry Andric template<class _U1, class _U2> 359*bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr 360*bdd1243dSDimitry Andric const pair& operator=(const pair<_U1, _U2>& __p) const 361*bdd1243dSDimitry Andric requires(is_assignable_v<const first_type&, const _U1&> && 362*bdd1243dSDimitry Andric is_assignable_v<const second_type&, const _U2&>) { 363*bdd1243dSDimitry Andric first = __p.first; 364*bdd1243dSDimitry Andric second = __p.second; 365*bdd1243dSDimitry Andric return *this; 366*bdd1243dSDimitry Andric } 367*bdd1243dSDimitry Andric 368*bdd1243dSDimitry Andric template<class _U1, class _U2> 369*bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr 370*bdd1243dSDimitry Andric const pair& operator=(pair<_U1, _U2>&& __p) const 371*bdd1243dSDimitry Andric requires(is_assignable_v<const first_type&, _U1> && 372*bdd1243dSDimitry Andric is_assignable_v<const second_type&, _U2>) { 373*bdd1243dSDimitry Andric first = std::forward<_U1>(__p.first); 374*bdd1243dSDimitry Andric second = std::forward<_U2>(__p.second); 375*bdd1243dSDimitry Andric return *this; 376*bdd1243dSDimitry Andric } 377*bdd1243dSDimitry Andric #endif // _LIBCPP_STD_VER > 20 378*bdd1243dSDimitry Andric 379349cc55cSDimitry Andric template <class _Tuple, typename enable_if< 380fe6060f1SDimitry Andric _CheckTLC<_Tuple>::template __enable_assign<_Tuple>() 381349cc55cSDimitry Andric >::type* = nullptr> 382*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 383fe6060f1SDimitry Andric pair& operator=(_Tuple&& __p) { 384fe6060f1SDimitry Andric first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p)); 385fe6060f1SDimitry Andric second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p)); 386fe6060f1SDimitry Andric return *this; 387fe6060f1SDimitry Andric } 388fe6060f1SDimitry Andric #endif 389fe6060f1SDimitry Andric 390*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 391fe6060f1SDimitry Andric void 392fe6060f1SDimitry Andric swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value && 393fe6060f1SDimitry Andric __is_nothrow_swappable<second_type>::value) 394fe6060f1SDimitry Andric { 395fe6060f1SDimitry Andric using _VSTD::swap; 396fe6060f1SDimitry Andric swap(first, __p.first); 397fe6060f1SDimitry Andric swap(second, __p.second); 398fe6060f1SDimitry Andric } 399*bdd1243dSDimitry Andric 400*bdd1243dSDimitry Andric #if _LIBCPP_STD_VER > 20 401*bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr 402*bdd1243dSDimitry Andric void swap(const pair& __p) const 403*bdd1243dSDimitry Andric noexcept(__is_nothrow_swappable<const first_type>::value && 404*bdd1243dSDimitry Andric __is_nothrow_swappable<const second_type>::value) 405*bdd1243dSDimitry Andric { 406*bdd1243dSDimitry Andric using std::swap; 407*bdd1243dSDimitry Andric swap(first, __p.first); 408*bdd1243dSDimitry Andric swap(second, __p.second); 409*bdd1243dSDimitry Andric } 410*bdd1243dSDimitry Andric #endif 411fe6060f1SDimitry Andric private: 412fe6060f1SDimitry Andric 413fe6060f1SDimitry Andric #ifndef _LIBCPP_CXX03_LANG 414fe6060f1SDimitry Andric template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 415*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 416fe6060f1SDimitry Andric pair(piecewise_construct_t, 417fe6060f1SDimitry Andric tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args, 418fe6060f1SDimitry Andric __tuple_indices<_I1...>, __tuple_indices<_I2...>); 419fe6060f1SDimitry Andric #endif 420fe6060f1SDimitry Andric }; 421fe6060f1SDimitry Andric 42281ad6265SDimitry Andric #if _LIBCPP_STD_VER > 14 423fe6060f1SDimitry Andric template<class _T1, class _T2> 424fe6060f1SDimitry Andric pair(_T1, _T2) -> pair<_T1, _T2>; 425349cc55cSDimitry Andric #endif 426349cc55cSDimitry Andric 427349cc55cSDimitry Andric // [pairs.spec], specialized algorithms 428fe6060f1SDimitry Andric 429fe6060f1SDimitry Andric template <class _T1, class _T2> 430*bdd1243dSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 431fe6060f1SDimitry Andric bool 432fe6060f1SDimitry Andric operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 433fe6060f1SDimitry Andric { 434fe6060f1SDimitry Andric return __x.first == __y.first && __x.second == __y.second; 435fe6060f1SDimitry Andric } 436fe6060f1SDimitry Andric 43781ad6265SDimitry Andric #if _LIBCPP_STD_VER > 17 438349cc55cSDimitry Andric 439349cc55cSDimitry Andric template <class _T1, class _T2> 440349cc55cSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr 441349cc55cSDimitry Andric common_comparison_category_t< 442349cc55cSDimitry Andric __synth_three_way_result<_T1>, 443349cc55cSDimitry Andric __synth_three_way_result<_T2> > 444349cc55cSDimitry Andric operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 445349cc55cSDimitry Andric { 446349cc55cSDimitry Andric if (auto __c = _VSTD::__synth_three_way(__x.first, __y.first); __c != 0) { 447349cc55cSDimitry Andric return __c; 448349cc55cSDimitry Andric } 449349cc55cSDimitry Andric return _VSTD::__synth_three_way(__x.second, __y.second); 450349cc55cSDimitry Andric } 451349cc55cSDimitry Andric 45281ad6265SDimitry Andric #else // _LIBCPP_STD_VER > 17 453349cc55cSDimitry Andric 454fe6060f1SDimitry Andric template <class _T1, class _T2> 455*bdd1243dSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 456fe6060f1SDimitry Andric bool 457fe6060f1SDimitry Andric operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 458fe6060f1SDimitry Andric { 459fe6060f1SDimitry Andric return !(__x == __y); 460fe6060f1SDimitry Andric } 461fe6060f1SDimitry Andric 462fe6060f1SDimitry Andric template <class _T1, class _T2> 463*bdd1243dSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 464fe6060f1SDimitry Andric bool 465fe6060f1SDimitry Andric operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 466fe6060f1SDimitry Andric { 467fe6060f1SDimitry Andric return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second); 468fe6060f1SDimitry Andric } 469fe6060f1SDimitry Andric 470fe6060f1SDimitry Andric template <class _T1, class _T2> 471*bdd1243dSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 472fe6060f1SDimitry Andric bool 473fe6060f1SDimitry Andric operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 474fe6060f1SDimitry Andric { 475fe6060f1SDimitry Andric return __y < __x; 476fe6060f1SDimitry Andric } 477fe6060f1SDimitry Andric 478fe6060f1SDimitry Andric template <class _T1, class _T2> 479*bdd1243dSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 480fe6060f1SDimitry Andric bool 481fe6060f1SDimitry Andric operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 482fe6060f1SDimitry Andric { 483fe6060f1SDimitry Andric return !(__x < __y); 484fe6060f1SDimitry Andric } 485fe6060f1SDimitry Andric 486fe6060f1SDimitry Andric template <class _T1, class _T2> 487*bdd1243dSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 488fe6060f1SDimitry Andric bool 489fe6060f1SDimitry Andric operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 490fe6060f1SDimitry Andric { 491fe6060f1SDimitry Andric return !(__y < __x); 492fe6060f1SDimitry Andric } 493fe6060f1SDimitry Andric 49481ad6265SDimitry Andric #endif // _LIBCPP_STD_VER > 17 49581ad6265SDimitry Andric 49681ad6265SDimitry Andric #if _LIBCPP_STD_VER > 20 49781ad6265SDimitry Andric template <class _T1, class _T2, class _U1, class _U2, template<class> class _TQual, template<class> class _UQual> 49881ad6265SDimitry Andric requires requires { typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, 49981ad6265SDimitry Andric common_reference_t<_TQual<_T2>, _UQual<_U2>>>; } 50081ad6265SDimitry Andric struct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual> { 50181ad6265SDimitry Andric using type = pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, 50281ad6265SDimitry Andric common_reference_t<_TQual<_T2>, _UQual<_U2>>>; 50381ad6265SDimitry Andric }; 50481ad6265SDimitry Andric 50581ad6265SDimitry Andric template <class _T1, class _T2, class _U1, class _U2> 50681ad6265SDimitry Andric requires requires { typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; } 50781ad6265SDimitry Andric struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> { 50881ad6265SDimitry Andric using type = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; 50981ad6265SDimitry Andric }; 51081ad6265SDimitry Andric #endif // _LIBCPP_STD_VER > 20 511349cc55cSDimitry Andric 512fe6060f1SDimitry Andric template <class _T1, class _T2> 513*bdd1243dSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 514fe6060f1SDimitry Andric typename enable_if 515fe6060f1SDimitry Andric < 516fe6060f1SDimitry Andric __is_swappable<_T1>::value && 517fe6060f1SDimitry Andric __is_swappable<_T2>::value, 518fe6060f1SDimitry Andric void 519fe6060f1SDimitry Andric >::type 520fe6060f1SDimitry Andric swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) 521fe6060f1SDimitry Andric _NOEXCEPT_((__is_nothrow_swappable<_T1>::value && 522fe6060f1SDimitry Andric __is_nothrow_swappable<_T2>::value)) 523fe6060f1SDimitry Andric { 524fe6060f1SDimitry Andric __x.swap(__y); 525fe6060f1SDimitry Andric } 526fe6060f1SDimitry Andric 527*bdd1243dSDimitry Andric #if _LIBCPP_STD_VER > 20 528*bdd1243dSDimitry Andric template <class _T1, class _T2> 529*bdd1243dSDimitry Andric requires (__is_swappable<const _T1>::value && 530*bdd1243dSDimitry Andric __is_swappable<const _T2>::value) 531*bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI constexpr 532*bdd1243dSDimitry Andric void swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) 533*bdd1243dSDimitry Andric noexcept(noexcept(__x.swap(__y))) 534*bdd1243dSDimitry Andric { 535*bdd1243dSDimitry Andric __x.swap(__y); 536*bdd1243dSDimitry Andric } 537*bdd1243dSDimitry Andric #endif 538fe6060f1SDimitry Andric 539fe6060f1SDimitry Andric template <class _T1, class _T2> 540*bdd1243dSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 541fe6060f1SDimitry Andric pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type> 542fe6060f1SDimitry Andric make_pair(_T1&& __t1, _T2&& __t2) 543fe6060f1SDimitry Andric { 544fe6060f1SDimitry Andric return pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type> 545fe6060f1SDimitry Andric (_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2)); 546fe6060f1SDimitry Andric } 547fe6060f1SDimitry Andric 548fe6060f1SDimitry Andric template <class _T1, class _T2> 549fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> > 550fe6060f1SDimitry Andric : public integral_constant<size_t, 2> {}; 551fe6060f1SDimitry Andric 552fe6060f1SDimitry Andric template <size_t _Ip, class _T1, class _T2> 553fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> > 554fe6060f1SDimitry Andric { 555fe6060f1SDimitry Andric static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::pair<T1, T2>>"); 556fe6060f1SDimitry Andric }; 557fe6060f1SDimitry Andric 558fe6060f1SDimitry Andric template <class _T1, class _T2> 559fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> > 560fe6060f1SDimitry Andric { 561349cc55cSDimitry Andric typedef _LIBCPP_NODEBUG _T1 type; 562fe6060f1SDimitry Andric }; 563fe6060f1SDimitry Andric 564fe6060f1SDimitry Andric template <class _T1, class _T2> 565fe6060f1SDimitry Andric struct _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> > 566fe6060f1SDimitry Andric { 567349cc55cSDimitry Andric typedef _LIBCPP_NODEBUG _T2 type; 568fe6060f1SDimitry Andric }; 569fe6060f1SDimitry Andric 570fe6060f1SDimitry Andric template <size_t _Ip> struct __get_pair; 571fe6060f1SDimitry Andric 572fe6060f1SDimitry Andric template <> 573fe6060f1SDimitry Andric struct __get_pair<0> 574fe6060f1SDimitry Andric { 575fe6060f1SDimitry Andric template <class _T1, class _T2> 576fe6060f1SDimitry Andric static 577*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 578fe6060f1SDimitry Andric _T1& 579fe6060f1SDimitry Andric get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;} 580fe6060f1SDimitry Andric 581fe6060f1SDimitry Andric template <class _T1, class _T2> 582fe6060f1SDimitry Andric static 583*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 584fe6060f1SDimitry Andric const _T1& 585fe6060f1SDimitry Andric get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;} 586fe6060f1SDimitry Andric 587fe6060f1SDimitry Andric template <class _T1, class _T2> 588fe6060f1SDimitry Andric static 589*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 590fe6060f1SDimitry Andric _T1&& 591fe6060f1SDimitry Andric get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);} 592fe6060f1SDimitry Andric 593fe6060f1SDimitry Andric template <class _T1, class _T2> 594fe6060f1SDimitry Andric static 595*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 596fe6060f1SDimitry Andric const _T1&& 597fe6060f1SDimitry Andric get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T1>(__p.first);} 598fe6060f1SDimitry Andric }; 599fe6060f1SDimitry Andric 600fe6060f1SDimitry Andric template <> 601fe6060f1SDimitry Andric struct __get_pair<1> 602fe6060f1SDimitry Andric { 603fe6060f1SDimitry Andric template <class _T1, class _T2> 604fe6060f1SDimitry Andric static 605*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 606fe6060f1SDimitry Andric _T2& 607fe6060f1SDimitry Andric get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;} 608fe6060f1SDimitry Andric 609fe6060f1SDimitry Andric template <class _T1, class _T2> 610fe6060f1SDimitry Andric static 611*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 612fe6060f1SDimitry Andric const _T2& 613fe6060f1SDimitry Andric get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;} 614fe6060f1SDimitry Andric 615fe6060f1SDimitry Andric template <class _T1, class _T2> 616fe6060f1SDimitry Andric static 617*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 618fe6060f1SDimitry Andric _T2&& 619fe6060f1SDimitry Andric get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);} 620fe6060f1SDimitry Andric 621fe6060f1SDimitry Andric template <class _T1, class _T2> 622fe6060f1SDimitry Andric static 623*bdd1243dSDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 624fe6060f1SDimitry Andric const _T2&& 625fe6060f1SDimitry Andric get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T2>(__p.second);} 626fe6060f1SDimitry Andric }; 627fe6060f1SDimitry Andric 628fe6060f1SDimitry Andric template <size_t _Ip, class _T1, class _T2> 629*bdd1243dSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 630fe6060f1SDimitry Andric typename tuple_element<_Ip, pair<_T1, _T2> >::type& 631fe6060f1SDimitry Andric get(pair<_T1, _T2>& __p) _NOEXCEPT 632fe6060f1SDimitry Andric { 633fe6060f1SDimitry Andric return __get_pair<_Ip>::get(__p); 634fe6060f1SDimitry Andric } 635fe6060f1SDimitry Andric 636fe6060f1SDimitry Andric template <size_t _Ip, class _T1, class _T2> 637*bdd1243dSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 638fe6060f1SDimitry Andric const typename tuple_element<_Ip, pair<_T1, _T2> >::type& 639fe6060f1SDimitry Andric get(const pair<_T1, _T2>& __p) _NOEXCEPT 640fe6060f1SDimitry Andric { 641fe6060f1SDimitry Andric return __get_pair<_Ip>::get(__p); 642fe6060f1SDimitry Andric } 643fe6060f1SDimitry Andric 644fe6060f1SDimitry Andric template <size_t _Ip, class _T1, class _T2> 645*bdd1243dSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 646fe6060f1SDimitry Andric typename tuple_element<_Ip, pair<_T1, _T2> >::type&& 647fe6060f1SDimitry Andric get(pair<_T1, _T2>&& __p) _NOEXCEPT 648fe6060f1SDimitry Andric { 649fe6060f1SDimitry Andric return __get_pair<_Ip>::get(_VSTD::move(__p)); 650fe6060f1SDimitry Andric } 651fe6060f1SDimitry Andric 652fe6060f1SDimitry Andric template <size_t _Ip, class _T1, class _T2> 653*bdd1243dSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 654fe6060f1SDimitry Andric const typename tuple_element<_Ip, pair<_T1, _T2> >::type&& 655fe6060f1SDimitry Andric get(const pair<_T1, _T2>&& __p) _NOEXCEPT 656fe6060f1SDimitry Andric { 657fe6060f1SDimitry Andric return __get_pair<_Ip>::get(_VSTD::move(__p)); 658fe6060f1SDimitry Andric } 659fe6060f1SDimitry Andric 660fe6060f1SDimitry Andric #if _LIBCPP_STD_VER > 11 661fe6060f1SDimitry Andric template <class _T1, class _T2> 662fe6060f1SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 663fe6060f1SDimitry Andric constexpr _T1 & get(pair<_T1, _T2>& __p) _NOEXCEPT 664fe6060f1SDimitry Andric { 665fe6060f1SDimitry Andric return __get_pair<0>::get(__p); 666fe6060f1SDimitry Andric } 667fe6060f1SDimitry Andric 668fe6060f1SDimitry Andric template <class _T1, class _T2> 669fe6060f1SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 670fe6060f1SDimitry Andric constexpr _T1 const & get(pair<_T1, _T2> const& __p) _NOEXCEPT 671fe6060f1SDimitry Andric { 672fe6060f1SDimitry Andric return __get_pair<0>::get(__p); 673fe6060f1SDimitry Andric } 674fe6060f1SDimitry Andric 675fe6060f1SDimitry Andric template <class _T1, class _T2> 676fe6060f1SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 677fe6060f1SDimitry Andric constexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT 678fe6060f1SDimitry Andric { 679fe6060f1SDimitry Andric return __get_pair<0>::get(_VSTD::move(__p)); 680fe6060f1SDimitry Andric } 681fe6060f1SDimitry Andric 682fe6060f1SDimitry Andric template <class _T1, class _T2> 683fe6060f1SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 684fe6060f1SDimitry Andric constexpr _T1 const && get(pair<_T1, _T2> const&& __p) _NOEXCEPT 685fe6060f1SDimitry Andric { 686fe6060f1SDimitry Andric return __get_pair<0>::get(_VSTD::move(__p)); 687fe6060f1SDimitry Andric } 688fe6060f1SDimitry Andric 689fe6060f1SDimitry Andric template <class _T1, class _T2> 690fe6060f1SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 691fe6060f1SDimitry Andric constexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT 692fe6060f1SDimitry Andric { 693fe6060f1SDimitry Andric return __get_pair<1>::get(__p); 694fe6060f1SDimitry Andric } 695fe6060f1SDimitry Andric 696fe6060f1SDimitry Andric template <class _T1, class _T2> 697fe6060f1SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 698fe6060f1SDimitry Andric constexpr _T1 const & get(pair<_T2, _T1> const& __p) _NOEXCEPT 699fe6060f1SDimitry Andric { 700fe6060f1SDimitry Andric return __get_pair<1>::get(__p); 701fe6060f1SDimitry Andric } 702fe6060f1SDimitry Andric 703fe6060f1SDimitry Andric template <class _T1, class _T2> 704fe6060f1SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 705fe6060f1SDimitry Andric constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT 706fe6060f1SDimitry Andric { 707fe6060f1SDimitry Andric return __get_pair<1>::get(_VSTD::move(__p)); 708fe6060f1SDimitry Andric } 709fe6060f1SDimitry Andric 710fe6060f1SDimitry Andric template <class _T1, class _T2> 711fe6060f1SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 712fe6060f1SDimitry Andric constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT 713fe6060f1SDimitry Andric { 714fe6060f1SDimitry Andric return __get_pair<1>::get(_VSTD::move(__p)); 715fe6060f1SDimitry Andric } 716fe6060f1SDimitry Andric 717*bdd1243dSDimitry Andric #endif // _LIBCPP_STD_VER > 11 718fe6060f1SDimitry Andric 719fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD 720fe6060f1SDimitry Andric 721fe6060f1SDimitry Andric #endif // _LIBCPP___UTILITY_PAIR_H 722