61 #if __cplusplus >= 201103L
65 namespace std _GLIBCXX_VISIBILITY(default)
67 _GLIBCXX_BEGIN_NAMESPACE_VERSION
74 #if __cplusplus >= 201103L
86 template<std::size_t...>
94 template <
bool,
typename _T1,
typename _T2>
97 template <
typename _U1,
typename _U2>
98 static constexpr
bool _ConstructiblePair()
100 return __and_<is_constructible<_T1, const _U1&>,
101 is_constructible<_T2, const _U2&>>::value;
104 template <
typename _U1,
typename _U2>
105 static constexpr
bool _ImplicitlyConvertiblePair()
107 return __and_<is_convertible<const _U1&, _T1>,
108 is_convertible<const _U2&, _T2>>::value;
111 template <
typename _U1,
typename _U2>
112 static constexpr
bool _MoveConstructiblePair()
114 return __and_<is_constructible<_T1, _U1&&>,
115 is_constructible<_T2, _U2&&>>::value;
118 template <
typename _U1,
typename _U2>
119 static constexpr
bool _ImplicitlyMoveConvertiblePair()
121 return __and_<is_convertible<_U1&&, _T1>,
122 is_convertible<_U2&&, _T2>>::value;
125 template <
bool __implicit,
typename _U1,
typename _U2>
126 static constexpr
bool _CopyMovePair()
128 using __do_converts = __and_<is_convertible<const _U1&, _T1>,
129 is_convertible<_U2&&, _T2>>;
130 using __converts =
typename conditional<__implicit,
132 __not_<__do_converts>>::type;
133 return __and_<is_constructible<_T1, const _U1&>,
134 is_constructible<_T2, _U2&&>,
139 template <
bool __implicit,
typename _U1,
typename _U2>
140 static constexpr
bool _MoveCopyPair()
142 using __do_converts = __and_<is_convertible<_U1&&, _T1>,
143 is_convertible<const _U2&, _T2>>;
144 using __converts =
typename conditional<__implicit,
146 __not_<__do_converts>>::type;
147 return __and_<is_constructible<_T1, _U1&&>,
148 is_constructible<_T2, const _U2&&>,
154 template <
typename _T1,
typename _T2>
155 struct _PCC<false, _T1, _T2>
157 template <
typename _U1,
typename _U2>
158 static constexpr
bool _ConstructiblePair()
163 template <
typename _U1,
typename _U2>
164 static constexpr
bool _ImplicitlyConvertiblePair()
169 template <
typename _U1,
typename _U2>
170 static constexpr
bool _MoveConstructiblePair()
175 template <
typename _U1,
typename _U2>
176 static constexpr
bool _ImplicitlyMoveConvertiblePair()
185 struct __nonesuch_no_braces : std::__nonesuch {
186 explicit __nonesuch_no_braces(
const __nonesuch&) =
delete;
197 template<
typename _T1,
typename _T2>
200 typedef _T1 first_type;
210 #if __cplusplus >= 201103L
211 template <
typename _U1 = _T1,
213 typename enable_if<__and_<
214 __is_implicitly_default_constructible<_U1>,
215 __is_implicitly_default_constructible<_U2>>
216 ::value,
bool>::type =
true>
221 #if __cplusplus >= 201103L
222 template <
typename _U1 = _T1,
224 typename enable_if<__and_<
225 is_default_constructible<_U1>,
226 is_default_constructible<_U2>,
228 __and_<__is_implicitly_default_constructible<_U1>,
229 __is_implicitly_default_constructible<_U2>>>>
230 ::value,
bool>::type =
false>
231 explicit constexpr
pair()
236 #if __cplusplus < 201103L
237 pair(
const _T1& __a,
const _T2& __b)
243 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
244 enable_if<_PCCP::template
245 _ConstructiblePair<_U1, _U2>()
247 _ImplicitlyConvertiblePair<_U1, _U2>(),
249 constexpr
pair(
const _T1& __a,
const _T2& __b)
252 template<
typename _U1 = _T1,
typename _U2=_T2,
typename
253 enable_if<_PCCP::template
254 _ConstructiblePair<_U1, _U2>()
256 _ImplicitlyConvertiblePair<_U1, _U2>(),
258 explicit constexpr
pair(
const _T1& __a,
const _T2& __b)
263 #if __cplusplus < 201103L
264 template<
typename _U1,
typename _U2>
265 pair(
const pair<_U1, _U2>& __p)
269 template <
typename _U1,
typename _U2>
270 using _PCCFP = _PCC<!is_same<_T1, _U1>::value
271 || !is_same<_T2, _U2>::value,
274 template<
typename _U1,
typename _U2,
typename
275 enable_if<_PCCFP<_U1, _U2>::template
276 _ConstructiblePair<_U1, _U2>()
278 _ImplicitlyConvertiblePair<_U1, _U2>(),
283 template<
typename _U1,
typename _U2,
typename
284 enable_if<_PCCFP<_U1, _U2>::template
285 _ConstructiblePair<_U1, _U2>()
286 && !_PCCFP<_U1, _U2>::template
287 _ImplicitlyConvertiblePair<_U1, _U2>(),
292 constexpr
pair(
const pair&) =
default;
296 template<
typename _U1,
typename
297 enable_if<_PCCP::template
298 _MoveCopyPair<true, _U1, _T2>(),
300 constexpr
pair(_U1&& __x,
const _T2& __y)
303 template<
typename _U1,
typename
304 enable_if<_PCCP::template
305 _MoveCopyPair<false, _U1, _T2>(),
307 explicit constexpr
pair(_U1&& __x,
const _T2& __y)
310 template<
typename _U2,
typename
311 enable_if<_PCCP::template
312 _CopyMovePair<true, _T1, _U2>(),
314 constexpr
pair(
const _T1& __x, _U2&& __y)
317 template<
typename _U2,
typename
318 enable_if<_PCCP::template
319 _CopyMovePair<false, _T1, _U2>(),
321 explicit pair(
const _T1& __x, _U2&& __y)
324 template<
typename _U1,
typename _U2,
typename
325 enable_if<_PCCP::template
326 _MoveConstructiblePair<_U1, _U2>()
328 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
330 constexpr
pair(_U1&& __x, _U2&& __y)
333 template<
typename _U1,
typename _U2,
typename
334 enable_if<_PCCP::template
335 _MoveConstructiblePair<_U1, _U2>()
337 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
339 explicit constexpr
pair(_U1&& __x, _U2&& __y)
343 template<
typename _U1,
typename _U2,
typename
344 enable_if<_PCCFP<_U1, _U2>::template
345 _MoveConstructiblePair<_U1, _U2>()
346 && _PCCFP<_U1, _U2>::template
347 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
349 constexpr
pair(pair<_U1, _U2>&& __p)
353 template<
typename _U1,
typename _U2,
typename
354 enable_if<_PCCFP<_U1, _U2>::template
355 _MoveConstructiblePair<_U1, _U2>()
356 && !_PCCFP<_U1, _U2>::template
357 _ImplicitlyMoveConvertiblePair<_U1, _U2>(),
359 explicit constexpr
pair(pair<_U1, _U2>&& __p)
363 template<
typename... _Args1,
typename... _Args2>
364 pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>);
367 operator=(
typename conditional<
368 __and_<is_copy_assignable<_T1>,
369 is_copy_assignable<_T2>>::value,
370 const pair&,
const __nonesuch_no_braces&>::type __p)
378 operator=(
typename conditional<
379 __not_<__and_<is_copy_assignable<_T1>,
380 is_copy_assignable<_T2>>>::value,
381 const pair&,
const __nonesuch_no_braces&>::type __p) =
delete;
384 operator=(
typename conditional<
385 __and_<is_move_assignable<_T1>,
386 is_move_assignable<_T2>>::value,
387 pair&&, __nonesuch_no_braces&&>::type __p)
388 noexcept(__and_<is_nothrow_move_assignable<_T1>,
389 is_nothrow_move_assignable<_T2>>::value)
391 first = std::forward<first_type>(__p.first);
392 second = std::forward<second_type>(__p.second);
396 template<
typename _U1,
typename _U2>
397 typename enable_if<__and_<is_assignable<_T1&, const _U1&>,
398 is_assignable<_T2&, const _U2&>>::value,
400 operator=(
const pair<_U1, _U2>& __p)
407 template<
typename _U1,
typename _U2>
408 typename enable_if<__and_<is_assignable<_T1&, _U1&&>,
409 is_assignable<_T2&, _U2&&>>::value,
411 operator=(pair<_U1, _U2>&& __p)
413 first = std::forward<_U1>(__p.first);
414 second = std::forward<_U2>(__p.second);
420 noexcept(__and_<__is_nothrow_swappable<_T1>,
421 __is_nothrow_swappable<_T2>>::value)
424 swap(
first, __p.first);
429 template<
typename... _Args1, std::size_t... _Indexes1,
430 typename... _Args2, std::size_t... _Indexes2>
431 pair(tuple<_Args1...>&, tuple<_Args2...>&,
432 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
436 #if __cpp_deduction_guides >= 201606
437 template<
typename _T1,
typename _T2> pair(_T1, _T2) -> pair<_T1, _T2>;
441 template<
typename _T1,
typename _T2>
442 inline _GLIBCXX_CONSTEXPR
bool
447 template<
typename _T1,
typename _T2>
448 inline _GLIBCXX_CONSTEXPR
bool
450 {
return __x.first < __y.first
451 || (!(__y.first < __x.first) && __x.second < __y.second); }
454 template<
typename _T1,
typename _T2>
455 inline _GLIBCXX_CONSTEXPR
bool
457 {
return !(__x == __y); }
460 template<
typename _T1,
typename _T2>
461 inline _GLIBCXX_CONSTEXPR
bool
463 {
return __y < __x; }
466 template<
typename _T1,
typename _T2>
467 inline _GLIBCXX_CONSTEXPR
bool
469 {
return !(__y < __x); }
472 template<
typename _T1,
typename _T2>
473 inline _GLIBCXX_CONSTEXPR
bool
475 {
return !(__x < __y); }
477 #if __cplusplus >= 201103L
481 template<
typename _T1,
typename _T2>
483 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
485 typename enable_if<__and_<__is_swappable<_T1>,
486 __is_swappable<_T2>>::value>::type
490 swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
491 noexcept(noexcept(__x.swap(__y)))
494 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
495 template<
typename _T1,
typename _T2>
496 typename enable_if<!__and_<__is_swappable<_T1>,
497 __is_swappable<_T2>>::value>::type
498 swap(pair<_T1, _T2>&, pair<_T1, _T2>&) =
delete;
500 #endif // __cplusplus >= 201103L
514 #if __cplusplus >= 201103L
516 template<
typename _T1,
typename _T2>
517 constexpr pair<typename __decay_and_strip<_T1>::__type,
518 typename __decay_and_strip<_T2>::__type>
521 typedef typename __decay_and_strip<_T1>::__type __ds_type1;
522 typedef typename __decay_and_strip<_T2>::__type __ds_type2;
524 return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
527 template<
typename _T1,
typename _T2>
528 inline pair<_T1, _T2>
530 {
return pair<_T1, _T2>(__x, __y); }
535 _GLIBCXX_END_NAMESPACE_VERSION
constexpr pair()
second is a copy of the second object
_PCC<!is_same< _T1, _U1 >::value||!is_same< _T2, _U2 >::value, _T1, _T2 > _PCCFP
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
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.
_GLIBCXX17_INLINE constexpr piecewise_construct_t piecewise_construct
piecewise_construct
_PCC< true, _BiIter, _BiIter > _PCCP
Primary class template, tuple.
_T2 second
first is a copy of the first object
Struct holding two objects of arbitrary type.
_T1 first
second_type is the second bound type
_T2 second_type
first_type is the first bound type