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 using _RawTp = typename remove_reference<_Tp>::type;
177 using _RawHp = typename remove_reference<_Hp>::type;
178 using _CheckLValueArg = integral_constant<bool,
179 is_lvalue_reference<_Tp>::value
180 || is_same<_RawTp, reference_wrapper<_RawHp>>::value
181 || is_same<_RawTp, reference_wrapper<typename remove_const<_RawHp>::type>>::value
183 return !is_reference<_Hp>::value
184 || (is_lvalue_reference<_Hp>::value && _CheckLValueArg::value)
185 || (is_rvalue_reference<_Hp>::value && !is_lvalue_reference<_Tp>::value);
188 __tuple_leaf& operator=(const __tuple_leaf&);
190 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
191 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_()
192 {static_assert(!is_reference<_Hp>::value,
193 "Attempted to default construct a reference element in a tuple");}
195 template <class _Alloc>
196 _LIBCPP_INLINE_VISIBILITY
197 __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
199 {static_assert(!is_reference<_Hp>::value,
200 "Attempted to default construct a reference element in a tuple");}
202 template <class _Alloc>
203 _LIBCPP_INLINE_VISIBILITY
204 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
205 : __value_(allocator_arg_t(), __a)
206 {static_assert(!is_reference<_Hp>::value,
207 "Attempted to default construct a reference element in a tuple");}
209 template <class _Alloc>
210 _LIBCPP_INLINE_VISIBILITY
211 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
213 {static_assert(!is_reference<_Hp>::value,
214 "Attempted to default construct a reference element in a tuple");}
217 class = typename enable_if<
219 __lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
220 , is_constructible<_Hp, _Tp>
224 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
225 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
226 : __value_(_VSTD::forward<_Tp>(__t))
227 {static_assert(__can_bind_reference<_Tp>(),
228 "Attempted to construct a reference element in a tuple with an rvalue");}
230 template <class _Tp, class _Alloc>
231 _LIBCPP_INLINE_VISIBILITY
232 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
233 : __value_(_VSTD::forward<_Tp>(__t))
234 {static_assert(__can_bind_reference<_Tp>(),
235 "Attempted to construct a reference element in a tuple with an rvalue");}
237 template <class _Tp, class _Alloc>
238 _LIBCPP_INLINE_VISIBILITY
239 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
240 : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
241 {static_assert(!is_reference<_Hp>::value,
242 "Attempted to uses-allocator construct a reference element in a tuple");}
244 template <class _Tp, class _Alloc>
245 _LIBCPP_INLINE_VISIBILITY
246 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
247 : __value_(_VSTD::forward<_Tp>(__t), __a)
248 {static_assert(!is_reference<_Hp>::value,
249 "Attempted to uses-allocator construct a reference element in a tuple");}
251 __tuple_leaf(const __tuple_leaf& __t) = default;
252 __tuple_leaf(__tuple_leaf&& __t) = default;
255 _LIBCPP_INLINE_VISIBILITY
257 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
259 __value_ = _VSTD::forward<_Tp>(__t);
263 _LIBCPP_INLINE_VISIBILITY
264 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
266 _VSTD::swap(*this, __t);
270 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;}
271 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;}
274 template <size_t _Ip, class _Hp>
275 class __tuple_leaf<_Ip, _Hp, true>
279 __tuple_leaf& operator=(const __tuple_leaf&);
281 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
282 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
284 template <class _Alloc>
285 _LIBCPP_INLINE_VISIBILITY
286 __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
288 template <class _Alloc>
289 _LIBCPP_INLINE_VISIBILITY
290 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
291 : _Hp(allocator_arg_t(), __a) {}
293 template <class _Alloc>
294 _LIBCPP_INLINE_VISIBILITY
295 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
299 class = typename enable_if<
301 __lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
302 , is_constructible<_Hp, _Tp>
306 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
307 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
308 : _Hp(_VSTD::forward<_Tp>(__t)) {}
310 template <class _Tp, class _Alloc>
311 _LIBCPP_INLINE_VISIBILITY
312 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
313 : _Hp(_VSTD::forward<_Tp>(__t)) {}
315 template <class _Tp, class _Alloc>
316 _LIBCPP_INLINE_VISIBILITY
317 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
318 : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
320 template <class _Tp, class _Alloc>
321 _LIBCPP_INLINE_VISIBILITY
322 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
323 : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
325 __tuple_leaf(__tuple_leaf const &) = default;
326 __tuple_leaf(__tuple_leaf &&) = default;
329 _LIBCPP_INLINE_VISIBILITY
331 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
333 _Hp::operator=(_VSTD::forward<_Tp>(__t));
337 _LIBCPP_INLINE_VISIBILITY
339 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
341 _VSTD::swap(*this, __t);
345 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
346 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
349 template <class ..._Tp>
350 _LIBCPP_INLINE_VISIBILITY
351 void __swallow(_Tp&&...) _NOEXCEPT {}
353 template <class ..._Tp>
354 struct __lazy_all : __all<_Tp::value...> {};
357 struct __all_default_constructible;
359 template <class ..._Tp>
360 struct __all_default_constructible<__tuple_types<_Tp...>>
361 : __all<is_default_constructible<_Tp>::value...>
366 template<class _Indx, class ..._Tp> struct __tuple_impl;
368 template<size_t ..._Indx, class ..._Tp>
369 struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
370 : public __tuple_leaf<_Indx, _Tp>...
372 _LIBCPP_INLINE_VISIBILITY
373 _LIBCPP_CONSTEXPR __tuple_impl()
374 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
376 template <size_t ..._Uf, class ..._Tf,
377 size_t ..._Ul, class ..._Tl, class ..._Up>
378 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
380 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
381 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
383 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
384 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
385 __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
386 __tuple_leaf<_Ul, _Tl>()...
389 template <class _Alloc, size_t ..._Uf, class ..._Tf,
390 size_t ..._Ul, class ..._Tl, class ..._Up>
391 _LIBCPP_INLINE_VISIBILITY
393 __tuple_impl(allocator_arg_t, const _Alloc& __a,
394 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
395 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
397 __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
398 _VSTD::forward<_Up>(__u))...,
399 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
402 template <class _Tuple,
403 class = typename enable_if
405 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
408 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
409 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
410 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
411 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
412 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
415 template <class _Alloc, class _Tuple,
416 class = typename enable_if
418 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
421 _LIBCPP_INLINE_VISIBILITY
422 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
423 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
424 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
425 _VSTD::forward<typename tuple_element<_Indx,
426 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
429 template <class _Tuple>
430 _LIBCPP_INLINE_VISIBILITY
433 __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
436 operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
437 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
439 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
440 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
444 __tuple_impl(const __tuple_impl&) = default;
445 __tuple_impl(__tuple_impl&&) = default;
447 _LIBCPP_INLINE_VISIBILITY
449 operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
451 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
455 _LIBCPP_INLINE_VISIBILITY
457 operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
459 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
463 _LIBCPP_INLINE_VISIBILITY
464 void swap(__tuple_impl& __t)
465 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
467 __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
473 template <class ..._Tp>
474 class _LIBCPP_TEMPLATE_VIS tuple
476 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
480 #if defined(_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION)
481 static constexpr bool _EnableImplicitReducedArityExtension = true;
483 static constexpr bool _EnableImplicitReducedArityExtension = false;
486 template <class ..._Args>
487 struct _PackExpandsToThisTuple : false_type {};
489 template <class _Arg>
490 struct _PackExpandsToThisTuple<_Arg>
491 : is_same<typename __uncvref<_Arg>::type, tuple> {};
493 template <bool _MaybeEnable, class _Dummy = void>
494 struct _CheckArgsConstructor : __check_tuple_constructor_fail {};
496 template <class _Dummy>
497 struct _CheckArgsConstructor<true, _Dummy>
499 template <class ..._Args>
500 static constexpr bool __enable_default() {
501 return __all<is_default_constructible<_Args>::value...>::value;
504 template <class ..._Args>
505 static constexpr bool __enable_explicit() {
507 __tuple_constructible<
509 typename __make_tuple_types<tuple,
510 sizeof...(_Args) < sizeof...(_Tp) ?
512 sizeof...(_Tp)>::type
514 !__tuple_convertible<
516 typename __make_tuple_types<tuple,
517 sizeof...(_Args) < sizeof...(_Tp) ?
519 sizeof...(_Tp)>::type
521 __all_default_constructible<
522 typename __make_tuple_types<tuple, sizeof...(_Tp),
523 sizeof...(_Args) < sizeof...(_Tp) ?
525 sizeof...(_Tp)>::type
529 template <class ..._Args>
530 static constexpr bool __enable_implicit() {
534 typename __make_tuple_types<tuple,
535 sizeof...(_Args) < sizeof...(_Tp) ?
537 sizeof...(_Tp)>::type
539 __all_default_constructible<
540 typename __make_tuple_types<tuple, sizeof...(_Tp),
541 sizeof...(_Args) < sizeof...(_Tp) ?
543 sizeof...(_Tp)>::type
548 template <bool _MaybeEnable,
549 bool = sizeof...(_Tp) == 1,
551 struct _CheckTupleLikeConstructor : __check_tuple_constructor_fail {};
553 template <class _Dummy>
554 struct _CheckTupleLikeConstructor<true, false, _Dummy>
556 template <class _Tuple>
557 static constexpr bool __enable_implicit() {
558 return __tuple_convertible<_Tuple, tuple>::value;
561 template <class _Tuple>
562 static constexpr bool __enable_explicit() {
563 return __tuple_constructible<_Tuple, tuple>::value
564 && !__tuple_convertible<_Tuple, tuple>::value;
568 template <class _Dummy>
569 struct _CheckTupleLikeConstructor<true, true, _Dummy>
571 // This trait is used to disable the tuple-like constructor when
572 // the UTypes... constructor should be selected instead.
573 // See LWG issue #2549.
574 template <class _Tuple>
575 using _PreferTupleLikeConstructor = __lazy_or<
576 // Don't attempt the two checks below if the tuple we are given
577 // has the same type as this tuple.
578 is_same<typename __uncvref<_Tuple>::type, tuple>,
580 __lazy_not<is_constructible<_Tp..., _Tuple>>,
581 __lazy_not<is_convertible<_Tuple, _Tp...>>
585 template <class _Tuple>
586 static constexpr bool __enable_implicit() {
588 __tuple_convertible<_Tuple, tuple>,
589 _PreferTupleLikeConstructor<_Tuple>
593 template <class _Tuple>
594 static constexpr bool __enable_explicit() {
596 __tuple_constructible<_Tuple, tuple>,
597 _PreferTupleLikeConstructor<_Tuple>,
598 __lazy_not<__tuple_convertible<_Tuple, tuple>>
603 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
604 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
605 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
606 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
607 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
608 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
609 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
610 const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
613 template <bool _Dummy = true, class = typename enable_if<
614 _CheckArgsConstructor<_Dummy>::template __enable_default<_Tp...>()
616 _LIBCPP_INLINE_VISIBILITY
617 _LIBCPP_CONSTEXPR tuple()
618 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
620 tuple(tuple const&) = default;
621 tuple(tuple&&) = default;
623 template <class _AllocArgT, class _Alloc, bool _Dummy = true, class = typename enable_if<
625 is_same<allocator_arg_t, _AllocArgT>,
626 __lazy_all<__dependent_type<is_default_constructible<_Tp>, _Dummy>...>
629 _LIBCPP_INLINE_VISIBILITY
630 tuple(_AllocArgT, _Alloc const& __a)
631 : __base_(allocator_arg_t(), __a,
632 __tuple_indices<>(), __tuple_types<>(),
633 typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
634 __tuple_types<_Tp...>()) {}
636 template <bool _Dummy = true,
639 _CheckArgsConstructor<
641 >::template __enable_implicit<_Tp const&...>(),
645 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
646 tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
647 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
648 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
649 typename __make_tuple_indices<0>::type(),
650 typename __make_tuple_types<tuple, 0>::type(),
654 template <bool _Dummy = true,
657 _CheckArgsConstructor<
659 >::template __enable_explicit<_Tp const&...>(),
663 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
664 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
665 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
666 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
667 typename __make_tuple_indices<0>::type(),
668 typename __make_tuple_types<tuple, 0>::type(),
672 template <class _Alloc, bool _Dummy = true,
675 _CheckArgsConstructor<
677 >::template __enable_implicit<_Tp const&...>(),
681 _LIBCPP_INLINE_VISIBILITY
682 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
683 : __base_(allocator_arg_t(), __a,
684 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
685 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
686 typename __make_tuple_indices<0>::type(),
687 typename __make_tuple_types<tuple, 0>::type(),
691 template <class _Alloc, bool _Dummy = true,
694 _CheckArgsConstructor<
696 >::template __enable_explicit<_Tp const&...>(),
700 _LIBCPP_INLINE_VISIBILITY
702 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
703 : __base_(allocator_arg_t(), __a,
704 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
705 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
706 typename __make_tuple_indices<0>::type(),
707 typename __make_tuple_types<tuple, 0>::type(),
711 template <class ..._Up,
712 bool _PackIsTuple = _PackExpandsToThisTuple<_Up...>::value,
715 _CheckArgsConstructor<
716 sizeof...(_Up) == sizeof...(_Tp)
718 >::template __enable_implicit<_Up...>() ||
719 _CheckArgsConstructor<
720 _EnableImplicitReducedArityExtension
721 && sizeof...(_Up) < sizeof...(_Tp)
723 >::template __enable_implicit<_Up...>(),
727 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
730 is_nothrow_constructible<_BaseT,
731 typename __make_tuple_indices<sizeof...(_Up)>::type,
732 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
733 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
734 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
738 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
739 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
740 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
741 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
742 _VSTD::forward<_Up>(__u)...) {}
744 template <class ..._Up,
747 _CheckArgsConstructor<
748 sizeof...(_Up) <= sizeof...(_Tp)
749 && !_PackExpandsToThisTuple<_Up...>::value
750 >::template __enable_explicit<_Up...>() ||
751 _CheckArgsConstructor<
752 !_EnableImplicitReducedArityExtension
753 && sizeof...(_Up) < sizeof...(_Tp)
754 && !_PackExpandsToThisTuple<_Up...>::value
755 >::template __enable_implicit<_Up...>(),
759 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
763 is_nothrow_constructible<_BaseT,
764 typename __make_tuple_indices<sizeof...(_Up)>::type,
765 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
766 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
767 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
771 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
772 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
773 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
774 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
775 _VSTD::forward<_Up>(__u)...) {}
777 template <class _Alloc, class ..._Up,
780 _CheckArgsConstructor<
781 sizeof...(_Up) == sizeof...(_Tp) &&
782 !_PackExpandsToThisTuple<_Up...>::value
783 >::template __enable_implicit<_Up...>(),
787 _LIBCPP_INLINE_VISIBILITY
788 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
789 : __base_(allocator_arg_t(), __a,
790 typename __make_tuple_indices<sizeof...(_Up)>::type(),
791 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
792 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
793 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
794 _VSTD::forward<_Up>(__u)...) {}
796 template <class _Alloc, class ..._Up,
799 _CheckArgsConstructor<
800 sizeof...(_Up) == sizeof...(_Tp) &&
801 !_PackExpandsToThisTuple<_Up...>::value
802 >::template __enable_explicit<_Up...>(),
806 _LIBCPP_INLINE_VISIBILITY
808 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
809 : __base_(allocator_arg_t(), __a,
810 typename __make_tuple_indices<sizeof...(_Up)>::type(),
811 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
812 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
813 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
814 _VSTD::forward<_Up>(__u)...) {}
816 template <class _Tuple,
819 _CheckTupleLikeConstructor<
820 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
821 && !_PackExpandsToThisTuple<_Tuple>::value
822 >::template __enable_implicit<_Tuple>(),
826 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
827 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
828 : __base_(_VSTD::forward<_Tuple>(__t)) {}
830 template <class _Tuple,
833 _CheckTupleLikeConstructor<
834 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
835 && !_PackExpandsToThisTuple<_Tuple>::value
836 >::template __enable_explicit<_Tuple>(),
840 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
842 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
843 : __base_(_VSTD::forward<_Tuple>(__t)) {}
845 template <class _Alloc, class _Tuple,
848 _CheckTupleLikeConstructor<
849 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
850 >::template __enable_implicit<_Tuple>(),
854 _LIBCPP_INLINE_VISIBILITY
855 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
856 : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
858 template <class _Alloc, class _Tuple,
861 _CheckTupleLikeConstructor<
862 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
863 >::template __enable_explicit<_Tuple>(),
867 _LIBCPP_INLINE_VISIBILITY
869 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
870 : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
872 using _CanCopyAssign = __all<is_copy_assignable<_Tp>::value...>;
873 using _CanMoveAssign = __all<is_move_assignable<_Tp>::value...>;
875 _LIBCPP_INLINE_VISIBILITY
876 tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, __nat>::type const& __t)
877 _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
879 __base_.operator=(__t.__base_);
883 _LIBCPP_INLINE_VISIBILITY
884 tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, __nat>::type&& __t)
885 _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
887 __base_.operator=(static_cast<_BaseT&&>(__t.__base_));
891 template <class _Tuple,
892 class = typename enable_if
894 __tuple_assignable<_Tuple, tuple>::value
897 _LIBCPP_INLINE_VISIBILITY
899 operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<_BaseT&, _Tuple>::value))
901 __base_.operator=(_VSTD::forward<_Tuple>(__t));
905 _LIBCPP_INLINE_VISIBILITY
906 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
907 {__base_.swap(__t.__base_);}
911 class _LIBCPP_TEMPLATE_VIS tuple<>
914 _LIBCPP_INLINE_VISIBILITY
915 _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
916 template <class _Alloc>
917 _LIBCPP_INLINE_VISIBILITY
918 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
919 template <class _Alloc>
920 _LIBCPP_INLINE_VISIBILITY
921 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
923 _LIBCPP_INLINE_VISIBILITY
924 tuple(array<_Up, 0>) _NOEXCEPT {}
925 template <class _Alloc, class _Up>
926 _LIBCPP_INLINE_VISIBILITY
927 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
928 _LIBCPP_INLINE_VISIBILITY
929 void swap(tuple&) _NOEXCEPT {}
932 #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
933 // NOTE: These are not yet standardized, but are required to simulate the
934 // implicit deduction guide that should be generated had libc++ declared the
935 // tuple-like constructors "correctly"
936 template <class _Alloc, class ..._Args>
937 tuple(allocator_arg_t, const _Alloc&, tuple<_Args...> const&) -> tuple<_Args...>;
938 template <class _Alloc, class ..._Args>
939 tuple(allocator_arg_t, const _Alloc&, tuple<_Args...>&&) -> tuple<_Args...>;
942 template <class ..._Tp>
943 inline _LIBCPP_INLINE_VISIBILITY
946 __all<__is_swappable<_Tp>::value...>::value,
949 swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
950 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
955 template <size_t _Ip, class ..._Tp>
956 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
957 typename tuple_element<_Ip, tuple<_Tp...> >::type&
958 get(tuple<_Tp...>& __t) _NOEXCEPT
960 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
961 return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
964 template <size_t _Ip, class ..._Tp>
965 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
966 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
967 get(const tuple<_Tp...>& __t) _NOEXCEPT
969 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
970 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
973 template <size_t _Ip, class ..._Tp>
974 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
975 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
976 get(tuple<_Tp...>&& __t) _NOEXCEPT
978 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
979 return static_cast<type&&>(
980 static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
983 template <size_t _Ip, class ..._Tp>
984 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
985 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
986 get(const tuple<_Tp...>&& __t) _NOEXCEPT
988 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
989 return static_cast<const type&&>(
990 static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
993 #if _LIBCPP_STD_VER > 11
995 namespace __find_detail {
997 static constexpr size_t __not_found = -1;
998 static constexpr size_t __ambiguous = __not_found - 1;
1000 inline _LIBCPP_INLINE_VISIBILITY
1001 constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
1002 return !__matches ? __res :
1003 (__res == __not_found ? __curr_i : __ambiguous);
1006 template <size_t _Nx>
1007 inline _LIBCPP_INLINE_VISIBILITY
1008 constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
1009 return __i == _Nx ? __not_found :
1010 __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]);
1013 template <class _T1, class ..._Args>
1014 struct __find_exactly_one_checked {
1015 static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
1016 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
1017 static_assert(value != __not_found, "type not found in type list" );
1018 static_assert(value != __ambiguous, "type occurs more than once in type list");
1021 template <class _T1>
1022 struct __find_exactly_one_checked<_T1> {
1023 static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
1026 } // namespace __find_detail;
1028 template <typename _T1, typename... _Args>
1029 struct __find_exactly_one_t
1030 : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
1033 template <class _T1, class... _Args>
1034 inline _LIBCPP_INLINE_VISIBILITY
1035 constexpr _T1& get(tuple<_Args...>& __tup) noexcept
1037 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1040 template <class _T1, class... _Args>
1041 inline _LIBCPP_INLINE_VISIBILITY
1042 constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
1044 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1047 template <class _T1, class... _Args>
1048 inline _LIBCPP_INLINE_VISIBILITY
1049 constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
1051 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1054 template <class _T1, class... _Args>
1055 inline _LIBCPP_INLINE_VISIBILITY
1056 constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
1058 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1065 template <class ..._Tp>
1066 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1068 tie(_Tp&... __t) _NOEXCEPT
1070 return tuple<_Tp&...>(__t...);
1073 template <class _Up>
1076 template <class _Tp>
1077 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1078 const __ignore_t& operator=(_Tp&&) const {return *this;}
1082 _LIBCPP_INLINE_VAR constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
1085 template <class _Tp>
1086 struct __make_tuple_return_impl
1091 template <class _Tp>
1092 struct __make_tuple_return_impl<reference_wrapper<_Tp> >
1097 template <class _Tp>
1098 struct __make_tuple_return
1100 typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
1103 template <class... _Tp>
1104 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1105 tuple<typename __make_tuple_return<_Tp>::type...>
1106 make_tuple(_Tp&&... __t)
1108 return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
1111 template <class... _Tp>
1112 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1114 forward_as_tuple(_Tp&&... __t) _NOEXCEPT
1116 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
1119 template <size_t _Ip>
1120 struct __tuple_equal
1122 template <class _Tp, class _Up>
1123 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1124 bool operator()(const _Tp& __x, const _Up& __y)
1126 return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
1131 struct __tuple_equal<0>
1133 template <class _Tp, class _Up>
1134 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1135 bool operator()(const _Tp&, const _Up&)
1141 template <class ..._Tp, class ..._Up>
1142 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1144 operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1146 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
1149 template <class ..._Tp, class ..._Up>
1150 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1152 operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1154 return !(__x == __y);
1157 template <size_t _Ip>
1160 template <class _Tp, class _Up>
1161 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1162 bool operator()(const _Tp& __x, const _Up& __y)
1164 const size_t __idx = tuple_size<_Tp>::value - _Ip;
1165 if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
1167 if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
1169 return __tuple_less<_Ip-1>()(__x, __y);
1174 struct __tuple_less<0>
1176 template <class _Tp, class _Up>
1177 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1178 bool operator()(const _Tp&, const _Up&)
1184 template <class ..._Tp, class ..._Up>
1185 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1187 operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1189 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
1192 template <class ..._Tp, class ..._Up>
1193 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1195 operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1200 template <class ..._Tp, class ..._Up>
1201 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1203 operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1205 return !(__x < __y);
1208 template <class ..._Tp, class ..._Up>
1209 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1211 operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1213 return !(__y < __x);
1218 template <class _Tp, class _Up> struct __tuple_cat_type;
1220 template <class ..._Ttypes, class ..._Utypes>
1221 struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
1223 typedef tuple<_Ttypes..., _Utypes...> type;
1226 template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
1227 struct __tuple_cat_return_1
1231 template <class ..._Types, class _Tuple0>
1232 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
1234 typedef typename __tuple_cat_type<tuple<_Types...>,
1235 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
1239 template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
1240 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
1241 : public __tuple_cat_return_1<
1242 typename __tuple_cat_type<
1244 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
1246 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
1247 _Tuple1, _Tuples...>
1251 template <class ..._Tuples> struct __tuple_cat_return;
1253 template <class _Tuple0, class ..._Tuples>
1254 struct __tuple_cat_return<_Tuple0, _Tuples...>
1255 : public __tuple_cat_return_1<tuple<>,
1256 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
1262 struct __tuple_cat_return<>
1264 typedef tuple<> type;
1267 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1274 template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
1275 struct __tuple_cat_return_ref_imp;
1277 template <class ..._Types, size_t ..._I0, class _Tuple0>
1278 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
1280 typedef typename remove_reference<_Tuple0>::type _T0;
1281 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1282 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1285 template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1286 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1287 _Tuple0, _Tuple1, _Tuples...>
1288 : public __tuple_cat_return_ref_imp<
1289 tuple<_Types..., typename __apply_cv<_Tuple0,
1290 typename tuple_element<_I0,
1291 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1292 typename __make_tuple_indices<tuple_size<typename
1293 remove_reference<_Tuple1>::type>::value>::type,
1294 _Tuple1, _Tuples...>
1298 template <class _Tuple0, class ..._Tuples>
1299 struct __tuple_cat_return_ref
1300 : public __tuple_cat_return_ref_imp<tuple<>,
1301 typename __make_tuple_indices<
1302 tuple_size<typename remove_reference<_Tuple0>::type>::value
1303 >::type, _Tuple0, _Tuples...>
1307 template <class _Types, class _I0, class _J0>
1310 template <class ..._Types, size_t ..._I0, size_t ..._J0>
1311 struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
1313 template <class _Tuple0>
1314 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1315 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1316 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1318 return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1319 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
1322 template <class _Tuple0, class _Tuple1, class ..._Tuples>
1323 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1324 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1325 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1327 typedef typename remove_reference<_Tuple0>::type _T0;
1328 typedef typename remove_reference<_Tuple1>::type _T1;
1330 tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1331 typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1332 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
1334 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1335 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
1337 _VSTD::forward<_Tuple1>(__t1),
1338 _VSTD::forward<_Tuples>(__tpls)...);
1342 template <class _Tuple0, class... _Tuples>
1343 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1344 typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1345 tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1347 typedef typename remove_reference<_Tuple0>::type _T0;
1348 return __tuple_cat<tuple<>, __tuple_indices<>,
1349 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
1350 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1351 _VSTD::forward<_Tuples>(__tpls)...);
1354 template <class ..._Tp, class _Alloc>
1355 struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
1358 template <class _T1, class _T2>
1359 template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1360 inline _LIBCPP_INLINE_VISIBILITY
1361 pair<_T1, _T2>::pair(piecewise_construct_t,
1362 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1363 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
1364 : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
1365 second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
1369 #if _LIBCPP_STD_VER > 14
1370 template <class _Tp>
1371 _LIBCPP_INLINE_VAR constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
1373 #define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
1375 template <class _Fn, class _Tuple, size_t ..._Id>
1376 inline _LIBCPP_INLINE_VISIBILITY
1377 constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
1378 __tuple_indices<_Id...>)
1379 _LIBCPP_NOEXCEPT_RETURN(
1380 _VSTD::__invoke_constexpr(
1381 _VSTD::forward<_Fn>(__f),
1382 _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
1385 template <class _Fn, class _Tuple>
1386 inline _LIBCPP_INLINE_VISIBILITY
1387 constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
1388 _LIBCPP_NOEXCEPT_RETURN(
1389 _VSTD::__apply_tuple_impl(
1390 _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
1391 typename __make_tuple_indices<tuple_size_v<decay_t<_Tuple>>>::type{})
1394 template <class _Tp, class _Tuple, size_t... _Idx>
1395 inline _LIBCPP_INLINE_VISIBILITY
1396 constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
1397 _LIBCPP_NOEXCEPT_RETURN(
1398 _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...)
1401 template <class _Tp, class _Tuple>
1402 inline _LIBCPP_INLINE_VISIBILITY
1403 constexpr _Tp make_from_tuple(_Tuple&& __t)
1404 _LIBCPP_NOEXCEPT_RETURN(
1405 _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
1406 typename __make_tuple_indices<tuple_size_v<decay_t<_Tuple>>>::type{})
1409 #undef _LIBCPP_NOEXCEPT_RETURN
1411 #endif // _LIBCPP_STD_VER > 14
1413 #endif // !defined(_LIBCPP_CXX03_LANG)
1415 _LIBCPP_END_NAMESPACE_STD
1417 #endif // _LIBCPP_TUPLE