2 //===--------------------------- tuple ------------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
24 explicit tuple(const T&...); // constexpr in C++14
26 explicit tuple(U&&...); // constexpr in C++14
27 tuple(const tuple&) = default;
28 tuple(tuple&&) = default;
30 tuple(const tuple<U...>&); // constexpr in C++14
32 tuple(tuple<U...>&&); // constexpr in C++14
33 template <class U1, class U2>
34 tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
35 template <class U1, class U2>
36 tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
38 // allocator-extended constructors
39 template <class Alloc>
40 tuple(allocator_arg_t, const Alloc& a);
41 template <class Alloc>
42 tuple(allocator_arg_t, const Alloc& a, const T&...);
43 template <class Alloc, class... U>
44 tuple(allocator_arg_t, const Alloc& a, U&&...);
45 template <class Alloc>
46 tuple(allocator_arg_t, const Alloc& a, const tuple&);
47 template <class Alloc>
48 tuple(allocator_arg_t, const Alloc& a, tuple&&);
49 template <class Alloc, class... U>
50 tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
51 template <class Alloc, class... U>
52 tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
53 template <class Alloc, class U1, class U2>
54 tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
55 template <class Alloc, class U1, class U2>
56 tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
58 tuple& operator=(const tuple&);
60 operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
62 tuple& operator=(const tuple<U...>&);
64 tuple& operator=(tuple<U...>&&);
65 template <class U1, class U2>
66 tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
67 template <class U1, class U2>
68 tuple& operator=(pair<U1, U2>&&); //iffsizeof...(T) == 2
70 void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
73 const unspecified ignore;
75 template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
76 template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
77 template <class... T> tuple<T&...> tie(T&...) noexcept;
78 template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
80 // 20.4.1.4, tuple helper classes:
81 template <class T> class tuple_size; // undefined
82 template <class... T> class tuple_size<tuple<T...>>;
83 template <intsize_t I, class T> class tuple_element; // undefined
84 template <intsize_t I, class... T> class tuple_element<I, tuple<T...>>;
86 // 20.4.1.5, element access:
87 template <intsize_t I, class... T>
88 typename tuple_element<I, tuple<T...>>::type&
89 get(tuple<T...>&) noexcept; // constexpr in C++14
90 template <intsize_t I, class... T>
91 typename tuple_element<I, tuple<T...>>::type const&
92 get(const tuple<T...>&) noexcept; // constexpr in C++14
93 template <intsize_t I, class... T>
94 typename tuple_element<I, tuple<T...>>::type&&
95 get(tuple<T...>&&) noexcept; // constexpr in C++14
97 template <class T1, class... T>
98 constexpr T1& get(tuple<T...>&) noexcept; // C++14
99 template <class T1, class... T>
100 constexpr T1 const& get(const tuple<T...>&) noexcept; // C++14
101 template <class T1, class... T>
102 constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
104 // 20.4.1.6, relational operators:
105 template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
106 template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
107 template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
108 template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
109 template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
110 template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
112 template <class... Types, class Alloc>
113 struct uses_allocator<tuple<Types...>, Alloc>;
115 template <class... Types>
117 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
126 #include <type_traits>
127 #include <__functional_base>
130 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
131 #pragma GCC system_header
134 _LIBCPP_BEGIN_NAMESPACE_STD
136 #ifndef _LIBCPP_HAS_NO_VARIADICS
140 template <class ..._Tp>
141 class _LIBCPP_TYPE_VIS_ONLY tuple_size<tuple<_Tp...> >
142 : public integral_constant<size_t, sizeof...(_Tp)>
148 template <size_t _Ip, class ..._Tp>
149 class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> >
152 typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
157 template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
158 #if __has_feature(is_final)
164 template <size_t _Ip, class _Hp, bool _Ep>
165 inline _LIBCPP_INLINE_VISIBILITY
166 void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
167 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
169 swap(__x.get(), __y.get());
172 template <size_t _Ip, class _Hp, bool>
177 __tuple_leaf& operator=(const __tuple_leaf&);
179 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
180 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value()
181 {static_assert(!is_reference<_Hp>::value,
182 "Attempted to default construct a reference element in a tuple");}
184 template <class _Alloc>
185 _LIBCPP_INLINE_VISIBILITY
186 __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
188 {static_assert(!is_reference<_Hp>::value,
189 "Attempted to default construct a reference element in a tuple");}
191 template <class _Alloc>
192 _LIBCPP_INLINE_VISIBILITY
193 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
194 : value(allocator_arg_t(), __a)
195 {static_assert(!is_reference<_Hp>::value,
196 "Attempted to default construct a reference element in a tuple");}
198 template <class _Alloc>
199 _LIBCPP_INLINE_VISIBILITY
200 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
202 {static_assert(!is_reference<_Hp>::value,
203 "Attempted to default construct a reference element in a tuple");}
206 class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
207 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
208 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
209 : value(_VSTD::forward<_Tp>(__t))
210 {static_assert(!is_reference<_Hp>::value ||
211 (is_lvalue_reference<_Hp>::value &&
212 (is_lvalue_reference<_Tp>::value ||
213 is_same<typename remove_reference<_Tp>::type,
215 typename remove_reference<_Hp>::type
218 (is_rvalue_reference<_Hp>::value &&
219 !is_lvalue_reference<_Tp>::value),
220 "Attempted to construct a reference element in a tuple with an rvalue");}
222 template <class _Tp, class _Alloc>
223 _LIBCPP_INLINE_VISIBILITY
224 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
225 : value(_VSTD::forward<_Tp>(__t))
226 {static_assert(!is_lvalue_reference<_Hp>::value ||
227 (is_lvalue_reference<_Hp>::value &&
228 (is_lvalue_reference<_Tp>::value ||
229 is_same<typename remove_reference<_Tp>::type,
231 typename remove_reference<_Hp>::type
234 "Attempted to construct a reference element in a tuple with an rvalue");}
236 template <class _Tp, class _Alloc>
237 _LIBCPP_INLINE_VISIBILITY
238 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
239 : value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
240 {static_assert(!is_lvalue_reference<_Hp>::value ||
241 (is_lvalue_reference<_Hp>::value &&
242 (is_lvalue_reference<_Tp>::value ||
243 is_same<typename remove_reference<_Tp>::type,
245 typename remove_reference<_Hp>::type
248 "Attempted to construct a reference element in a tuple with an rvalue");}
250 template <class _Tp, class _Alloc>
251 _LIBCPP_INLINE_VISIBILITY
252 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
253 : value(_VSTD::forward<_Tp>(__t), __a)
254 {static_assert(!is_lvalue_reference<_Hp>::value ||
255 (is_lvalue_reference<_Hp>::value &&
256 (is_lvalue_reference<_Tp>::value ||
257 is_same<typename remove_reference<_Tp>::type,
259 typename remove_reference<_Hp>::type
262 "Attempted to construct a reference element in a tuple with an rvalue");}
264 _LIBCPP_INLINE_VISIBILITY
265 _LIBCPP_CONSTEXPR_AFTER_CXX11
266 __tuple_leaf(const __tuple_leaf& __t) _NOEXCEPT_(is_nothrow_copy_constructible<_Hp>::value)
268 {static_assert(!is_rvalue_reference<_Hp>::value, "Can not copy a tuple with rvalue reference member");}
270 _LIBCPP_INLINE_VISIBILITY
271 _LIBCPP_CONSTEXPR_AFTER_CXX11
272 __tuple_leaf(__tuple_leaf&& __t) _NOEXCEPT_(is_nothrow_move_constructible<_Hp>::value)
273 : value(_VSTD::forward<_Hp>(__t.get()))
277 _LIBCPP_INLINE_VISIBILITY
279 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
281 value = _VSTD::forward<_Tp>(__t);
285 _LIBCPP_INLINE_VISIBILITY
286 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
288 _VSTD::swap(*this, __t);
292 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return value;}
293 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return value;}
296 template <size_t _Ip, class _Hp>
297 class __tuple_leaf<_Ip, _Hp, true>
301 __tuple_leaf& operator=(const __tuple_leaf&);
303 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
304 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
306 template <class _Alloc>
307 _LIBCPP_INLINE_VISIBILITY
308 __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
310 template <class _Alloc>
311 _LIBCPP_INLINE_VISIBILITY
312 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
313 : _Hp(allocator_arg_t(), __a) {}
315 template <class _Alloc>
316 _LIBCPP_INLINE_VISIBILITY
317 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
321 class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
322 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
323 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
324 : _Hp(_VSTD::forward<_Tp>(__t)) {}
326 template <class _Tp, class _Alloc>
327 _LIBCPP_INLINE_VISIBILITY
328 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
329 : _Hp(_VSTD::forward<_Tp>(__t)) {}
331 template <class _Tp, class _Alloc>
332 _LIBCPP_INLINE_VISIBILITY
333 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
334 : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
336 template <class _Tp, class _Alloc>
337 _LIBCPP_INLINE_VISIBILITY
338 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
339 : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
342 _LIBCPP_INLINE_VISIBILITY
344 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
346 _Hp::operator=(_VSTD::forward<_Tp>(__t));
350 _LIBCPP_INLINE_VISIBILITY
352 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
354 _VSTD::swap(*this, __t);
358 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
359 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
362 template <class ..._Tp>
363 _LIBCPP_INLINE_VISIBILITY
364 void __swallow(_Tp&&...) _NOEXCEPT {}
366 template <bool ...> struct __all;
371 static const bool value = true;
374 template <bool _B0, bool ... _Bp>
375 struct __all<_B0, _Bp...>
377 static const bool value = _B0 && __all<_Bp...>::value;
382 template<class _Indx, class ..._Tp> struct __tuple_impl;
384 template<size_t ..._Indx, class ..._Tp>
385 struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
386 : public __tuple_leaf<_Indx, _Tp>...
388 _LIBCPP_INLINE_VISIBILITY
389 _LIBCPP_CONSTEXPR __tuple_impl()
390 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
392 template <size_t ..._Uf, class ..._Tf,
393 size_t ..._Ul, class ..._Tl, class ..._Up>
394 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
396 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
397 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
399 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
400 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
401 __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
402 __tuple_leaf<_Ul, _Tl>()...
405 template <class _Alloc, size_t ..._Uf, class ..._Tf,
406 size_t ..._Ul, class ..._Tl, class ..._Up>
407 _LIBCPP_INLINE_VISIBILITY
409 __tuple_impl(allocator_arg_t, const _Alloc& __a,
410 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
411 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
413 __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
414 _VSTD::forward<_Up>(__u))...,
415 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
418 template <class _Tuple,
419 class = typename enable_if
421 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
424 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
425 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
426 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
427 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
428 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
431 template <class _Alloc, class _Tuple,
432 class = typename enable_if
434 __tuple_convertible<_Tuple, tuple<_Tp...> >::value
437 _LIBCPP_INLINE_VISIBILITY
438 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
439 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
440 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
441 _VSTD::forward<typename tuple_element<_Indx,
442 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
445 template <class _Tuple>
446 _LIBCPP_INLINE_VISIBILITY
449 __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
452 operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
453 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
455 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
456 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
460 __tuple_impl(const __tuple_impl&) = default;
461 __tuple_impl(__tuple_impl&&) = default;
463 _LIBCPP_INLINE_VISIBILITY
465 operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
467 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
471 _LIBCPP_INLINE_VISIBILITY
473 operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
475 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
479 _LIBCPP_INLINE_VISIBILITY
480 void swap(__tuple_impl& __t)
481 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
483 __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
487 template <class ..._Tp>
488 class _LIBCPP_TYPE_VIS_ONLY tuple
490 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
494 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
495 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
496 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
497 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
498 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
499 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
502 _LIBCPP_INLINE_VISIBILITY
503 _LIBCPP_CONSTEXPR tuple()
504 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
506 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
507 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
508 : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
509 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
510 typename __make_tuple_indices<0>::type(),
511 typename __make_tuple_types<tuple, 0>::type(),
515 template <class _Alloc>
516 _LIBCPP_INLINE_VISIBILITY
517 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
518 : base_(allocator_arg_t(), __a,
519 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
520 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
521 typename __make_tuple_indices<0>::type(),
522 typename __make_tuple_types<tuple, 0>::type(),
526 template <class ..._Up,
529 sizeof...(_Up) <= sizeof...(_Tp) &&
533 typename __make_tuple_types<tuple,
534 sizeof...(_Up) < sizeof...(_Tp) ?
536 sizeof...(_Tp)>::type
541 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
544 is_nothrow_constructible<
545 typename __make_tuple_indices<sizeof...(_Up)>::type,
546 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
547 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
548 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
552 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
553 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
554 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
555 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
556 _VSTD::forward<_Up>(__u)...) {}
558 template <class ..._Up,
561 sizeof...(_Up) <= sizeof...(_Tp) &&
562 __tuple_constructible
565 typename __make_tuple_types<tuple,
566 sizeof...(_Up) < sizeof...(_Tp) ?
568 sizeof...(_Tp)>::type
573 typename __make_tuple_types<tuple,
574 sizeof...(_Up) < sizeof...(_Tp) ?
576 sizeof...(_Tp)>::type
581 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
585 is_nothrow_constructible<
586 typename __make_tuple_indices<sizeof...(_Up)>::type,
587 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
588 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
589 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
593 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
594 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
595 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
596 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
597 _VSTD::forward<_Up>(__u)...) {}
599 template <class _Alloc, class ..._Up,
600 class = typename enable_if
602 sizeof...(_Up) <= sizeof...(_Tp) &&
606 typename __make_tuple_types<tuple,
607 sizeof...(_Up) < sizeof...(_Tp) ?
609 sizeof...(_Tp)>::type
613 _LIBCPP_INLINE_VISIBILITY
614 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
615 : base_(allocator_arg_t(), __a,
616 typename __make_tuple_indices<sizeof...(_Up)>::type(),
617 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
618 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
619 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
620 _VSTD::forward<_Up>(__u)...) {}
622 template <class _Tuple,
625 __tuple_convertible<_Tuple, tuple>::value,
629 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
630 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
631 : base_(_VSTD::forward<_Tuple>(__t)) {}
633 template <class _Tuple,
636 __tuple_constructible<_Tuple, tuple>::value &&
637 !__tuple_convertible<_Tuple, tuple>::value,
641 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
643 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
644 : base_(_VSTD::forward<_Tuple>(__t)) {}
646 template <class _Alloc, class _Tuple,
647 class = typename enable_if
649 __tuple_convertible<_Tuple, tuple>::value
652 _LIBCPP_INLINE_VISIBILITY
653 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
654 : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
656 template <class _Tuple,
657 class = typename enable_if
659 __tuple_assignable<_Tuple, tuple>::value
662 _LIBCPP_INLINE_VISIBILITY
664 operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value))
666 base_.operator=(_VSTD::forward<_Tuple>(__t));
670 _LIBCPP_INLINE_VISIBILITY
671 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
672 {base_.swap(__t.base_);}
676 class _LIBCPP_TYPE_VIS_ONLY tuple<>
679 _LIBCPP_INLINE_VISIBILITY
680 _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
681 template <class _Alloc>
682 _LIBCPP_INLINE_VISIBILITY
683 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
684 template <class _Alloc>
685 _LIBCPP_INLINE_VISIBILITY
686 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
688 _LIBCPP_INLINE_VISIBILITY
689 tuple(array<_Up, 0>) _NOEXCEPT {}
690 template <class _Alloc, class _Up>
691 _LIBCPP_INLINE_VISIBILITY
692 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
693 _LIBCPP_INLINE_VISIBILITY
694 void swap(tuple&) _NOEXCEPT {}
697 template <class ..._Tp>
698 inline _LIBCPP_INLINE_VISIBILITY
701 __all<__is_swappable<_Tp>::value...>::value,
704 swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
705 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
710 template <size_t _Ip, class ..._Tp>
711 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
712 typename tuple_element<_Ip, tuple<_Tp...> >::type&
713 get(tuple<_Tp...>& __t) _NOEXCEPT
715 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
716 return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get();
719 template <size_t _Ip, class ..._Tp>
720 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
721 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
722 get(const tuple<_Tp...>& __t) _NOEXCEPT
724 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
725 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
728 template <size_t _Ip, class ..._Tp>
729 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
730 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
731 get(tuple<_Tp...>&& __t) _NOEXCEPT
733 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
734 return static_cast<type&&>(
735 static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
738 #if _LIBCPP_STD_VER > 11
740 template <typename _T1, size_t _Idx, typename... _Args>
741 struct __find_exactly_one_t_helper;
743 // -- find exactly one
744 template <typename _T1, size_t _Idx, typename... _Args>
745 struct __find_exactly_one_t_checker {
746 static constexpr size_t value = _Idx;
747 // Check the rest of the list to make sure there's only one
748 static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" );
752 template <typename _T1, size_t _Idx>
753 struct __find_exactly_one_t_helper <_T1, _Idx> {
754 static constexpr size_t value = -1;
757 template <typename _T1, size_t _Idx, typename _Head, typename... _Args>
758 struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> {
759 static constexpr size_t value =
761 std::is_same<_T1, _Head>::value,
762 __find_exactly_one_t_checker<_T1, _Idx, _Args...>,
763 __find_exactly_one_t_helper <_T1, _Idx+1, _Args...>
767 template <typename _T1, typename... _Args>
768 struct __find_exactly_one_t {
769 static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value;
770 static_assert ( value != -1, "type not found in type list" );
773 template <class _T1, class... _Args>
774 inline _LIBCPP_INLINE_VISIBILITY
775 constexpr _T1& get(tuple<_Args...>& __tup) noexcept
777 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
780 template <class _T1, class... _Args>
781 inline _LIBCPP_INLINE_VISIBILITY
782 constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
784 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
787 template <class _T1, class... _Args>
788 inline _LIBCPP_INLINE_VISIBILITY
789 constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
791 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
798 template <class ..._Tp>
799 inline _LIBCPP_INLINE_VISIBILITY
801 tie(_Tp&... __t) _NOEXCEPT
803 return tuple<_Tp&...>(__t...);
810 _LIBCPP_INLINE_VISIBILITY
811 const __ignore_t& operator=(_Tp&&) const {return *this;}
814 namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
816 template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
819 struct ___make_tuple_return
825 struct ___make_tuple_return<reference_wrapper<_Tp> >
831 struct __make_tuple_return
833 typedef typename ___make_tuple_return<typename decay<_Tp>::type>::type type;
836 template <class... _Tp>
837 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
838 tuple<typename __make_tuple_return<_Tp>::type...>
839 make_tuple(_Tp&&... __t)
841 return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
844 template <class... _Tp>
845 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
847 forward_as_tuple(_Tp&&... __t) _NOEXCEPT
849 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
852 template <size_t _Ip>
855 template <class _Tp, class _Up>
856 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
857 bool operator()(const _Tp& __x, const _Up& __y)
859 return __tuple_equal<_Ip - 1>()(__x, __y) && get<_Ip-1>(__x) == get<_Ip-1>(__y);
864 struct __tuple_equal<0>
866 template <class _Tp, class _Up>
867 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
868 bool operator()(const _Tp&, const _Up&)
874 template <class ..._Tp, class ..._Up>
875 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
877 operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
879 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
882 template <class ..._Tp, class ..._Up>
883 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
885 operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
887 return !(__x == __y);
890 template <size_t _Ip>
893 template <class _Tp, class _Up>
894 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
895 bool operator()(const _Tp& __x, const _Up& __y)
897 return __tuple_less<_Ip-1>()(__x, __y) ||
898 (!__tuple_less<_Ip-1>()(__y, __x) && get<_Ip-1>(__x) < get<_Ip-1>(__y));
903 struct __tuple_less<0>
905 template <class _Tp, class _Up>
906 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
907 bool operator()(const _Tp&, const _Up&)
913 template <class ..._Tp, class ..._Up>
914 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
916 operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
918 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
921 template <class ..._Tp, class ..._Up>
922 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
924 operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
929 template <class ..._Tp, class ..._Up>
930 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
932 operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
937 template <class ..._Tp, class ..._Up>
938 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
940 operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
947 template <class _Tp, class _Up> struct __tuple_cat_type;
949 template <class ..._Ttypes, class ..._Utypes>
950 struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
952 typedef tuple<_Ttypes..., _Utypes...> type;
955 template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
956 struct __tuple_cat_return_1
960 template <class ..._Types, class _Tuple0>
961 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
963 typedef typename __tuple_cat_type<tuple<_Types...>,
964 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
968 template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
969 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
970 : public __tuple_cat_return_1<
971 typename __tuple_cat_type<
973 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
975 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
980 template <class ..._Tuples> struct __tuple_cat_return;
982 template <class _Tuple0, class ..._Tuples>
983 struct __tuple_cat_return<_Tuple0, _Tuples...>
984 : public __tuple_cat_return_1<tuple<>,
985 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
991 struct __tuple_cat_return<>
993 typedef tuple<> type;
996 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1003 template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
1004 struct __tuple_cat_return_ref_imp;
1006 template <class ..._Types, size_t ..._I0, class _Tuple0>
1007 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
1009 typedef typename remove_reference<_Tuple0>::type _T0;
1010 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1011 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1014 template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1015 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1016 _Tuple0, _Tuple1, _Tuples...>
1017 : public __tuple_cat_return_ref_imp<
1018 tuple<_Types..., typename __apply_cv<_Tuple0,
1019 typename tuple_element<_I0,
1020 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1021 typename __make_tuple_indices<tuple_size<typename
1022 remove_reference<_Tuple1>::type>::value>::type,
1023 _Tuple1, _Tuples...>
1027 template <class _Tuple0, class ..._Tuples>
1028 struct __tuple_cat_return_ref
1029 : public __tuple_cat_return_ref_imp<tuple<>,
1030 typename __make_tuple_indices<
1031 tuple_size<typename remove_reference<_Tuple0>::type>::value
1032 >::type, _Tuple0, _Tuples...>
1036 template <class _Types, class _I0, class _J0>
1039 template <class ..._Types, size_t ..._I0, size_t ..._J0>
1040 struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
1042 template <class _Tuple0>
1043 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1044 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1045 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1047 return forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))...,
1048 get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
1051 template <class _Tuple0, class _Tuple1, class ..._Tuples>
1052 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1053 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1054 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1056 typedef typename remove_reference<_Tuple0>::type _T0;
1057 typedef typename remove_reference<_Tuple1>::type _T1;
1059 tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1060 typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1061 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
1063 _VSTD::forward<_Types>(get<_I0>(__t))...,
1064 get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
1066 _VSTD::forward<_Tuple1>(__t1),
1067 _VSTD::forward<_Tuples>(__tpls)...);
1071 template <class _Tuple0, class... _Tuples>
1072 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1073 typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1074 tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1076 typedef typename remove_reference<_Tuple0>::type _T0;
1077 return __tuple_cat<tuple<>, __tuple_indices<>,
1078 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
1079 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1080 _VSTD::forward<_Tuples>(__tpls)...);
1083 template <class ..._Tp, class _Alloc>
1084 struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc>
1087 template <class _T1, class _T2>
1088 template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1089 inline _LIBCPP_INLINE_VISIBILITY
1090 pair<_T1, _T2>::pair(piecewise_construct_t,
1091 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1092 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
1093 : first(_VSTD::forward<_Args1>(get<_I1>( __first_args))...),
1094 second(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
1098 #endif // _LIBCPP_HAS_NO_VARIADICS
1100 _LIBCPP_END_NAMESPACE_STD
1102 #endif // _LIBCPP_TUPLE