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 inline constexpr 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; // constexpr in C++14
78 template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
80 // [tuple.apply], calling a function with a tuple of arguments:
81 template <class F, class Tuple>
82 constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17
83 template <class T, class Tuple>
84 constexpr T make_from_tuple(Tuple&& t); // C++17
86 // 20.4.1.4, tuple helper classes:
87 template <class T> class tuple_size; // undefined
88 template <class... T> class tuple_size<tuple<T...>>;
90 inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
91 template <size_t I, class T> class tuple_element; // undefined
92 template <size_t I, class... T> class tuple_element<I, tuple<T...>>;
93 template <size_t I, class T>
94 using tuple_element_t = typename tuple_element <I, T>::type; // C++14
96 // 20.4.1.5, element access:
97 template <size_t I, class... T>
98 typename tuple_element<I, tuple<T...>>::type&
99 get(tuple<T...>&) noexcept; // constexpr in C++14
100 template <size_t I, class... T>
101 const typename tuple_element<I, tuple<T...>>::type&
102 get(const tuple<T...>&) noexcept; // constexpr in C++14
103 template <size_t I, class... T>
104 typename tuple_element<I, tuple<T...>>::type&&
105 get(tuple<T...>&&) noexcept; // constexpr in C++14
106 template <size_t I, class... T>
107 const typename tuple_element<I, tuple<T...>>::type&&
108 get(const tuple<T...>&&) noexcept; // constexpr in C++14
110 template <class T1, class... T>
111 constexpr T1& get(tuple<T...>&) noexcept; // C++14
112 template <class T1, class... T>
113 constexpr const T1& get(const tuple<T...>&) noexcept; // C++14
114 template <class T1, class... T>
115 constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
116 template <class T1, class... T>
117 constexpr const T1&& get(const tuple<T...>&&) noexcept; // C++14
119 // 20.4.1.6, relational operators:
120 template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
121 template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
122 template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
123 template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
124 template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
125 template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
127 template <class... Types, class Alloc>
128 struct uses_allocator<tuple<Types...>, Alloc>;
130 template <class... Types>
132 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
141 #include <type_traits>
142 #include <__functional_base>
145 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
146 #pragma GCC system_header
149 _LIBCPP_BEGIN_NAMESPACE_STD
151 #ifndef _LIBCPP_CXX03_LANG
156 template <size_t _Ip, class _Hp,
157 bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
161 template <size_t _Ip, class _Hp, bool _Ep>
162 inline _LIBCPP_INLINE_VISIBILITY
163 void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
164 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
166 swap(__x.get(), __y.get());
169 template <size_t _Ip, class _Hp, bool>
175 static constexpr bool __can_bind_reference() {
176 #if __has_keyword(__reference_binds_to_temporary)
177 return !__reference_binds_to_temporary(_Hp, _Tp);
183 __tuple_leaf& operator=(const __tuple_leaf&);
185 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
186 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_()
187 {static_assert(!is_reference<_Hp>::value,
188 "Attempted to default construct a reference element in a tuple");}
190 template <class _Alloc>
191 _LIBCPP_INLINE_VISIBILITY
192 __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
194 {static_assert(!is_reference<_Hp>::value,
195 "Attempted to default construct a reference element in a tuple");}
197 template <class _Alloc>
198 _LIBCPP_INLINE_VISIBILITY
199 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
200 : __value_(allocator_arg_t(), __a)
201 {static_assert(!is_reference<_Hp>::value,
202 "Attempted to default construct a reference element in a tuple");}
204 template <class _Alloc>
205 _LIBCPP_INLINE_VISIBILITY
206 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
208 {static_assert(!is_reference<_Hp>::value,
209 "Attempted to default construct a reference element in a tuple");}
212 class = typename enable_if<
214 __lazy_not<is_same<typename __uncvref<_Tp>::type, __tuple_leaf>>
215 , is_constructible<_Hp, _Tp>
219 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
220 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
221 : __value_(_VSTD::forward<_Tp>(__t))
222 {static_assert(__can_bind_reference<_Tp&&>(),
223 "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
225 template <class _Tp, class _Alloc>
226 _LIBCPP_INLINE_VISIBILITY
227 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
228 : __value_(_VSTD::forward<_Tp>(__t))
229 {static_assert(__can_bind_reference<_Tp&&>(),
230 "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
232 template <class _Tp, class _Alloc>
233 _LIBCPP_INLINE_VISIBILITY
234 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
235 : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
236 {static_assert(!is_reference<_Hp>::value,
237 "Attempted to uses-allocator construct a reference element in a tuple");}
239 template <class _Tp, class _Alloc>
240 _LIBCPP_INLINE_VISIBILITY
241 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
242 : __value_(_VSTD::forward<_Tp>(__t), __a)
243 {static_assert(!is_reference<_Hp>::value,
244 "Attempted to uses-allocator construct a reference element in a tuple");}
246 __tuple_leaf(const __tuple_leaf& __t) = default;
247 __tuple_leaf(__tuple_leaf&& __t) = default;
250 _LIBCPP_INLINE_VISIBILITY
252 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
254 __value_ = _VSTD::forward<_Tp>(__t);
258 _LIBCPP_INLINE_VISIBILITY
259 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
261 _VSTD::swap(*this, __t);
265 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;}
266 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;}
269 template <size_t _Ip, class _Hp>
270 class __tuple_leaf<_Ip, _Hp, true>
274 __tuple_leaf& operator=(const __tuple_leaf&);
276 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
277 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
279 template <class _Alloc>
280 _LIBCPP_INLINE_VISIBILITY
281 __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
283 template <class _Alloc>
284 _LIBCPP_INLINE_VISIBILITY
285 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
286 : _Hp(allocator_arg_t(), __a) {}
288 template <class _Alloc>
289 _LIBCPP_INLINE_VISIBILITY
290 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
294 class = typename enable_if<
296 __lazy_not<is_same<typename __uncvref<_Tp>::type, __tuple_leaf>>
297 , is_constructible<_Hp, _Tp>
301 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
302 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
303 : _Hp(_VSTD::forward<_Tp>(__t)) {}
305 template <class _Tp, class _Alloc>
306 _LIBCPP_INLINE_VISIBILITY
307 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
308 : _Hp(_VSTD::forward<_Tp>(__t)) {}
310 template <class _Tp, class _Alloc>
311 _LIBCPP_INLINE_VISIBILITY
312 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
313 : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
315 template <class _Tp, class _Alloc>
316 _LIBCPP_INLINE_VISIBILITY
317 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
318 : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
320 __tuple_leaf(__tuple_leaf const &) = default;
321 __tuple_leaf(__tuple_leaf &&) = default;
324 _LIBCPP_INLINE_VISIBILITY
326 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
328 _Hp::operator=(_VSTD::forward<_Tp>(__t));
332 _LIBCPP_INLINE_VISIBILITY
334 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
336 _VSTD::swap(*this, __t);
340 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
341 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
344 template <class ..._Tp>
345 _LIBCPP_INLINE_VISIBILITY
346 void __swallow(_Tp&&...) _NOEXCEPT {}
348 template <class ..._Tp>
349 struct __lazy_all : __all<_Tp::value...> {};
352 struct __all_default_constructible;
354 template <class ..._Tp>
355 struct __all_default_constructible<__tuple_types<_Tp...>>
356 : __all<is_default_constructible<_Tp>::value...>
361 template<class _Indx, class ..._Tp> struct __tuple_impl;
363 template<size_t ..._Indx, class ..._Tp>
364 struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
365 : public __tuple_leaf<_Indx, _Tp>...
367 _LIBCPP_INLINE_VISIBILITY
368 _LIBCPP_CONSTEXPR __tuple_impl()
369 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
371 template <size_t ..._Uf, class ..._Tf,
372 size_t ..._Ul, class ..._Tl, class ..._Up>
373 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
375 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
376 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
378 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
379 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
380 __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
381 __tuple_leaf<_Ul, _Tl>()...
384 template <class _Alloc, size_t ..._Uf, class ..._Tf,
385 size_t ..._Ul, class ..._Tl, class ..._Up>
386 _LIBCPP_INLINE_VISIBILITY
388 __tuple_impl(allocator_arg_t, const _Alloc& __a,
389 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
390 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
392 __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
393 _VSTD::forward<_Up>(__u))...,
394 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
397 template <class _Tuple,
398 class = typename enable_if
400 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
403 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
404 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
405 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
406 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
407 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
410 template <class _Alloc, class _Tuple,
411 class = typename enable_if
413 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
416 _LIBCPP_INLINE_VISIBILITY
417 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
418 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
419 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
420 _VSTD::forward<typename tuple_element<_Indx,
421 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
424 template <class _Tuple>
425 _LIBCPP_INLINE_VISIBILITY
428 __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
431 operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
432 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
434 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
435 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
439 __tuple_impl(const __tuple_impl&) = default;
440 __tuple_impl(__tuple_impl&&) = default;
442 _LIBCPP_INLINE_VISIBILITY
444 operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
446 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
450 _LIBCPP_INLINE_VISIBILITY
452 operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
454 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
458 _LIBCPP_INLINE_VISIBILITY
459 void swap(__tuple_impl& __t)
460 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
462 __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
468 template <class ..._Tp>
469 class _LIBCPP_TEMPLATE_VIS tuple
471 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
475 #if defined(_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION)
476 static constexpr bool _EnableImplicitReducedArityExtension = true;
478 static constexpr bool _EnableImplicitReducedArityExtension = false;
481 template <class ..._Args>
482 struct _PackExpandsToThisTuple : false_type {};
484 template <class _Arg>
485 struct _PackExpandsToThisTuple<_Arg>
486 : is_same<typename __uncvref<_Arg>::type, tuple> {};
488 template <bool _MaybeEnable, class _Dummy = void>
489 struct _CheckArgsConstructor : __check_tuple_constructor_fail {};
491 template <class _Dummy>
492 struct _CheckArgsConstructor<true, _Dummy>
494 template <class ..._Args>
495 static constexpr bool __enable_default() {
496 return __all<is_default_constructible<_Args>::value...>::value;
499 template <class ..._Args>
500 static constexpr bool __enable_explicit() {
502 __tuple_constructible<
504 typename __make_tuple_types<tuple,
505 sizeof...(_Args) < sizeof...(_Tp) ?
507 sizeof...(_Tp)>::type
509 !__tuple_convertible<
511 typename __make_tuple_types<tuple,
512 sizeof...(_Args) < sizeof...(_Tp) ?
514 sizeof...(_Tp)>::type
516 __all_default_constructible<
517 typename __make_tuple_types<tuple, sizeof...(_Tp),
518 sizeof...(_Args) < sizeof...(_Tp) ?
520 sizeof...(_Tp)>::type
524 template <class ..._Args>
525 static constexpr bool __enable_implicit() {
529 typename __make_tuple_types<tuple,
530 sizeof...(_Args) < sizeof...(_Tp) ?
532 sizeof...(_Tp)>::type
534 __all_default_constructible<
535 typename __make_tuple_types<tuple, sizeof...(_Tp),
536 sizeof...(_Args) < sizeof...(_Tp) ?
538 sizeof...(_Tp)>::type
543 template <bool _MaybeEnable,
544 bool = sizeof...(_Tp) == 1,
546 struct _CheckTupleLikeConstructor : __check_tuple_constructor_fail {};
548 template <class _Dummy>
549 struct _CheckTupleLikeConstructor<true, false, _Dummy>
551 template <class _Tuple>
552 static constexpr bool __enable_implicit() {
553 return __tuple_convertible<_Tuple, tuple>::value;
556 template <class _Tuple>
557 static constexpr bool __enable_explicit() {
558 return __tuple_constructible<_Tuple, tuple>::value
559 && !__tuple_convertible<_Tuple, tuple>::value;
563 template <class _Dummy>
564 struct _CheckTupleLikeConstructor<true, true, _Dummy>
566 // This trait is used to disable the tuple-like constructor when
567 // the UTypes... constructor should be selected instead.
568 // See LWG issue #2549.
569 template <class _Tuple>
570 using _PreferTupleLikeConstructor = __lazy_or<
571 // Don't attempt the two checks below if the tuple we are given
572 // has the same type as this tuple.
573 is_same<typename __uncvref<_Tuple>::type, tuple>,
575 __lazy_not<is_constructible<_Tp..., _Tuple>>,
576 __lazy_not<is_convertible<_Tuple, _Tp...>>
580 template <class _Tuple>
581 static constexpr bool __enable_implicit() {
583 __tuple_convertible<_Tuple, tuple>,
584 _PreferTupleLikeConstructor<_Tuple>
588 template <class _Tuple>
589 static constexpr bool __enable_explicit() {
591 __tuple_constructible<_Tuple, tuple>,
592 _PreferTupleLikeConstructor<_Tuple>,
593 __lazy_not<__tuple_convertible<_Tuple, tuple>>
598 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
599 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
600 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
601 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
602 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
603 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
604 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
605 const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
608 template <bool _Dummy = true, class = typename enable_if<
609 _CheckArgsConstructor<_Dummy>::template __enable_default<_Tp...>()
611 _LIBCPP_INLINE_VISIBILITY
612 _LIBCPP_CONSTEXPR tuple()
613 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
615 tuple(tuple const&) = default;
616 tuple(tuple&&) = default;
618 template <class _AllocArgT, class _Alloc, bool _Dummy = true, class = typename enable_if<
620 is_same<allocator_arg_t, _AllocArgT>,
621 __lazy_all<__dependent_type<is_default_constructible<_Tp>, _Dummy>...>
624 _LIBCPP_INLINE_VISIBILITY
625 tuple(_AllocArgT, _Alloc const& __a)
626 : __base_(allocator_arg_t(), __a,
627 __tuple_indices<>(), __tuple_types<>(),
628 typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
629 __tuple_types<_Tp...>()) {}
631 template <bool _Dummy = true,
634 _CheckArgsConstructor<
636 >::template __enable_implicit<_Tp const&...>(),
640 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
641 tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
642 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
643 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
644 typename __make_tuple_indices<0>::type(),
645 typename __make_tuple_types<tuple, 0>::type(),
649 template <bool _Dummy = true,
652 _CheckArgsConstructor<
654 >::template __enable_explicit<_Tp const&...>(),
658 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
659 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
660 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
661 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
662 typename __make_tuple_indices<0>::type(),
663 typename __make_tuple_types<tuple, 0>::type(),
667 template <class _Alloc, bool _Dummy = true,
670 _CheckArgsConstructor<
672 >::template __enable_implicit<_Tp const&...>(),
676 _LIBCPP_INLINE_VISIBILITY
677 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
678 : __base_(allocator_arg_t(), __a,
679 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
680 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
681 typename __make_tuple_indices<0>::type(),
682 typename __make_tuple_types<tuple, 0>::type(),
686 template <class _Alloc, bool _Dummy = true,
689 _CheckArgsConstructor<
691 >::template __enable_explicit<_Tp const&...>(),
695 _LIBCPP_INLINE_VISIBILITY
697 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
698 : __base_(allocator_arg_t(), __a,
699 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
700 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
701 typename __make_tuple_indices<0>::type(),
702 typename __make_tuple_types<tuple, 0>::type(),
706 template <class ..._Up,
707 bool _PackIsTuple = _PackExpandsToThisTuple<_Up...>::value,
710 _CheckArgsConstructor<
711 sizeof...(_Up) == sizeof...(_Tp)
713 >::template __enable_implicit<_Up...>() ||
714 _CheckArgsConstructor<
715 _EnableImplicitReducedArityExtension
716 && sizeof...(_Up) < sizeof...(_Tp)
718 >::template __enable_implicit<_Up...>(),
722 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
725 is_nothrow_constructible<_BaseT,
726 typename __make_tuple_indices<sizeof...(_Up)>::type,
727 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
728 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
729 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
733 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
734 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
735 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
736 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
737 _VSTD::forward<_Up>(__u)...) {}
739 template <class ..._Up,
742 _CheckArgsConstructor<
743 sizeof...(_Up) <= sizeof...(_Tp)
744 && !_PackExpandsToThisTuple<_Up...>::value
745 >::template __enable_explicit<_Up...>() ||
746 _CheckArgsConstructor<
747 !_EnableImplicitReducedArityExtension
748 && sizeof...(_Up) < sizeof...(_Tp)
749 && !_PackExpandsToThisTuple<_Up...>::value
750 >::template __enable_implicit<_Up...>(),
754 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
758 is_nothrow_constructible<_BaseT,
759 typename __make_tuple_indices<sizeof...(_Up)>::type,
760 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
761 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
762 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
766 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
767 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
768 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
769 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
770 _VSTD::forward<_Up>(__u)...) {}
772 template <class _Alloc, class ..._Up,
775 _CheckArgsConstructor<
776 sizeof...(_Up) == sizeof...(_Tp) &&
777 !_PackExpandsToThisTuple<_Up...>::value
778 >::template __enable_implicit<_Up...>(),
782 _LIBCPP_INLINE_VISIBILITY
783 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
784 : __base_(allocator_arg_t(), __a,
785 typename __make_tuple_indices<sizeof...(_Up)>::type(),
786 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
787 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
788 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
789 _VSTD::forward<_Up>(__u)...) {}
791 template <class _Alloc, class ..._Up,
794 _CheckArgsConstructor<
795 sizeof...(_Up) == sizeof...(_Tp) &&
796 !_PackExpandsToThisTuple<_Up...>::value
797 >::template __enable_explicit<_Up...>(),
801 _LIBCPP_INLINE_VISIBILITY
803 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
804 : __base_(allocator_arg_t(), __a,
805 typename __make_tuple_indices<sizeof...(_Up)>::type(),
806 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
807 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
808 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
809 _VSTD::forward<_Up>(__u)...) {}
811 template <class _Tuple,
814 _CheckTupleLikeConstructor<
815 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
816 && !_PackExpandsToThisTuple<_Tuple>::value
817 >::template __enable_implicit<_Tuple>(),
821 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
822 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
823 : __base_(_VSTD::forward<_Tuple>(__t)) {}
825 template <class _Tuple,
828 _CheckTupleLikeConstructor<
829 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
830 && !_PackExpandsToThisTuple<_Tuple>::value
831 >::template __enable_explicit<_Tuple>(),
835 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
837 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
838 : __base_(_VSTD::forward<_Tuple>(__t)) {}
840 template <class _Alloc, class _Tuple,
843 _CheckTupleLikeConstructor<
844 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
845 >::template __enable_implicit<_Tuple>(),
849 _LIBCPP_INLINE_VISIBILITY
850 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
851 : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
853 template <class _Alloc, class _Tuple,
856 _CheckTupleLikeConstructor<
857 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
858 >::template __enable_explicit<_Tuple>(),
862 _LIBCPP_INLINE_VISIBILITY
864 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
865 : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
867 using _CanCopyAssign = __all<is_copy_assignable<_Tp>::value...>;
868 using _CanMoveAssign = __all<is_move_assignable<_Tp>::value...>;
870 _LIBCPP_INLINE_VISIBILITY
871 tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, __nat>::type const& __t)
872 _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
874 __base_.operator=(__t.__base_);
878 _LIBCPP_INLINE_VISIBILITY
879 tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, __nat>::type&& __t)
880 _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
882 __base_.operator=(static_cast<_BaseT&&>(__t.__base_));
886 template <class _Tuple,
887 class = typename enable_if
889 __tuple_assignable<_Tuple, tuple>::value
892 _LIBCPP_INLINE_VISIBILITY
894 operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<_BaseT&, _Tuple>::value))
896 __base_.operator=(_VSTD::forward<_Tuple>(__t));
900 _LIBCPP_INLINE_VISIBILITY
901 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
902 {__base_.swap(__t.__base_);}
906 class _LIBCPP_TEMPLATE_VIS tuple<>
909 _LIBCPP_INLINE_VISIBILITY
910 _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
911 template <class _Alloc>
912 _LIBCPP_INLINE_VISIBILITY
913 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
914 template <class _Alloc>
915 _LIBCPP_INLINE_VISIBILITY
916 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
918 _LIBCPP_INLINE_VISIBILITY
919 tuple(array<_Up, 0>) _NOEXCEPT {}
920 template <class _Alloc, class _Up>
921 _LIBCPP_INLINE_VISIBILITY
922 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
923 _LIBCPP_INLINE_VISIBILITY
924 void swap(tuple&) _NOEXCEPT {}
927 #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
928 // NOTE: These are not yet standardized, but are required to simulate the
929 // implicit deduction guide that should be generated had libc++ declared the
930 // tuple-like constructors "correctly"
931 template <class _Alloc, class ..._Args>
932 tuple(allocator_arg_t, const _Alloc&, tuple<_Args...> const&) -> tuple<_Args...>;
933 template <class _Alloc, class ..._Args>
934 tuple(allocator_arg_t, const _Alloc&, tuple<_Args...>&&) -> tuple<_Args...>;
937 template <class ..._Tp>
938 inline _LIBCPP_INLINE_VISIBILITY
941 __all<__is_swappable<_Tp>::value...>::value,
944 swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
945 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
950 template <size_t _Ip, class ..._Tp>
951 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
952 typename tuple_element<_Ip, tuple<_Tp...> >::type&
953 get(tuple<_Tp...>& __t) _NOEXCEPT
955 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
956 return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
959 template <size_t _Ip, class ..._Tp>
960 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
961 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
962 get(const tuple<_Tp...>& __t) _NOEXCEPT
964 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
965 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
968 template <size_t _Ip, class ..._Tp>
969 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
970 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
971 get(tuple<_Tp...>&& __t) _NOEXCEPT
973 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
974 return static_cast<type&&>(
975 static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
978 template <size_t _Ip, class ..._Tp>
979 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
980 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
981 get(const tuple<_Tp...>&& __t) _NOEXCEPT
983 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
984 return static_cast<const type&&>(
985 static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
988 #if _LIBCPP_STD_VER > 11
990 namespace __find_detail {
992 static constexpr size_t __not_found = -1;
993 static constexpr size_t __ambiguous = __not_found - 1;
995 inline _LIBCPP_INLINE_VISIBILITY
996 constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
997 return !__matches ? __res :
998 (__res == __not_found ? __curr_i : __ambiguous);
1001 template <size_t _Nx>
1002 inline _LIBCPP_INLINE_VISIBILITY
1003 constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
1004 return __i == _Nx ? __not_found :
1005 __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]);
1008 template <class _T1, class ..._Args>
1009 struct __find_exactly_one_checked {
1010 static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
1011 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
1012 static_assert(value != __not_found, "type not found in type list" );
1013 static_assert(value != __ambiguous, "type occurs more than once in type list");
1016 template <class _T1>
1017 struct __find_exactly_one_checked<_T1> {
1018 static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
1021 } // namespace __find_detail;
1023 template <typename _T1, typename... _Args>
1024 struct __find_exactly_one_t
1025 : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
1028 template <class _T1, class... _Args>
1029 inline _LIBCPP_INLINE_VISIBILITY
1030 constexpr _T1& get(tuple<_Args...>& __tup) noexcept
1032 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1035 template <class _T1, class... _Args>
1036 inline _LIBCPP_INLINE_VISIBILITY
1037 constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
1039 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1042 template <class _T1, class... _Args>
1043 inline _LIBCPP_INLINE_VISIBILITY
1044 constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
1046 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1049 template <class _T1, class... _Args>
1050 inline _LIBCPP_INLINE_VISIBILITY
1051 constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
1053 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1060 template <class ..._Tp>
1061 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1063 tie(_Tp&... __t) _NOEXCEPT
1065 return tuple<_Tp&...>(__t...);
1068 template <class _Up>
1071 template <class _Tp>
1072 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1073 const __ignore_t& operator=(_Tp&&) const {return *this;}
1077 _LIBCPP_INLINE_VAR constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
1080 template <class _Tp>
1081 struct __make_tuple_return_impl
1086 template <class _Tp>
1087 struct __make_tuple_return_impl<reference_wrapper<_Tp> >
1092 template <class _Tp>
1093 struct __make_tuple_return
1095 typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
1098 template <class... _Tp>
1099 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1100 tuple<typename __make_tuple_return<_Tp>::type...>
1101 make_tuple(_Tp&&... __t)
1103 return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
1106 template <class... _Tp>
1107 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1109 forward_as_tuple(_Tp&&... __t) _NOEXCEPT
1111 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
1114 template <size_t _Ip>
1115 struct __tuple_equal
1117 template <class _Tp, class _Up>
1118 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1119 bool operator()(const _Tp& __x, const _Up& __y)
1121 return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
1126 struct __tuple_equal<0>
1128 template <class _Tp, class _Up>
1129 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1130 bool operator()(const _Tp&, const _Up&)
1136 template <class ..._Tp, class ..._Up>
1137 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1139 operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1141 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
1144 template <class ..._Tp, class ..._Up>
1145 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1147 operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1149 return !(__x == __y);
1152 template <size_t _Ip>
1155 template <class _Tp, class _Up>
1156 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1157 bool operator()(const _Tp& __x, const _Up& __y)
1159 const size_t __idx = tuple_size<_Tp>::value - _Ip;
1160 if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
1162 if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
1164 return __tuple_less<_Ip-1>()(__x, __y);
1169 struct __tuple_less<0>
1171 template <class _Tp, class _Up>
1172 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1173 bool operator()(const _Tp&, const _Up&)
1179 template <class ..._Tp, class ..._Up>
1180 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1182 operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1184 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
1187 template <class ..._Tp, class ..._Up>
1188 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1190 operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1195 template <class ..._Tp, class ..._Up>
1196 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1198 operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1200 return !(__x < __y);
1203 template <class ..._Tp, class ..._Up>
1204 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1206 operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1208 return !(__y < __x);
1213 template <class _Tp, class _Up> struct __tuple_cat_type;
1215 template <class ..._Ttypes, class ..._Utypes>
1216 struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
1218 typedef tuple<_Ttypes..., _Utypes...> type;
1221 template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
1222 struct __tuple_cat_return_1
1226 template <class ..._Types, class _Tuple0>
1227 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
1229 typedef typename __tuple_cat_type<tuple<_Types...>,
1230 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
1234 template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
1235 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
1236 : public __tuple_cat_return_1<
1237 typename __tuple_cat_type<
1239 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
1241 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
1242 _Tuple1, _Tuples...>
1246 template <class ..._Tuples> struct __tuple_cat_return;
1248 template <class _Tuple0, class ..._Tuples>
1249 struct __tuple_cat_return<_Tuple0, _Tuples...>
1250 : public __tuple_cat_return_1<tuple<>,
1251 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
1257 struct __tuple_cat_return<>
1259 typedef tuple<> type;
1262 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1269 template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
1270 struct __tuple_cat_return_ref_imp;
1272 template <class ..._Types, size_t ..._I0, class _Tuple0>
1273 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
1275 typedef typename remove_reference<_Tuple0>::type _T0;
1276 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1277 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1280 template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1281 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1282 _Tuple0, _Tuple1, _Tuples...>
1283 : public __tuple_cat_return_ref_imp<
1284 tuple<_Types..., typename __apply_cv<_Tuple0,
1285 typename tuple_element<_I0,
1286 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1287 typename __make_tuple_indices<tuple_size<typename
1288 remove_reference<_Tuple1>::type>::value>::type,
1289 _Tuple1, _Tuples...>
1293 template <class _Tuple0, class ..._Tuples>
1294 struct __tuple_cat_return_ref
1295 : public __tuple_cat_return_ref_imp<tuple<>,
1296 typename __make_tuple_indices<
1297 tuple_size<typename remove_reference<_Tuple0>::type>::value
1298 >::type, _Tuple0, _Tuples...>
1302 template <class _Types, class _I0, class _J0>
1305 template <class ..._Types, size_t ..._I0, size_t ..._J0>
1306 struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
1308 template <class _Tuple0>
1309 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1310 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1311 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1313 return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1314 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
1317 template <class _Tuple0, class _Tuple1, class ..._Tuples>
1318 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1319 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1320 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1322 typedef typename remove_reference<_Tuple0>::type _T0;
1323 typedef typename remove_reference<_Tuple1>::type _T1;
1325 tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1326 typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1327 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
1329 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1330 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
1332 _VSTD::forward<_Tuple1>(__t1),
1333 _VSTD::forward<_Tuples>(__tpls)...);
1337 template <class _Tuple0, class... _Tuples>
1338 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1339 typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1340 tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1342 typedef typename remove_reference<_Tuple0>::type _T0;
1343 return __tuple_cat<tuple<>, __tuple_indices<>,
1344 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
1345 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1346 _VSTD::forward<_Tuples>(__tpls)...);
1349 template <class ..._Tp, class _Alloc>
1350 struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
1353 template <class _T1, class _T2>
1354 template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1355 inline _LIBCPP_INLINE_VISIBILITY
1356 pair<_T1, _T2>::pair(piecewise_construct_t,
1357 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1358 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
1359 : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
1360 second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
1364 #if _LIBCPP_STD_VER > 14
1365 template <class _Tp>
1366 _LIBCPP_INLINE_VAR constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
1368 #define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
1370 template <class _Fn, class _Tuple, size_t ..._Id>
1371 inline _LIBCPP_INLINE_VISIBILITY
1372 constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
1373 __tuple_indices<_Id...>)
1374 _LIBCPP_NOEXCEPT_RETURN(
1375 _VSTD::__invoke_constexpr(
1376 _VSTD::forward<_Fn>(__f),
1377 _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
1380 template <class _Fn, class _Tuple>
1381 inline _LIBCPP_INLINE_VISIBILITY
1382 constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
1383 _LIBCPP_NOEXCEPT_RETURN(
1384 _VSTD::__apply_tuple_impl(
1385 _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
1386 typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
1389 template <class _Tp, class _Tuple, size_t... _Idx>
1390 inline _LIBCPP_INLINE_VISIBILITY
1391 constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
1392 _LIBCPP_NOEXCEPT_RETURN(
1393 _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...)
1396 template <class _Tp, class _Tuple>
1397 inline _LIBCPP_INLINE_VISIBILITY
1398 constexpr _Tp make_from_tuple(_Tuple&& __t)
1399 _LIBCPP_NOEXCEPT_RETURN(
1400 _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
1401 typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
1404 #undef _LIBCPP_NOEXCEPT_RETURN
1406 #endif // _LIBCPP_STD_VER > 14
1408 #endif // !defined(_LIBCPP_CXX03_LANG)
1410 _LIBCPP_END_NAMESPACE_STD
1412 #endif // _LIBCPP_TUPLE