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&...);
26 explicit tuple(U&&...);
27 tuple(const tuple&) = default;
28 tuple(tuple&&) = default;
30 tuple(const tuple<U...>&);
33 template <class U1, class U2>
34 tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2
35 template <class U1, class U2>
36 tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2
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&&...);
76 template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept;
77 template <class... T> tuple<T&...> tie(T&...) noexcept;
78 template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls);
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;
90 template <intsize_t I, class... T>
91 typename tuple_element<I, tuple<T...>>::type const&
92 get(const tuple<T...>&) noexcept;
93 template <intsize_t I, class... T>
94 typename tuple_element<I, tuple<T...>>::type&&
95 get(tuple<T...>&&) noexcept;
97 // 20.4.1.6, relational operators:
98 template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&);
99 template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&);
100 template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&);
101 template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&);
102 template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&);
103 template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&);
105 template <class... Types, class Alloc>
106 struct uses_allocator<tuple<Types...>, Alloc>;
108 template <class... Types>
110 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
119 #include <type_traits>
120 #include <__functional_base>
123 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
124 #pragma GCC system_header
127 _LIBCPP_BEGIN_NAMESPACE_STD
131 struct _LIBCPP_TYPE_VIS allocator_arg_t { };
133 #if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY)
134 extern const allocator_arg_t allocator_arg;
136 constexpr allocator_arg_t allocator_arg = allocator_arg_t();
142 struct __has_allocator_type
145 struct __two {char __lx; char __lxx;};
146 template <class _Up> static __two __test(...);
147 template <class _Up> static char __test(typename _Up::allocator_type* = 0);
149 static const bool value = sizeof(__test<_Tp>(0)) == 1;
152 template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>
153 struct __uses_allocator
154 : public integral_constant<bool,
155 is_convertible<_Alloc, typename _Tp::allocator_type>::value>
159 template <class _Tp, class _Alloc>
160 struct __uses_allocator<_Tp, _Alloc, false>
165 template <class _Tp, class _Alloc>
166 struct _LIBCPP_TYPE_VIS uses_allocator
167 : public __uses_allocator<_Tp, _Alloc>
171 #ifndef _LIBCPP_HAS_NO_VARIADICS
173 // uses-allocator construction
175 template <class _Tp, class _Alloc, class ..._Args>
176 struct __uses_alloc_ctor_imp
178 static const bool __ua = uses_allocator<_Tp, _Alloc>::value;
179 static const bool __ic =
180 is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
181 static const int value = __ua ? 2 - __ic : 0;
184 template <class _Tp, class _Alloc, class ..._Args>
185 struct __uses_alloc_ctor
186 : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value>
189 #endif // _LIBCPP_HAS_NO_VARIADICS
191 #ifndef _LIBCPP_HAS_NO_VARIADICS
195 template <class ..._Tp>
196 class _LIBCPP_TYPE_VIS tuple_size<tuple<_Tp...> >
197 : public integral_constant<size_t, sizeof...(_Tp)>
203 template <size_t _Ip, class ..._Tp>
204 class _LIBCPP_TYPE_VIS tuple_element<_Ip, tuple<_Tp...> >
207 typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
212 template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
213 #if __has_feature(is_final)
219 template <size_t _Ip, class _Hp, bool _Ep>
220 inline _LIBCPP_INLINE_VISIBILITY
221 void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
222 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
224 swap(__x.get(), __y.get());
227 template <size_t _Ip, class _Hp, bool>
232 __tuple_leaf& operator=(const __tuple_leaf&);
234 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
235 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value()
236 {static_assert(!is_reference<_Hp>::value,
237 "Attempted to default construct a reference element in a tuple");}
239 template <class _Alloc>
240 _LIBCPP_INLINE_VISIBILITY
241 __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
243 {static_assert(!is_reference<_Hp>::value,
244 "Attempted to default construct a reference element in a tuple");}
246 template <class _Alloc>
247 _LIBCPP_INLINE_VISIBILITY
248 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
249 : value(allocator_arg_t(), __a)
250 {static_assert(!is_reference<_Hp>::value,
251 "Attempted to default construct a reference element in a tuple");}
253 template <class _Alloc>
254 _LIBCPP_INLINE_VISIBILITY
255 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
257 {static_assert(!is_reference<_Hp>::value,
258 "Attempted to default construct a reference element in a tuple");}
261 class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
262 _LIBCPP_INLINE_VISIBILITY
263 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
264 : value(_VSTD::forward<_Tp>(__t))
265 {static_assert(!is_reference<_Hp>::value ||
266 (is_lvalue_reference<_Hp>::value &&
267 (is_lvalue_reference<_Tp>::value ||
268 is_same<typename remove_reference<_Tp>::type,
270 typename remove_reference<_Hp>::type
273 (is_rvalue_reference<_Hp>::value &&
274 !is_lvalue_reference<_Tp>::value),
275 "Attempted to construct a reference element in a tuple with an rvalue");}
277 template <class _Tp, class _Alloc>
278 _LIBCPP_INLINE_VISIBILITY
279 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
280 : value(_VSTD::forward<_Tp>(__t))
281 {static_assert(!is_lvalue_reference<_Hp>::value ||
282 (is_lvalue_reference<_Hp>::value &&
283 (is_lvalue_reference<_Tp>::value ||
284 is_same<typename remove_reference<_Tp>::type,
286 typename remove_reference<_Hp>::type
289 "Attempted to construct a reference element in a tuple with an rvalue");}
291 template <class _Tp, class _Alloc>
292 _LIBCPP_INLINE_VISIBILITY
293 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
294 : value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
295 {static_assert(!is_lvalue_reference<_Hp>::value ||
296 (is_lvalue_reference<_Hp>::value &&
297 (is_lvalue_reference<_Tp>::value ||
298 is_same<typename remove_reference<_Tp>::type,
300 typename remove_reference<_Hp>::type
303 "Attempted to construct a reference element in a tuple with an rvalue");}
305 template <class _Tp, class _Alloc>
306 _LIBCPP_INLINE_VISIBILITY
307 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
308 : value(_VSTD::forward<_Tp>(__t), __a)
309 {static_assert(!is_lvalue_reference<_Hp>::value ||
310 (is_lvalue_reference<_Hp>::value &&
311 (is_lvalue_reference<_Tp>::value ||
312 is_same<typename remove_reference<_Tp>::type,
314 typename remove_reference<_Hp>::type
317 "Attempted to construct a reference element in a tuple with an rvalue");}
319 __tuple_leaf(const __tuple_leaf& __t) _NOEXCEPT_(is_nothrow_copy_constructible<_Hp>::value)
321 {static_assert(!is_rvalue_reference<_Hp>::value, "Can not copy a tuple with rvalue reference member");}
324 _LIBCPP_INLINE_VISIBILITY
325 explicit __tuple_leaf(const __tuple_leaf<_Ip, _Tp>& __t)
326 _NOEXCEPT_((is_nothrow_constructible<_Hp, const _Tp&>::value))
327 : value(__t.get()) {}
330 _LIBCPP_INLINE_VISIBILITY
332 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
334 value = _VSTD::forward<_Tp>(__t);
338 _LIBCPP_INLINE_VISIBILITY
339 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
341 _VSTD::swap(*this, __t);
345 _LIBCPP_INLINE_VISIBILITY _Hp& get() _NOEXCEPT {return value;}
346 _LIBCPP_INLINE_VISIBILITY const _Hp& get() const _NOEXCEPT {return value;}
349 template <size_t _Ip, class _Hp>
350 class __tuple_leaf<_Ip, _Hp, true>
354 __tuple_leaf& operator=(const __tuple_leaf&);
356 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
357 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
359 template <class _Alloc>
360 _LIBCPP_INLINE_VISIBILITY
361 __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
363 template <class _Alloc>
364 _LIBCPP_INLINE_VISIBILITY
365 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
366 : _Hp(allocator_arg_t(), __a) {}
368 template <class _Alloc>
369 _LIBCPP_INLINE_VISIBILITY
370 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
374 class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
375 _LIBCPP_INLINE_VISIBILITY
376 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
377 : _Hp(_VSTD::forward<_Tp>(__t)) {}
379 template <class _Tp, class _Alloc>
380 _LIBCPP_INLINE_VISIBILITY
381 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
382 : _Hp(_VSTD::forward<_Tp>(__t)) {}
384 template <class _Tp, class _Alloc>
385 _LIBCPP_INLINE_VISIBILITY
386 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
387 : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
389 template <class _Tp, class _Alloc>
390 _LIBCPP_INLINE_VISIBILITY
391 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
392 : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
395 _LIBCPP_INLINE_VISIBILITY
396 explicit __tuple_leaf(const __tuple_leaf<_Ip, _Tp>& __t)
397 _NOEXCEPT_((is_nothrow_constructible<_Hp, const _Tp&>::value))
401 _LIBCPP_INLINE_VISIBILITY
403 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
405 _Hp::operator=(_VSTD::forward<_Tp>(__t));
409 _LIBCPP_INLINE_VISIBILITY
411 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
413 _VSTD::swap(*this, __t);
417 _LIBCPP_INLINE_VISIBILITY _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
418 _LIBCPP_INLINE_VISIBILITY const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
421 template <class ..._Tp>
422 _LIBCPP_INLINE_VISIBILITY
423 void __swallow(_Tp&&...) _NOEXCEPT {}
425 template <bool ...> struct __all;
430 static const bool value = true;
433 template <bool _B0, bool ... _Bp>
434 struct __all<_B0, _Bp...>
436 static const bool value = _B0 && __all<_Bp...>::value;
441 template<class _Indx, class ..._Tp> struct __tuple_impl;
443 template<size_t ..._Indx, class ..._Tp>
444 struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
445 : public __tuple_leaf<_Indx, _Tp>...
447 _LIBCPP_INLINE_VISIBILITY
448 _LIBCPP_CONSTEXPR __tuple_impl()
449 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
451 template <size_t ..._Uf, class ..._Tf,
452 size_t ..._Ul, class ..._Tl, class ..._Up>
453 _LIBCPP_INLINE_VISIBILITY
455 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
456 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
458 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
459 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
460 __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
461 __tuple_leaf<_Ul, _Tl>()...
464 template <class _Alloc, size_t ..._Uf, class ..._Tf,
465 size_t ..._Ul, class ..._Tl, class ..._Up>
466 _LIBCPP_INLINE_VISIBILITY
468 __tuple_impl(allocator_arg_t, const _Alloc& __a,
469 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
470 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
472 __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
473 _VSTD::forward<_Up>(__u))...,
474 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
477 template <class _Tuple,
478 class = typename enable_if
480 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
483 _LIBCPP_INLINE_VISIBILITY
484 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
485 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
486 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
487 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
490 template <class _Alloc, class _Tuple,
491 class = typename enable_if
493 __tuple_convertible<_Tuple, tuple<_Tp...> >::value
496 _LIBCPP_INLINE_VISIBILITY
497 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
498 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
499 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
500 _VSTD::forward<typename tuple_element<_Indx,
501 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
504 template <class _Tuple>
505 _LIBCPP_INLINE_VISIBILITY
508 __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
511 operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
512 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
514 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
515 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
519 _LIBCPP_INLINE_VISIBILITY
521 operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
523 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
527 _LIBCPP_INLINE_VISIBILITY
528 void swap(__tuple_impl& __t)
529 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
531 __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
535 template <class ..._Tp>
536 class _LIBCPP_TYPE_VIS tuple
538 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
542 template <size_t _Jp, class ..._Up> friend
543 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
544 template <size_t _Jp, class ..._Up> friend
545 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
546 template <size_t _Jp, class ..._Up> friend
547 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
550 _LIBCPP_INLINE_VISIBILITY
551 _LIBCPP_CONSTEXPR tuple()
552 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
554 _LIBCPP_INLINE_VISIBILITY
555 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
556 : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
557 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
558 typename __make_tuple_indices<0>::type(),
559 typename __make_tuple_types<tuple, 0>::type(),
563 template <class _Alloc>
564 _LIBCPP_INLINE_VISIBILITY
565 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
566 : base_(allocator_arg_t(), __a,
567 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
568 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
569 typename __make_tuple_indices<0>::type(),
570 typename __make_tuple_types<tuple, 0>::type(),
574 template <class ..._Up,
577 sizeof...(_Up) <= sizeof...(_Tp) &&
581 typename __make_tuple_types<tuple,
582 sizeof...(_Up) < sizeof...(_Tp) ?
584 sizeof...(_Tp)>::type
589 _LIBCPP_INLINE_VISIBILITY
592 is_nothrow_constructible<
593 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,
600 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
601 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
602 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
603 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
604 _VSTD::forward<_Up>(__u)...) {}
606 template <class ..._Up,
609 sizeof...(_Up) <= sizeof...(_Tp) &&
610 __tuple_constructible
613 typename __make_tuple_types<tuple,
614 sizeof...(_Up) < sizeof...(_Tp) ?
616 sizeof...(_Tp)>::type
621 typename __make_tuple_types<tuple,
622 sizeof...(_Up) < sizeof...(_Tp) ?
624 sizeof...(_Tp)>::type
629 _LIBCPP_INLINE_VISIBILITY
633 is_nothrow_constructible<
634 typename __make_tuple_indices<sizeof...(_Up)>::type,
635 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
636 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
637 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
641 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
642 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
643 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
644 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
645 _VSTD::forward<_Up>(__u)...) {}
647 template <class _Alloc, class ..._Up,
648 class = typename enable_if
650 sizeof...(_Up) <= sizeof...(_Tp) &&
654 typename __make_tuple_types<tuple,
655 sizeof...(_Up) < sizeof...(_Tp) ?
657 sizeof...(_Tp)>::type
661 _LIBCPP_INLINE_VISIBILITY
662 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
663 : base_(allocator_arg_t(), __a,
664 typename __make_tuple_indices<sizeof...(_Up)>::type(),
665 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
666 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
667 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
668 _VSTD::forward<_Up>(__u)...) {}
670 template <class _Tuple,
673 __tuple_convertible<_Tuple, tuple>::value,
677 _LIBCPP_INLINE_VISIBILITY
678 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
679 : base_(_VSTD::forward<_Tuple>(__t)) {}
681 template <class _Tuple,
684 __tuple_constructible<_Tuple, tuple>::value &&
685 !__tuple_convertible<_Tuple, tuple>::value,
689 _LIBCPP_INLINE_VISIBILITY
691 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
692 : base_(_VSTD::forward<_Tuple>(__t)) {}
694 template <class _Alloc, class _Tuple,
695 class = typename enable_if
697 __tuple_convertible<_Tuple, tuple>::value
700 _LIBCPP_INLINE_VISIBILITY
701 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
702 : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
704 template <class _Tuple,
705 class = typename enable_if
707 __tuple_assignable<_Tuple, tuple>::value
710 _LIBCPP_INLINE_VISIBILITY
712 operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value))
714 base_.operator=(_VSTD::forward<_Tuple>(__t));
718 _LIBCPP_INLINE_VISIBILITY
719 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
720 {base_.swap(__t.base_);}
724 class _LIBCPP_TYPE_VIS tuple<>
727 _LIBCPP_INLINE_VISIBILITY
728 _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
729 template <class _Alloc>
730 _LIBCPP_INLINE_VISIBILITY
731 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
732 template <class _Alloc>
733 _LIBCPP_INLINE_VISIBILITY
734 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
736 _LIBCPP_INLINE_VISIBILITY
737 tuple(array<_Up, 0>) _NOEXCEPT {}
738 template <class _Alloc, class _Up>
739 _LIBCPP_INLINE_VISIBILITY
740 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
741 _LIBCPP_INLINE_VISIBILITY
742 void swap(tuple&) _NOEXCEPT {}
745 template <class ..._Tp>
746 inline _LIBCPP_INLINE_VISIBILITY
749 __all<__is_swappable<_Tp>::value...>::value,
752 swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
753 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
758 template <size_t _Ip, class ..._Tp>
759 inline _LIBCPP_INLINE_VISIBILITY
760 typename tuple_element<_Ip, tuple<_Tp...> >::type&
761 get(tuple<_Tp...>& __t) _NOEXCEPT
763 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
764 return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get();
767 template <size_t _Ip, class ..._Tp>
768 inline _LIBCPP_INLINE_VISIBILITY
769 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
770 get(const tuple<_Tp...>& __t) _NOEXCEPT
772 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
773 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
776 template <size_t _Ip, class ..._Tp>
777 inline _LIBCPP_INLINE_VISIBILITY
778 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
779 get(tuple<_Tp...>&& __t) _NOEXCEPT
781 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
782 return static_cast<type&&>(
783 static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
788 template <class ..._Tp>
789 inline _LIBCPP_INLINE_VISIBILITY
791 tie(_Tp&... __t) _NOEXCEPT
793 return tuple<_Tp&...>(__t...);
800 _LIBCPP_INLINE_VISIBILITY
801 const __ignore_t& operator=(_Tp&&) const {return *this;}
804 namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
806 template <class _Tp> class _LIBCPP_TYPE_VIS reference_wrapper;
809 struct ___make_tuple_return
815 struct ___make_tuple_return<reference_wrapper<_Tp> >
821 struct __make_tuple_return
823 typedef typename ___make_tuple_return<typename decay<_Tp>::type>::type type;
826 template <class... _Tp>
827 inline _LIBCPP_INLINE_VISIBILITY
828 tuple<typename __make_tuple_return<_Tp>::type...>
829 make_tuple(_Tp&&... __t)
831 return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
834 template <class... _Tp>
835 inline _LIBCPP_INLINE_VISIBILITY
837 forward_as_tuple(_Tp&&... __t) _NOEXCEPT
839 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
842 template <size_t _Ip>
845 template <class _Tp, class _Up>
846 _LIBCPP_INLINE_VISIBILITY
847 bool operator()(const _Tp& __x, const _Up& __y)
849 return __tuple_equal<_Ip - 1>()(__x, __y) && get<_Ip-1>(__x) == get<_Ip-1>(__y);
854 struct __tuple_equal<0>
856 template <class _Tp, class _Up>
857 _LIBCPP_INLINE_VISIBILITY
858 bool operator()(const _Tp&, const _Up&)
864 template <class ..._Tp, class ..._Up>
865 inline _LIBCPP_INLINE_VISIBILITY
867 operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
869 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
872 template <class ..._Tp, class ..._Up>
873 inline _LIBCPP_INLINE_VISIBILITY
875 operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
877 return !(__x == __y);
880 template <size_t _Ip>
883 template <class _Tp, class _Up>
884 _LIBCPP_INLINE_VISIBILITY
885 bool operator()(const _Tp& __x, const _Up& __y)
887 return __tuple_less<_Ip-1>()(__x, __y) ||
888 (!__tuple_less<_Ip-1>()(__y, __x) && get<_Ip-1>(__x) < get<_Ip-1>(__y));
893 struct __tuple_less<0>
895 template <class _Tp, class _Up>
896 _LIBCPP_INLINE_VISIBILITY
897 bool operator()(const _Tp&, const _Up&)
903 template <class ..._Tp, class ..._Up>
904 inline _LIBCPP_INLINE_VISIBILITY
906 operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
908 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
911 template <class ..._Tp, class ..._Up>
912 inline _LIBCPP_INLINE_VISIBILITY
914 operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
919 template <class ..._Tp, class ..._Up>
920 inline _LIBCPP_INLINE_VISIBILITY
922 operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
927 template <class ..._Tp, class ..._Up>
928 inline _LIBCPP_INLINE_VISIBILITY
930 operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
937 template <class _Tp, class _Up> struct __tuple_cat_type;
939 template <class ..._Ttypes, class ..._Utypes>
940 struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
942 typedef tuple<_Ttypes..., _Utypes...> type;
945 template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
946 struct __tuple_cat_return_1
950 template <class ..._Types, class _Tuple0>
951 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
953 typedef typename __tuple_cat_type<tuple<_Types...>,
954 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
958 template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
959 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
960 : public __tuple_cat_return_1<
961 typename __tuple_cat_type<
963 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
965 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
970 template <class ..._Tuples> struct __tuple_cat_return;
972 template <class _Tuple0, class ..._Tuples>
973 struct __tuple_cat_return<_Tuple0, _Tuples...>
974 : public __tuple_cat_return_1<tuple<>,
975 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
981 struct __tuple_cat_return<>
983 typedef tuple<> type;
986 inline _LIBCPP_INLINE_VISIBILITY
993 template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
994 struct __tuple_cat_return_ref_imp;
996 template <class ..._Types, size_t ..._I0, class _Tuple0>
997 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
999 typedef typename remove_reference<_Tuple0>::type _T0;
1000 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1001 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1004 template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1005 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1006 _Tuple0, _Tuple1, _Tuples...>
1007 : public __tuple_cat_return_ref_imp<
1008 tuple<_Types..., typename __apply_cv<_Tuple0,
1009 typename tuple_element<_I0,
1010 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1011 typename __make_tuple_indices<tuple_size<typename
1012 remove_reference<_Tuple1>::type>::value>::type,
1013 _Tuple1, _Tuples...>
1017 template <class _Tuple0, class ..._Tuples>
1018 struct __tuple_cat_return_ref
1019 : public __tuple_cat_return_ref_imp<tuple<>,
1020 typename __make_tuple_indices<
1021 tuple_size<typename remove_reference<_Tuple0>::type>::value
1022 >::type, _Tuple0, _Tuples...>
1026 template <class _Types, class _I0, class _J0>
1029 template <class ..._Types, size_t ..._I0, size_t ..._J0>
1030 struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
1032 template <class _Tuple0>
1033 _LIBCPP_INLINE_VISIBILITY
1034 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1035 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1037 return _VSTD::forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))...,
1038 get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
1041 template <class _Tuple0, class _Tuple1, class ..._Tuples>
1042 _LIBCPP_INLINE_VISIBILITY
1043 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1044 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1046 typedef typename remove_reference<_Tuple0>::type _T0;
1047 typedef typename remove_reference<_Tuple1>::type _T1;
1049 tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1050 typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1051 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
1052 (_VSTD::forward_as_tuple(
1053 _VSTD::forward<_Types>(get<_I0>(__t))...,
1054 get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
1056 _VSTD::forward<_Tuple1>(__t1),
1057 _VSTD::forward<_Tuples>(__tpls)...);
1061 template <class _Tuple0, class... _Tuples>
1062 inline _LIBCPP_INLINE_VISIBILITY
1063 typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1064 tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1066 typedef typename remove_reference<_Tuple0>::type _T0;
1067 return __tuple_cat<tuple<>, __tuple_indices<>,
1068 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
1069 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1070 _VSTD::forward<_Tuples>(__tpls)...);
1073 template <class ..._Tp, class _Alloc>
1074 struct _LIBCPP_TYPE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
1077 template <class _T1, class _T2>
1078 template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1079 inline _LIBCPP_INLINE_VISIBILITY
1080 pair<_T1, _T2>::pair(piecewise_construct_t,
1081 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1082 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
1083 : first(_VSTD::forward<_Args1>(get<_I1>( __first_args))...),
1084 second(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
1088 #endif // _LIBCPP_HAS_NO_VARIADICS
1090 _LIBCPP_END_NAMESPACE_STD
1092 #endif // _LIBCPP_TUPLE