2 //===--------------------------- tuple ------------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
24 explicit tuple(const T&...); // constexpr in C++14
26 explicit tuple(U&&...); // constexpr in C++14
27 tuple(const tuple&) = default;
28 tuple(tuple&&) = default;
30 tuple(const tuple<U...>&); // constexpr in C++14
32 tuple(tuple<U...>&&); // constexpr in C++14
33 template <class U1, class U2>
34 tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
35 template <class U1, class U2>
36 tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
38 // allocator-extended constructors
39 template <class Alloc>
40 tuple(allocator_arg_t, const Alloc& a);
41 template <class Alloc>
42 tuple(allocator_arg_t, const Alloc& a, const T&...);
43 template <class Alloc, class... U>
44 tuple(allocator_arg_t, const Alloc& a, U&&...);
45 template <class Alloc>
46 tuple(allocator_arg_t, const Alloc& a, const tuple&);
47 template <class Alloc>
48 tuple(allocator_arg_t, const Alloc& a, tuple&&);
49 template <class Alloc, class... U>
50 tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
51 template <class Alloc, class... U>
52 tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
53 template <class Alloc, class U1, class U2>
54 tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
55 template <class Alloc, class U1, class U2>
56 tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
58 tuple& operator=(const tuple&);
60 operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
62 tuple& operator=(const tuple<U...>&);
64 tuple& operator=(tuple<U...>&&);
65 template <class U1, class U2>
66 tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
67 template <class U1, class U2>
68 tuple& operator=(pair<U1, U2>&&); //iffsizeof...(T) == 2
70 void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
73 const unspecified ignore;
75 template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
76 template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
77 template <class... T> tuple<T&...> tie(T&...) noexcept; // 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 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_HAS_NO_VARIADICS
155 template <class ..._Tp>
156 class _LIBCPP_TYPE_VIS_ONLY tuple_size<tuple<_Tp...> >
157 : public integral_constant<size_t, sizeof...(_Tp)>
163 template <size_t _Ip, class ..._Tp>
164 class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> >
167 typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
170 #if _LIBCPP_STD_VER > 11
171 template <size_t _Ip, class ..._Tp>
172 using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
177 template <size_t _Ip, class _Hp,
178 bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
182 template <size_t _Ip, class _Hp, bool _Ep>
183 inline _LIBCPP_INLINE_VISIBILITY
184 void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
185 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
187 swap(__x.get(), __y.get());
190 template <size_t _Ip, class _Hp, bool>
195 __tuple_leaf& operator=(const __tuple_leaf&);
197 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
198 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value()
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, 0>, const _Alloc&)
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, 1>, const _Alloc& __a)
212 : value(allocator_arg_t(), __a)
213 {static_assert(!is_reference<_Hp>::value,
214 "Attempted to default construct a reference element in a tuple");}
216 template <class _Alloc>
217 _LIBCPP_INLINE_VISIBILITY
218 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
220 {static_assert(!is_reference<_Hp>::value,
221 "Attempted to default construct a reference element in a tuple");}
224 class = typename enable_if<
226 __lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
227 , is_constructible<_Hp, _Tp>
231 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
232 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
233 : value(_VSTD::forward<_Tp>(__t))
234 {static_assert(!is_reference<_Hp>::value ||
235 (is_lvalue_reference<_Hp>::value &&
236 (is_lvalue_reference<_Tp>::value ||
237 is_same<typename remove_reference<_Tp>::type,
239 typename remove_reference<_Hp>::type
242 (is_rvalue_reference<_Hp>::value &&
243 !is_lvalue_reference<_Tp>::value),
244 "Attempted to construct a reference element in a tuple with an rvalue");}
246 template <class _Tp, class _Alloc>
247 _LIBCPP_INLINE_VISIBILITY
248 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
249 : value(_VSTD::forward<_Tp>(__t))
250 {static_assert(!is_lvalue_reference<_Hp>::value ||
251 (is_lvalue_reference<_Hp>::value &&
252 (is_lvalue_reference<_Tp>::value ||
253 is_same<typename remove_reference<_Tp>::type,
255 typename remove_reference<_Hp>::type
258 "Attempted to construct a reference element in a tuple with an rvalue");}
260 template <class _Tp, class _Alloc>
261 _LIBCPP_INLINE_VISIBILITY
262 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
263 : value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
264 {static_assert(!is_lvalue_reference<_Hp>::value ||
265 (is_lvalue_reference<_Hp>::value &&
266 (is_lvalue_reference<_Tp>::value ||
267 is_same<typename remove_reference<_Tp>::type,
269 typename remove_reference<_Hp>::type
272 "Attempted to construct a reference element in a tuple with an rvalue");}
274 template <class _Tp, class _Alloc>
275 _LIBCPP_INLINE_VISIBILITY
276 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
277 : value(_VSTD::forward<_Tp>(__t), __a)
278 {static_assert(!is_lvalue_reference<_Hp>::value ||
279 (is_lvalue_reference<_Hp>::value &&
280 (is_lvalue_reference<_Tp>::value ||
281 is_same<typename remove_reference<_Tp>::type,
283 typename remove_reference<_Hp>::type
286 "Attempted to construct a reference element in a tuple with an rvalue");}
288 __tuple_leaf(const __tuple_leaf& __t) = default;
289 __tuple_leaf(__tuple_leaf&& __t) = default;
292 _LIBCPP_INLINE_VISIBILITY
294 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
296 value = _VSTD::forward<_Tp>(__t);
300 _LIBCPP_INLINE_VISIBILITY
301 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
303 _VSTD::swap(*this, __t);
307 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return value;}
308 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return value;}
311 template <size_t _Ip, class _Hp>
312 class __tuple_leaf<_Ip, _Hp, true>
316 __tuple_leaf& operator=(const __tuple_leaf&);
318 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
319 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
321 template <class _Alloc>
322 _LIBCPP_INLINE_VISIBILITY
323 __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
325 template <class _Alloc>
326 _LIBCPP_INLINE_VISIBILITY
327 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
328 : _Hp(allocator_arg_t(), __a) {}
330 template <class _Alloc>
331 _LIBCPP_INLINE_VISIBILITY
332 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
336 class = typename enable_if<
338 __lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
339 , is_constructible<_Hp, _Tp>
343 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
344 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
345 : _Hp(_VSTD::forward<_Tp>(__t)) {}
347 template <class _Tp, class _Alloc>
348 _LIBCPP_INLINE_VISIBILITY
349 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
350 : _Hp(_VSTD::forward<_Tp>(__t)) {}
352 template <class _Tp, class _Alloc>
353 _LIBCPP_INLINE_VISIBILITY
354 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
355 : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
357 template <class _Tp, class _Alloc>
358 _LIBCPP_INLINE_VISIBILITY
359 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
360 : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
362 __tuple_leaf(__tuple_leaf const &) = default;
363 __tuple_leaf(__tuple_leaf &&) = default;
366 _LIBCPP_INLINE_VISIBILITY
368 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
370 _Hp::operator=(_VSTD::forward<_Tp>(__t));
374 _LIBCPP_INLINE_VISIBILITY
376 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
378 _VSTD::swap(*this, __t);
382 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
383 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
386 template <class ..._Tp>
387 _LIBCPP_INLINE_VISIBILITY
388 void __swallow(_Tp&&...) _NOEXCEPT {}
390 template <class ..._Tp>
391 struct __lazy_all : __all<_Tp::value...> {};
394 struct __all_default_constructible;
396 template <class ..._Tp>
397 struct __all_default_constructible<__tuple_types<_Tp...>>
398 : __all<is_default_constructible<_Tp>::value...>
403 template<class _Indx, class ..._Tp> struct __tuple_impl;
405 template<size_t ..._Indx, class ..._Tp>
406 struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
407 : public __tuple_leaf<_Indx, _Tp>...
409 _LIBCPP_INLINE_VISIBILITY
410 _LIBCPP_CONSTEXPR __tuple_impl()
411 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
413 template <size_t ..._Uf, class ..._Tf,
414 size_t ..._Ul, class ..._Tl, class ..._Up>
415 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
417 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
418 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
420 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
421 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
422 __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
423 __tuple_leaf<_Ul, _Tl>()...
426 template <class _Alloc, size_t ..._Uf, class ..._Tf,
427 size_t ..._Ul, class ..._Tl, class ..._Up>
428 _LIBCPP_INLINE_VISIBILITY
430 __tuple_impl(allocator_arg_t, const _Alloc& __a,
431 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
432 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
434 __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
435 _VSTD::forward<_Up>(__u))...,
436 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
439 template <class _Tuple,
440 class = typename enable_if
442 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
445 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
446 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
447 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
448 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
449 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
452 template <class _Alloc, class _Tuple,
453 class = typename enable_if
455 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
458 _LIBCPP_INLINE_VISIBILITY
459 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
460 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
461 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
462 _VSTD::forward<typename tuple_element<_Indx,
463 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
466 template <class _Tuple>
467 _LIBCPP_INLINE_VISIBILITY
470 __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
473 operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
474 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
476 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
477 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
481 __tuple_impl(const __tuple_impl&) = default;
482 __tuple_impl(__tuple_impl&&) = default;
484 _LIBCPP_INLINE_VISIBILITY
486 operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
488 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
492 _LIBCPP_INLINE_VISIBILITY
494 operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
496 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
500 _LIBCPP_INLINE_VISIBILITY
501 void swap(__tuple_impl& __t)
502 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
504 __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
508 template <bool _IsTuple, class _SizeTrait, size_t _Expected>
509 struct __tuple_like_with_size_imp : false_type {};
511 template <class _SizeTrait, size_t _Expected>
512 struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
513 : integral_constant<bool, _SizeTrait::value == _Expected> {};
515 template <class _Tuple, size_t _ExpectedSize,
516 class _RawTuple = typename __uncvref<_Tuple>::type>
517 using __tuple_like_with_size = __tuple_like_with_size_imp<
518 __tuple_like<_RawTuple>::value,
519 tuple_size<_RawTuple>, _ExpectedSize
523 struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
525 static constexpr bool __enable_explicit() { return false; }
527 static constexpr bool __enable_implicit() { return false; }
530 template <class ..._Tp>
531 class _LIBCPP_TYPE_VIS_ONLY tuple
533 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
537 template <class ..._Args>
538 struct _PackExpandsToThisTuple : false_type {};
540 template <class _Arg>
541 struct _PackExpandsToThisTuple<_Arg>
542 : is_same<typename __uncvref<_Arg>::type, tuple> {};
544 template <bool _MaybeEnable, class _Dummy = void>
545 struct _CheckArgsConstructor : __check_tuple_constructor_fail {};
547 template <class _Dummy>
548 struct _CheckArgsConstructor<true, _Dummy>
550 template <class ..._Args>
551 static constexpr bool __enable_explicit() {
553 __tuple_constructible<
555 typename __make_tuple_types<tuple,
556 sizeof...(_Args) < sizeof...(_Tp) ?
558 sizeof...(_Tp)>::type
560 !__tuple_convertible<
562 typename __make_tuple_types<tuple,
563 sizeof...(_Args) < sizeof...(_Tp) ?
565 sizeof...(_Tp)>::type
567 __all_default_constructible<
568 typename __make_tuple_types<tuple, sizeof...(_Tp),
569 sizeof...(_Args) < sizeof...(_Tp) ?
571 sizeof...(_Tp)>::type
575 template <class ..._Args>
576 static constexpr bool __enable_implicit() {
580 typename __make_tuple_types<tuple,
581 sizeof...(_Args) < sizeof...(_Tp) ?
583 sizeof...(_Tp)>::type
585 __all_default_constructible<
586 typename __make_tuple_types<tuple, sizeof...(_Tp),
587 sizeof...(_Args) < sizeof...(_Tp) ?
589 sizeof...(_Tp)>::type
594 template <bool _MaybeEnable,
595 bool = sizeof...(_Tp) == 1,
597 struct _CheckTupleLikeConstructor : __check_tuple_constructor_fail {};
599 template <class _Dummy>
600 struct _CheckTupleLikeConstructor<true, false, _Dummy>
602 template <class _Tuple>
603 static constexpr bool __enable_implicit() {
604 return __tuple_convertible<_Tuple, tuple>::value;
607 template <class _Tuple>
608 static constexpr bool __enable_explicit() {
609 return __tuple_constructible<_Tuple, tuple>::value
610 && !__tuple_convertible<_Tuple, tuple>::value;
614 template <class _Dummy>
615 struct _CheckTupleLikeConstructor<true, true, _Dummy>
617 // This trait is used to disable the tuple-like constructor when
618 // the UTypes... constructor should be selected instead.
619 // See LWG issue #2549.
620 template <class _Tuple>
621 using _PreferTupleLikeConstructor = __lazy_or<
622 // Don't attempt the two checks below if the tuple we are given
623 // has the same type as this tuple.
624 is_same<typename __uncvref<_Tuple>::type, tuple>,
626 __lazy_not<is_constructible<_Tp..., _Tuple>>,
627 __lazy_not<is_convertible<_Tuple, _Tp...>>
631 template <class _Tuple>
632 static constexpr bool __enable_implicit() {
634 __tuple_convertible<_Tuple, tuple>,
635 _PreferTupleLikeConstructor<_Tuple>
639 template <class _Tuple>
640 static constexpr bool __enable_explicit() {
642 __tuple_constructible<_Tuple, tuple>,
643 _PreferTupleLikeConstructor<_Tuple>,
644 __lazy_not<__tuple_convertible<_Tuple, tuple>>
649 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
650 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
651 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
652 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
653 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
654 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
655 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
656 const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
659 template <bool _Dummy = true, class = typename enable_if<
660 __all<__dependent_type<is_default_constructible<_Tp>, _Dummy>::value...>::value
662 _LIBCPP_INLINE_VISIBILITY
663 _LIBCPP_CONSTEXPR tuple()
664 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
666 template <class _AllocArgT, class _Alloc, bool _Dummy = true, class = typename enable_if<
668 is_same<allocator_arg_t, _AllocArgT>,
669 __lazy_all<__dependent_type<is_default_constructible<_Tp>, _Dummy>...>
672 _LIBCPP_INLINE_VISIBILITY
673 tuple(_AllocArgT, _Alloc const& __a)
674 : base_(allocator_arg_t(), __a,
675 __tuple_indices<>(), __tuple_types<>(),
676 typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
677 __tuple_types<_Tp...>()) {}
679 template <bool _Dummy = true,
682 _CheckArgsConstructor<
684 >::template __enable_implicit<_Tp const&...>(),
688 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
689 tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
690 : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
691 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
692 typename __make_tuple_indices<0>::type(),
693 typename __make_tuple_types<tuple, 0>::type(),
697 template <bool _Dummy = true,
700 _CheckArgsConstructor<
702 >::template __enable_explicit<_Tp const&...>(),
706 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
707 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
708 : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
709 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
710 typename __make_tuple_indices<0>::type(),
711 typename __make_tuple_types<tuple, 0>::type(),
715 template <class _Alloc, bool _Dummy = true,
718 _CheckArgsConstructor<
720 >::template __enable_implicit<_Tp const&...>(),
724 _LIBCPP_INLINE_VISIBILITY
725 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
726 : base_(allocator_arg_t(), __a,
727 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
728 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
729 typename __make_tuple_indices<0>::type(),
730 typename __make_tuple_types<tuple, 0>::type(),
734 template <class _Alloc, bool _Dummy = true,
737 _CheckArgsConstructor<
739 >::template __enable_explicit<_Tp const&...>(),
743 _LIBCPP_INLINE_VISIBILITY
745 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
746 : base_(allocator_arg_t(), __a,
747 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
748 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
749 typename __make_tuple_indices<0>::type(),
750 typename __make_tuple_types<tuple, 0>::type(),
754 template <class ..._Up,
757 _CheckArgsConstructor<
758 sizeof...(_Up) <= sizeof...(_Tp)
759 && !_PackExpandsToThisTuple<_Up...>::value
760 >::template __enable_implicit<_Up...>(),
764 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
767 is_nothrow_constructible<base,
768 typename __make_tuple_indices<sizeof...(_Up)>::type,
769 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
770 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
771 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
775 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
776 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
777 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
778 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
779 _VSTD::forward<_Up>(__u)...) {}
781 template <class ..._Up,
784 _CheckArgsConstructor<
785 sizeof...(_Up) <= sizeof...(_Tp)
786 && !_PackExpandsToThisTuple<_Up...>::value
787 >::template __enable_explicit<_Up...>(),
791 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
795 is_nothrow_constructible<base,
796 typename __make_tuple_indices<sizeof...(_Up)>::type,
797 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
798 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
799 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
803 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
804 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
805 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
806 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
807 _VSTD::forward<_Up>(__u)...) {}
809 template <class _Alloc, class ..._Up,
812 _CheckArgsConstructor<
813 sizeof...(_Up) == sizeof...(_Tp) &&
814 !_PackExpandsToThisTuple<_Up...>::value
815 >::template __enable_implicit<_Up...>(),
819 _LIBCPP_INLINE_VISIBILITY
820 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
821 : base_(allocator_arg_t(), __a,
822 typename __make_tuple_indices<sizeof...(_Up)>::type(),
823 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
824 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
825 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
826 _VSTD::forward<_Up>(__u)...) {}
828 template <class _Alloc, class ..._Up,
831 _CheckArgsConstructor<
832 sizeof...(_Up) == sizeof...(_Tp) &&
833 !_PackExpandsToThisTuple<_Up...>::value
834 >::template __enable_explicit<_Up...>(),
838 _LIBCPP_INLINE_VISIBILITY
840 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
841 : base_(allocator_arg_t(), __a,
842 typename __make_tuple_indices<sizeof...(_Up)>::type(),
843 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
844 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
845 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
846 _VSTD::forward<_Up>(__u)...) {}
848 template <class _Tuple,
851 _CheckTupleLikeConstructor<
852 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
853 && !_PackExpandsToThisTuple<_Tuple>::value
854 >::template __enable_implicit<_Tuple>(),
858 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
859 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
860 : base_(_VSTD::forward<_Tuple>(__t)) {}
862 template <class _Tuple,
865 _CheckTupleLikeConstructor<
866 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
867 && !_PackExpandsToThisTuple<_Tuple>::value
868 >::template __enable_explicit<_Tuple>(),
872 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
874 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
875 : base_(_VSTD::forward<_Tuple>(__t)) {}
877 template <class _Alloc, class _Tuple,
880 _CheckTupleLikeConstructor<
881 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
882 >::template __enable_implicit<_Tuple>(),
886 _LIBCPP_INLINE_VISIBILITY
887 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
888 : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
890 template <class _Alloc, class _Tuple,
893 _CheckTupleLikeConstructor<
894 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
895 >::template __enable_explicit<_Tuple>(),
899 _LIBCPP_INLINE_VISIBILITY
901 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
902 : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
904 template <class _Tuple,
905 class = typename enable_if
907 __tuple_assignable<_Tuple, tuple>::value
910 _LIBCPP_INLINE_VISIBILITY
912 operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value))
914 base_.operator=(_VSTD::forward<_Tuple>(__t));
918 _LIBCPP_INLINE_VISIBILITY
919 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
920 {base_.swap(__t.base_);}
924 class _LIBCPP_TYPE_VIS_ONLY tuple<>
927 _LIBCPP_INLINE_VISIBILITY
928 _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
929 template <class _Alloc>
930 _LIBCPP_INLINE_VISIBILITY
931 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
932 template <class _Alloc>
933 _LIBCPP_INLINE_VISIBILITY
934 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
936 _LIBCPP_INLINE_VISIBILITY
937 tuple(array<_Up, 0>) _NOEXCEPT {}
938 template <class _Alloc, class _Up>
939 _LIBCPP_INLINE_VISIBILITY
940 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
941 _LIBCPP_INLINE_VISIBILITY
942 void swap(tuple&) _NOEXCEPT {}
945 template <class ..._Tp>
946 inline _LIBCPP_INLINE_VISIBILITY
949 __all<__is_swappable<_Tp>::value...>::value,
952 swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
953 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
958 template <size_t _Ip, class ..._Tp>
959 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
960 typename tuple_element<_Ip, tuple<_Tp...> >::type&
961 get(tuple<_Tp...>& __t) _NOEXCEPT
963 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
964 return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get();
967 template <size_t _Ip, class ..._Tp>
968 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
969 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
970 get(const tuple<_Tp...>& __t) _NOEXCEPT
972 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
973 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
976 template <size_t _Ip, class ..._Tp>
977 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
978 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
979 get(tuple<_Tp...>&& __t) _NOEXCEPT
981 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
982 return static_cast<type&&>(
983 static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
986 template <size_t _Ip, class ..._Tp>
987 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
988 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
989 get(const tuple<_Tp...>&& __t) _NOEXCEPT
991 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
992 return static_cast<const type&&>(
993 static_cast<const __tuple_leaf<_Ip, type>&&>(__t.base_).get());
996 #if _LIBCPP_STD_VER > 11
998 namespace __find_detail {
1000 static constexpr size_t __not_found = -1;
1001 static constexpr size_t __ambiguous = __not_found - 1;
1003 inline _LIBCPP_INLINE_VISIBILITY
1004 constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
1005 return !__matches ? __res :
1006 (__res == __not_found ? __curr_i : __ambiguous);
1009 template <size_t _Nx>
1010 inline _LIBCPP_INLINE_VISIBILITY
1011 constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
1012 return __i == _Nx ? __not_found :
1013 __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]);
1016 template <class _T1, class ..._Args>
1017 struct __find_exactly_one_checked {
1018 static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
1019 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
1020 static_assert (value != __not_found, "type not found in type list" );
1021 static_assert(value != __ambiguous,"type occurs more than once in type list");
1024 template <class _T1>
1025 struct __find_exactly_one_checked<_T1> {
1026 static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
1029 } // namespace __find_detail;
1031 template <typename _T1, typename... _Args>
1032 struct __find_exactly_one_t
1033 : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
1036 template <class _T1, class... _Args>
1037 inline _LIBCPP_INLINE_VISIBILITY
1038 constexpr _T1& get(tuple<_Args...>& __tup) noexcept
1040 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1043 template <class _T1, class... _Args>
1044 inline _LIBCPP_INLINE_VISIBILITY
1045 constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
1047 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1050 template <class _T1, class... _Args>
1051 inline _LIBCPP_INLINE_VISIBILITY
1052 constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
1054 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1057 template <class _T1, class... _Args>
1058 inline _LIBCPP_INLINE_VISIBILITY
1059 constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
1061 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1068 template <class ..._Tp>
1069 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1071 tie(_Tp&... __t) _NOEXCEPT
1073 return tuple<_Tp&...>(__t...);
1076 template <class _Up>
1079 template <class _Tp>
1080 _LIBCPP_INLINE_VISIBILITY
1081 const __ignore_t& operator=(_Tp&&) const {return *this;}
1084 namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
1086 template <class _Tp>
1087 struct __make_tuple_return_impl
1092 template <class _Tp>
1093 struct __make_tuple_return_impl<reference_wrapper<_Tp> >
1098 template <class _Tp>
1099 struct __make_tuple_return
1101 typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
1104 template <class... _Tp>
1105 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1106 tuple<typename __make_tuple_return<_Tp>::type...>
1107 make_tuple(_Tp&&... __t)
1109 return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
1112 template <class... _Tp>
1113 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1115 forward_as_tuple(_Tp&&... __t) _NOEXCEPT
1117 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
1120 template <size_t _Ip>
1121 struct __tuple_equal
1123 template <class _Tp, class _Up>
1124 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1125 bool operator()(const _Tp& __x, const _Up& __y)
1127 return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
1132 struct __tuple_equal<0>
1134 template <class _Tp, class _Up>
1135 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1136 bool operator()(const _Tp&, const _Up&)
1142 template <class ..._Tp, class ..._Up>
1143 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1145 operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1147 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
1150 template <class ..._Tp, class ..._Up>
1151 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1153 operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1155 return !(__x == __y);
1158 template <size_t _Ip>
1161 template <class _Tp, class _Up>
1162 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1163 bool operator()(const _Tp& __x, const _Up& __y)
1165 const size_t __idx = tuple_size<_Tp>::value - _Ip;
1166 if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
1168 if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
1170 return __tuple_less<_Ip-1>()(__x, __y);
1175 struct __tuple_less<0>
1177 template <class _Tp, class _Up>
1178 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1179 bool operator()(const _Tp&, const _Up&)
1185 template <class ..._Tp, class ..._Up>
1186 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1188 operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1190 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
1193 template <class ..._Tp, class ..._Up>
1194 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1196 operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1201 template <class ..._Tp, class ..._Up>
1202 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1204 operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1206 return !(__x < __y);
1209 template <class ..._Tp, class ..._Up>
1210 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1212 operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1214 return !(__y < __x);
1219 template <class _Tp, class _Up> struct __tuple_cat_type;
1221 template <class ..._Ttypes, class ..._Utypes>
1222 struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
1224 typedef tuple<_Ttypes..., _Utypes...> type;
1227 template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
1228 struct __tuple_cat_return_1
1232 template <class ..._Types, class _Tuple0>
1233 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
1235 typedef typename __tuple_cat_type<tuple<_Types...>,
1236 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
1240 template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
1241 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
1242 : public __tuple_cat_return_1<
1243 typename __tuple_cat_type<
1245 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
1247 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
1248 _Tuple1, _Tuples...>
1252 template <class ..._Tuples> struct __tuple_cat_return;
1254 template <class _Tuple0, class ..._Tuples>
1255 struct __tuple_cat_return<_Tuple0, _Tuples...>
1256 : public __tuple_cat_return_1<tuple<>,
1257 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
1263 struct __tuple_cat_return<>
1265 typedef tuple<> type;
1268 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1275 template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
1276 struct __tuple_cat_return_ref_imp;
1278 template <class ..._Types, size_t ..._I0, class _Tuple0>
1279 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
1281 typedef typename remove_reference<_Tuple0>::type _T0;
1282 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1283 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1286 template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1287 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1288 _Tuple0, _Tuple1, _Tuples...>
1289 : public __tuple_cat_return_ref_imp<
1290 tuple<_Types..., typename __apply_cv<_Tuple0,
1291 typename tuple_element<_I0,
1292 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1293 typename __make_tuple_indices<tuple_size<typename
1294 remove_reference<_Tuple1>::type>::value>::type,
1295 _Tuple1, _Tuples...>
1299 template <class _Tuple0, class ..._Tuples>
1300 struct __tuple_cat_return_ref
1301 : public __tuple_cat_return_ref_imp<tuple<>,
1302 typename __make_tuple_indices<
1303 tuple_size<typename remove_reference<_Tuple0>::type>::value
1304 >::type, _Tuple0, _Tuples...>
1308 template <class _Types, class _I0, class _J0>
1311 template <class ..._Types, size_t ..._I0, size_t ..._J0>
1312 struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
1314 template <class _Tuple0>
1315 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1316 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1317 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1319 return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1320 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
1323 template <class _Tuple0, class _Tuple1, class ..._Tuples>
1324 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1325 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1326 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1328 typedef typename remove_reference<_Tuple0>::type _T0;
1329 typedef typename remove_reference<_Tuple1>::type _T1;
1331 tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1332 typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1333 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
1335 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1336 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
1338 _VSTD::forward<_Tuple1>(__t1),
1339 _VSTD::forward<_Tuples>(__tpls)...);
1343 template <class _Tuple0, class... _Tuples>
1344 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1345 typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1346 tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1348 typedef typename remove_reference<_Tuple0>::type _T0;
1349 return __tuple_cat<tuple<>, __tuple_indices<>,
1350 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
1351 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1352 _VSTD::forward<_Tuples>(__tpls)...);
1355 template <class ..._Tp, class _Alloc>
1356 struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc>
1359 template <class _T1, class _T2>
1360 template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1361 inline _LIBCPP_INLINE_VISIBILITY
1362 pair<_T1, _T2>::pair(piecewise_construct_t,
1363 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1364 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
1365 : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
1366 second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
1370 #endif // _LIBCPP_HAS_NO_VARIADICS
1372 #if _LIBCPP_STD_VER > 14
1373 template <class _Tp>
1374 constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
1376 #define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
1378 template <class _Fn, class _Tuple, size_t ..._Id>
1379 inline _LIBCPP_INLINE_VISIBILITY
1380 constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
1381 __tuple_indices<_Id...>)
1382 _LIBCPP_NOEXCEPT_RETURN(
1383 _VSTD::__invoke_constexpr(
1384 _VSTD::forward<_Fn>(__f),
1385 _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
1388 template <class _Fn, class _Tuple>
1389 inline _LIBCPP_INLINE_VISIBILITY
1390 constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
1391 _LIBCPP_NOEXCEPT_RETURN(
1392 _VSTD::__apply_tuple_impl(
1393 _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
1394 typename __make_tuple_indices<tuple_size_v<decay_t<_Tuple>>>::type{})
1397 template <class _Tp, class _Tuple, size_t... _Idx>
1398 inline _LIBCPP_INLINE_VISIBILITY
1399 constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
1400 _LIBCPP_NOEXCEPT_RETURN(
1401 _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...)
1404 template <class _Tp, class _Tuple>
1405 inline _LIBCPP_INLINE_VISIBILITY
1406 constexpr _Tp make_from_tuple(_Tuple&& __t)
1407 _LIBCPP_NOEXCEPT_RETURN(
1408 _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
1409 typename __make_tuple_indices<tuple_size_v<decay_t<_Tuple>>>::type{})
1412 #undef _LIBCPP_NOEXCEPT_RETURN
1414 #endif // _LIBCPP_STD_VER > 14
1416 _LIBCPP_END_NAMESPACE_STD
1418 #endif // _LIBCPP_TUPLE