61 #if __cplusplus >= 201103L 65 namespace std _GLIBCXX_VISIBILITY(default)
67 _GLIBCXX_BEGIN_NAMESPACE_VERSION
74 #if __cplusplus >= 201103L 85 template<std::size_t...>
90 template <
typename _T1,
typename _T2,
typename _U1,
typename _U2>
91 constexpr
bool _ConstructiblePair()
93 return __and_<is_constructible<_T1, const _U1&>,
94 is_constructible<_T2, const _U2&>>::value;
97 template <
typename _T1,
typename _T2,
typename _U1,
typename _U2>
98 constexpr
bool _ImplicitlyConvertiblePair()
100 return __and_<is_convertible<const _U1&, _T1>,
101 is_convertible<const _U2&, _T2>>::value;
104 template <
typename _T1,
typename _T2,
typename _U1,
typename _U2>
105 constexpr
bool _MoveConstructiblePair()
107 return __and_<is_constructible<_T1, _U1&&>,
108 is_constructible<_T2, _U2&&>>::value;
111 template <
typename _T1,
typename _T2,
typename _U1,
typename _U2>
112 constexpr
bool _ImplicitlyMoveConvertiblePair()
114 return __and_<is_convertible<_U1&&, _T1>,
115 is_convertible<_U2&&, _T2>>::value;
127 template<
typename _T1,
typename _T2>
130 typedef _T1 first_type;
140 #if __cplusplus >= 201103L 141 template <
typename _U1 = _T1,
143 typename enable_if<__and_<
144 __is_implicitly_default_constructible<_U1>,
145 __is_implicitly_default_constructible<_U2>>
146 ::value,
bool>::type =
true>
149 : first(), second() { }
151 #if __cplusplus >= 201103L 152 template <
typename _U1 = _T1,
154 typename enable_if<__and_<
155 is_default_constructible<_U1>,
156 is_default_constructible<_U2>,
158 __and_<__is_implicitly_default_constructible<_U1>,
159 __is_implicitly_default_constructible<_U2>>>>
160 ::value,
bool>::type =
false>
161 explicit constexpr
pair()
162 : first(), second() { }
166 #if __cplusplus < 201103L 167 pair(
const _T1& __a,
const _T2& __b)
168 : first(__a), second(__b) { }
170 template<
typename _U1 = _T1,
typename _U2=_T2,
typename 171 enable_if<_ConstructiblePair<_T1, _T2, _U1, _U2>()
172 && _ImplicitlyConvertiblePair<_T1, _T2, _U1, _U2>(),
174 constexpr
pair(
const _T1& __a,
const _T2& __b)
175 : first(__a), second(__b) { }
177 template<
typename _U1 = _T1,
typename _U2=_T2,
typename 178 enable_if<_ConstructiblePair<_T1, _T2, _U1, _U2>()
179 && !_ImplicitlyConvertiblePair<_T1, _T2, _U1, _U2>(),
181 explicit constexpr pair(
const _T1& __a,
const _T2& __b)
182 : first(__a), second(__b) { }
186 #if __cplusplus < 201103L 187 template<
typename _U1,
typename _U2>
191 template<
typename _U1,
typename _U2,
typename 192 enable_if<_ConstructiblePair<_T1, _T2, _U1, _U2>()
193 && _ImplicitlyConvertiblePair<_T1, _T2, _U1, _U2>(),
196 : first(__p.first), second(__p.second) { }
198 template<
typename _U1,
typename _U2,
typename 199 enable_if<_ConstructiblePair<_T1, _T2, _U1, _U2>()
200 && !_ImplicitlyConvertiblePair<_T1, _T2, _U1, _U2>(),
205 constexpr pair(
const pair&) =
default;
206 constexpr pair(pair&&) =
default;
209 template<
typename _U1,
typename 210 enable_if<_ConstructiblePair<_T2, _T2, _T2, _T2>()
211 && _MoveConstructiblePair<_T1, _T2, _U1, _T2>()
212 && _ImplicitlyConvertiblePair<_T2, _T2, _T2, _T2>()
213 && _ImplicitlyMoveConvertiblePair<_T1, _T2,
216 constexpr pair(_U1&& __x,
const _T2& __y)
217 : first(std::forward<_U1>(__x)), second(__y) { }
219 template<
typename _U1,
typename 220 enable_if<_ConstructiblePair<_T2, _T2, _T2, _T2>()
221 && _MoveConstructiblePair<_T1, _T2, _U1, _T2>()
222 && (!_ImplicitlyConvertiblePair<_T2, _T2, _T2, _T2>()
223 || !_ImplicitlyMoveConvertiblePair<_T1, _T2,
226 explicit constexpr pair(_U1&& __x,
const _T2& __y)
227 : first(std::forward<_U1>(__x)), second(__y) { }
229 template<
typename _U2,
typename 230 enable_if<_ConstructiblePair<_T1, _T1, _T1, _T1>()
231 && _MoveConstructiblePair<_T1, _T2, _T1, _U2>()
232 && _ImplicitlyConvertiblePair<_T1, _T1, _T1, _T1>()
233 && _ImplicitlyMoveConvertiblePair<_T1, _T2,
236 constexpr pair(
const _T1& __x, _U2&& __y)
237 : first(__x), second(std::forward<_U2>(__y)) { }
239 template<
typename _U2,
typename 240 enable_if<_ConstructiblePair<_T1, _T1, _T1, _T1>()
241 && _MoveConstructiblePair<_T1, _T2, _T1, _U2>()
242 && (!_ImplicitlyConvertiblePair<_T1, _T1, _T1, _T1>()
243 || !_ImplicitlyMoveConvertiblePair<_T1, _T2,
246 explicit pair(
const _T1& __x, _U2&& __y)
247 : first(__x), second(std::forward<_U2>(__y)) { }
249 template<
typename _U1,
typename _U2,
typename 250 enable_if<_MoveConstructiblePair<_T1, _T2, _U1, _U2>()
251 && _ImplicitlyMoveConvertiblePair<_T1, _T2,
254 constexpr pair(_U1&& __x, _U2&& __y)
255 : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { }
257 template<
typename _U1,
typename _U2,
typename 258 enable_if<_MoveConstructiblePair<_T1, _T2, _U1, _U2>()
259 && !_ImplicitlyMoveConvertiblePair<_T1, _T2,
262 explicit constexpr pair(_U1&& __x, _U2&& __y)
263 : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { }
266 template<
typename _U1,
typename _U2,
typename 267 enable_if<_MoveConstructiblePair<_T1, _T2, _U1, _U2>()
268 && _ImplicitlyMoveConvertiblePair<_T1, _T2,
272 : first(std::forward<_U1>(__p.
first)),
273 second(std::forward<_U2>(__p.
second)) { }
275 template<
typename _U1,
typename _U2,
typename 276 enable_if<_MoveConstructiblePair<_T1, _T2, _U1, _U2>()
277 && !_ImplicitlyMoveConvertiblePair<_T1, _T2,
281 : first(std::forward<_U1>(__p.
first)),
282 second(std::forward<_U2>(__p.
second)) { }
284 template<
typename... _Args1,
typename... _Args2>
288 operator=(
const pair& __p)
296 operator=(pair&& __p)
297 noexcept(__and_<is_nothrow_move_assignable<_T1>,
298 is_nothrow_move_assignable<_T2>>::value)
300 first = std::forward<first_type>(__p.
first);
301 second = std::forward<second_type>(__p.
second);
305 template<
typename _U1,
typename _U2>
314 template<
typename _U1,
typename _U2>
318 first = std::forward<_U1>(__p.
first);
319 second = std::forward<_U2>(__p.
second);
325 noexcept(__is_nothrow_swappable<_T1>::value
326 && __is_nothrow_swappable<_T2>::value)
329 swap(first, __p.
first);
334 template<
typename... _Args1, std::size_t... _Indexes1,
335 typename... _Args2, std::size_t... _Indexes2>
337 _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
342 template<
typename _T1,
typename _T2>
343 inline _GLIBCXX_CONSTEXPR
bool 348 template<
typename _T1,
typename _T2>
349 inline _GLIBCXX_CONSTEXPR
bool 351 {
return __x.
first < __y.first
352 || (!(__y.first < __x.first) && __x.second < __y.second); }
355 template<
typename _T1,
typename _T2>
356 inline _GLIBCXX_CONSTEXPR
bool 358 {
return !(__x == __y); }
361 template<
typename _T1,
typename _T2>
362 inline _GLIBCXX_CONSTEXPR
bool 364 {
return __y < __x; }
367 template<
typename _T1,
typename _T2>
368 inline _GLIBCXX_CONSTEXPR
bool 370 {
return !(__y < __x); }
373 template<
typename _T1,
typename _T2>
374 inline _GLIBCXX_CONSTEXPR
bool 376 {
return !(__x < __y); }
378 #if __cplusplus >= 201103L 382 template<
typename _T1,
typename _T2>
385 noexcept(noexcept(__x.swap(__y)))
401 #if __cplusplus >= 201103L 403 template<
typename _T1,
typename _T2>
405 typename __decay_and_strip<_T2>::__type>
408 typedef typename __decay_and_strip<_T1>::__type __ds_type1;
409 typedef typename __decay_and_strip<_T2>::__type __ds_type2;
411 return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
414 template<
typename _T1,
typename _T2>
422 _GLIBCXX_END_NAMESPACE_VERSION
constexpr pair()
second is a copy of the second object
constexpr pair(const pair< _U1, _U2 > &__p)
constexpr pair(const _T1 &__a, const _T2 &__b)
constexpr piecewise_construct_t piecewise_construct
piecewise_construct
ISO C++ entities toplevel namespace is std.
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.
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