2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
22 explicit(see-below) constexpr tuple();
23 explicit(see-below) tuple(const T&...); // constexpr in C++14
25 explicit(see-below) tuple(U&&...); // constexpr in C++14
26 tuple(const tuple&) = default;
27 tuple(tuple&&) = default;
29 template<class... UTypes>
30 constexpr explicit(see-below) tuple(tuple<UTypes...>&); // C++23
32 explicit(see-below) tuple(const tuple<U...>&); // constexpr in C++14
34 explicit(see-below) tuple(tuple<U...>&&); // constexpr in C++14
35 template<class... UTypes>
36 constexpr explicit(see-below) tuple(const tuple<UTypes...>&&); // C++23
38 template<class U1, class U2>
39 constexpr explicit(see-below) tuple(pair<U1, U2>&); // iff sizeof...(Types) == 2 // C++23
40 template <class U1, class U2>
41 explicit(see-below) tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
42 template <class U1, class U2>
43 explicit(see-below) tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
44 template<class U1, class U2>
45 constexpr explicit(see-below) tuple(const pair<U1, U2>&&); // iff sizeof...(Types) == 2 // C++23
47 // allocator-extended constructors
48 template <class Alloc>
49 tuple(allocator_arg_t, const Alloc& a);
50 template <class Alloc>
51 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const T&...); // constexpr in C++20
52 template <class Alloc, class... U>
53 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, U&&...); // constexpr in C++20
54 template <class Alloc>
55 tuple(allocator_arg_t, const Alloc& a, const tuple&); // constexpr in C++20
56 template <class Alloc>
57 tuple(allocator_arg_t, const Alloc& a, tuple&&); // constexpr in C++20
58 template<class Alloc, class... UTypes>
59 constexpr explicit(see-below)
60 tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&); // C++23
61 template <class Alloc, class... U>
62 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&); // constexpr in C++20
63 template <class Alloc, class... U>
64 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&); // constexpr in C++20
65 template<class Alloc, class... UTypes>
66 constexpr explicit(see-below)
67 tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&&); // C++23
68 template<class Alloc, class U1, class U2>
69 constexpr explicit(see-below)
70 tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&); // C++23
71 template <class Alloc, class U1, class U2>
72 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&); // constexpr in C++20
73 template <class Alloc, class U1, class U2>
74 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&); // constexpr in C++20
75 template<class Alloc, class U1, class U2>
76 constexpr explicit(see-below)
77 tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&&); // C++23
79 tuple& operator=(const tuple&); // constexpr in C++20
80 constexpr const tuple& operator=(const tuple&) const; // C++23
81 tuple& operator=(tuple&&) noexcept(is_nothrow_move_assignable_v<T> && ...); // constexpr in C++20
82 constexpr const tuple& operator=(tuple&&) const; // C++23
84 tuple& operator=(const tuple<U...>&); // constexpr in C++20
85 template<class... UTypes>
86 constexpr const tuple& operator=(const tuple<UTypes...>&) const; // C++23
88 tuple& operator=(tuple<U...>&&); // constexpr in C++20
89 template<class... UTypes>
90 constexpr const tuple& operator=(tuple<UTypes...>&&) const; // C++23
91 template <class U1, class U2>
92 tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++20
93 template<class U1, class U2>
94 constexpr const tuple& operator=(const pair<U1, U2>&) const; // iff sizeof...(Types) == 2 // C++23
95 template <class U1, class U2>
96 tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++20
97 template<class U1, class U2>
98 constexpr const tuple& operator=(pair<U1, U2>&&) const; // iff sizeof...(Types) == 2 // C++23
100 template<class U, size_t N>
101 tuple& operator=(array<U, N> const&) // iff sizeof...(T) == N, EXTENSION
102 template<class U, size_t N>
103 tuple& operator=(array<U, N>&&) // iff sizeof...(T) == N, EXTENSION
105 void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); // constexpr in C++20
106 constexpr void swap(const tuple&) const noexcept(see-below); // C++23
110 template<class... TTypes, class... UTypes, template<class> class TQual, template<class> class UQual> // since C++23
111 requires requires { typename tuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...>; }
112 struct basic_common_reference<tuple<TTypes...>, tuple<UTypes...>, TQual, UQual> {
113 using type = tuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...>;
116 template<class... TTypes, class... UTypes> // since C++23
117 requires requires { typename tuple<common_type_t<TTypes, UTypes>...>; }
118 struct common_type<tuple<TTypes...>, tuple<UTypes...>> {
119 using type = tuple<common_type_t<TTypes, UTypes>...>;
122 template <class ...T>
123 tuple(T...) -> tuple<T...>; // since C++17
124 template <class T1, class T2>
125 tuple(pair<T1, T2>) -> tuple<T1, T2>; // since C++17
126 template <class Alloc, class ...T>
127 tuple(allocator_arg_t, Alloc, T...) -> tuple<T...>; // since C++17
128 template <class Alloc, class T1, class T2>
129 tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; // since C++17
130 template <class Alloc, class ...T>
131 tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>; // since C++17
133 inline constexpr unspecified ignore;
135 template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
136 template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
137 template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
138 template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
140 // [tuple.apply], calling a function with a tuple of arguments:
141 template <class F, class Tuple>
142 constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17
143 template <class T, class Tuple>
144 constexpr T make_from_tuple(Tuple&& t); // C++17
146 // 20.4.1.4, tuple helper classes:
147 template <class T> struct tuple_size; // undefined
148 template <class... T> struct tuple_size<tuple<T...>>;
150 inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
151 template <size_t I, class T> struct tuple_element; // undefined
152 template <size_t I, class... T> struct tuple_element<I, tuple<T...>>;
153 template <size_t I, class T>
154 using tuple_element_t = typename tuple_element <I, T>::type; // C++14
156 // 20.4.1.5, element access:
157 template <size_t I, class... T>
158 typename tuple_element<I, tuple<T...>>::type&
159 get(tuple<T...>&) noexcept; // constexpr in C++14
160 template <size_t I, class... T>
161 const typename tuple_element<I, tuple<T...>>::type&
162 get(const tuple<T...>&) noexcept; // constexpr in C++14
163 template <size_t I, class... T>
164 typename tuple_element<I, tuple<T...>>::type&&
165 get(tuple<T...>&&) noexcept; // constexpr in C++14
166 template <size_t I, class... T>
167 const typename tuple_element<I, tuple<T...>>::type&&
168 get(const tuple<T...>&&) noexcept; // constexpr in C++14
170 template <class T1, class... T>
171 constexpr T1& get(tuple<T...>&) noexcept; // C++14
172 template <class T1, class... T>
173 constexpr const T1& get(const tuple<T...>&) noexcept; // C++14
174 template <class T1, class... T>
175 constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
176 template <class T1, class... T>
177 constexpr const T1&& get(const tuple<T...>&&) noexcept; // C++14
179 // 20.4.1.6, relational operators:
180 template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
181 template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
182 template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
183 template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
184 template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
185 template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
186 template<class... T, class... U>
187 constexpr common_comparison_category_t<synth-three-way-result<T, U>...>
188 operator<=>(const tuple<T...>&, const tuple<U...>&); // since C++20
190 template <class... Types, class Alloc>
191 struct uses_allocator<tuple<Types...>, Alloc>;
193 template <class... Types>
195 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
197 template <class... Types>
198 constexpr void swap(const tuple<Types...>& x, const tuple<Types...>& y) noexcept(see-below); // C++23
204 #include <__assert> // all public C++ headers provide the assertion handler
205 #include <__compare/common_comparison_category.h>
206 #include <__compare/synth_three_way.h>
208 #include <__functional/invoke.h>
209 #include <__fwd/array.h>
210 #include <__fwd/get.h>
211 #include <__fwd/tuple.h>
212 #include <__memory/allocator_arg_t.h>
213 #include <__memory/uses_allocator.h>
214 #include <__tuple/make_tuple_types.h>
215 #include <__tuple/sfinae_helpers.h>
216 #include <__tuple/tuple_element.h>
217 #include <__tuple/tuple_indices.h>
218 #include <__tuple/tuple_like_ext.h>
219 #include <__tuple/tuple_size.h>
220 #include <__tuple/tuple_types.h>
221 #include <__type_traits/apply_cv.h>
222 #include <__type_traits/common_reference.h>
223 #include <__type_traits/common_type.h>
224 #include <__type_traits/conditional.h>
225 #include <__type_traits/conjunction.h>
226 #include <__type_traits/copy_cvref.h>
227 #include <__type_traits/disjunction.h>
228 #include <__type_traits/is_arithmetic.h>
229 #include <__type_traits/is_assignable.h>
230 #include <__type_traits/is_constructible.h>
231 #include <__type_traits/is_convertible.h>
232 #include <__type_traits/is_copy_assignable.h>
233 #include <__type_traits/is_copy_constructible.h>
234 #include <__type_traits/is_default_constructible.h>
235 #include <__type_traits/is_empty.h>
236 #include <__type_traits/is_final.h>
237 #include <__type_traits/is_implicitly_default_constructible.h>
238 #include <__type_traits/is_move_assignable.h>
239 #include <__type_traits/is_move_constructible.h>
240 #include <__type_traits/is_nothrow_assignable.h>
241 #include <__type_traits/is_nothrow_constructible.h>
242 #include <__type_traits/is_nothrow_copy_assignable.h>
243 #include <__type_traits/is_nothrow_copy_constructible.h>
244 #include <__type_traits/is_nothrow_default_constructible.h>
245 #include <__type_traits/is_nothrow_move_assignable.h>
246 #include <__type_traits/is_reference.h>
247 #include <__type_traits/is_same.h>
248 #include <__type_traits/is_swappable.h>
249 #include <__type_traits/lazy.h>
250 #include <__type_traits/maybe_const.h>
251 #include <__type_traits/nat.h>
252 #include <__type_traits/negation.h>
253 #include <__type_traits/remove_cvref.h>
254 #include <__type_traits/remove_reference.h>
255 #include <__type_traits/unwrap_ref.h>
256 #include <__utility/forward.h>
257 #include <__utility/integer_sequence.h>
258 #include <__utility/move.h>
259 #include <__utility/pair.h>
260 #include <__utility/piecewise_construct.h>
261 #include <__utility/swap.h>
265 // standard-mandated includes
270 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
271 # pragma GCC system_header
275 #include <__undef_macros>
277 _LIBCPP_BEGIN_NAMESPACE_STD
279 #ifndef _LIBCPP_CXX03_LANG
284 template <size_t _Ip, class _Hp,
285 bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
289 template <size_t _Ip, class _Hp, bool _Ep>
290 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
291 void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
292 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
294 swap(__x.get(), __y.get());
297 template <size_t _Ip, class _Hp, bool _Ep>
298 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
299 void swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x, const __tuple_leaf<_Ip, _Hp, _Ep>& __y)
300 _NOEXCEPT_(__is_nothrow_swappable<const _Hp>::value) {
301 swap(__x.get(), __y.get());
304 template <size_t _Ip, class _Hp, bool>
310 static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() {
311 #if __has_keyword(__reference_binds_to_temporary)
312 return !__reference_binds_to_temporary(_Hp, _Tp);
318 _LIBCPP_CONSTEXPR_SINCE_CXX14
319 __tuple_leaf& operator=(const __tuple_leaf&);
321 _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
322 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_()
323 {static_assert(!is_reference<_Hp>::value,
324 "Attempted to default construct a reference element in a tuple");}
326 template <class _Alloc>
327 _LIBCPP_INLINE_VISIBILITY constexpr
328 __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
330 {static_assert(!is_reference<_Hp>::value,
331 "Attempted to default construct a reference element in a tuple");}
333 template <class _Alloc>
334 _LIBCPP_INLINE_VISIBILITY constexpr
335 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
336 : __value_(allocator_arg_t(), __a)
337 {static_assert(!is_reference<_Hp>::value,
338 "Attempted to default construct a reference element in a tuple");}
340 template <class _Alloc>
341 _LIBCPP_INLINE_VISIBILITY constexpr
342 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
344 {static_assert(!is_reference<_Hp>::value,
345 "Attempted to default construct a reference element in a tuple");}
348 class = __enable_if_t<
350 _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>,
351 is_constructible<_Hp, _Tp>
355 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
356 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
357 : __value_(_VSTD::forward<_Tp>(__t))
358 {static_assert(__can_bind_reference<_Tp&&>(),
359 "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
361 template <class _Tp, class _Alloc>
362 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
363 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
364 : __value_(_VSTD::forward<_Tp>(__t))
365 {static_assert(__can_bind_reference<_Tp&&>(),
366 "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
368 template <class _Tp, class _Alloc>
369 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
370 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
371 : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
372 {static_assert(!is_reference<_Hp>::value,
373 "Attempted to uses-allocator construct a reference element in a tuple");}
375 template <class _Tp, class _Alloc>
376 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
377 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
378 : __value_(_VSTD::forward<_Tp>(__t), __a)
379 {static_assert(!is_reference<_Hp>::value,
380 "Attempted to uses-allocator construct a reference element in a tuple");}
382 _LIBCPP_HIDE_FROM_ABI __tuple_leaf(const __tuple_leaf& __t) = default;
383 _LIBCPP_HIDE_FROM_ABI __tuple_leaf(__tuple_leaf&& __t) = default;
385 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
386 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
388 _VSTD::swap(*this, __t);
392 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
393 int swap(const __tuple_leaf& __t) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
394 _VSTD::swap(*this, __t);
398 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 _Hp& get() _NOEXCEPT {return __value_;}
399 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT {return __value_;}
402 template <size_t _Ip, class _Hp>
403 class __tuple_leaf<_Ip, _Hp, true>
406 _LIBCPP_CONSTEXPR_SINCE_CXX14
407 __tuple_leaf& operator=(const __tuple_leaf&);
409 _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
410 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
412 template <class _Alloc>
413 _LIBCPP_INLINE_VISIBILITY constexpr
414 __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
416 template <class _Alloc>
417 _LIBCPP_INLINE_VISIBILITY constexpr
418 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
419 : _Hp(allocator_arg_t(), __a) {}
421 template <class _Alloc>
422 _LIBCPP_INLINE_VISIBILITY constexpr
423 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
427 class = __enable_if_t<
429 _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>,
430 is_constructible<_Hp, _Tp>
434 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
435 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
436 : _Hp(_VSTD::forward<_Tp>(__t)) {}
438 template <class _Tp, class _Alloc>
439 _LIBCPP_INLINE_VISIBILITY constexpr
440 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
441 : _Hp(_VSTD::forward<_Tp>(__t)) {}
443 template <class _Tp, class _Alloc>
444 _LIBCPP_INLINE_VISIBILITY constexpr
445 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
446 : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
448 template <class _Tp, class _Alloc>
449 _LIBCPP_INLINE_VISIBILITY constexpr
450 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
451 : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
453 __tuple_leaf(__tuple_leaf const &) = default;
454 __tuple_leaf(__tuple_leaf &&) = default;
456 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
458 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
460 _VSTD::swap(*this, __t);
464 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
465 int swap(const __tuple_leaf& __rhs) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
466 _VSTD::swap(*this, __rhs);
470 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
471 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
474 template <class ..._Tp>
475 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
476 void __swallow(_Tp&&...) _NOEXCEPT {}
479 struct __all_default_constructible;
481 template <class ..._Tp>
482 struct __all_default_constructible<__tuple_types<_Tp...>>
483 : __all<is_default_constructible<_Tp>::value...>
488 template<class _Indx, class ..._Tp> struct __tuple_impl;
490 template<size_t ..._Indx, class ..._Tp>
491 struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
492 : public __tuple_leaf<_Indx, _Tp>...
494 _LIBCPP_INLINE_VISIBILITY
495 constexpr __tuple_impl()
496 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
498 template <size_t ..._Uf, class ..._Tf,
499 size_t ..._Ul, class ..._Tl, class ..._Up>
500 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
502 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
503 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
505 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
506 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
507 __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
508 __tuple_leaf<_Ul, _Tl>()...
511 template <class _Alloc, size_t ..._Uf, class ..._Tf,
512 size_t ..._Ul, class ..._Tl, class ..._Up>
513 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
515 __tuple_impl(allocator_arg_t, const _Alloc& __a,
516 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
517 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
519 __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
520 _VSTD::forward<_Up>(__u))...,
521 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
524 template <class _Tuple,
525 class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
527 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
528 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
529 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
530 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
531 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
534 template <class _Alloc, class _Tuple,
535 class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
537 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
538 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
539 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
540 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
541 _VSTD::forward<typename tuple_element<_Indx,
542 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
545 __tuple_impl(const __tuple_impl&) = default;
546 __tuple_impl(__tuple_impl&&) = default;
548 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
549 void swap(__tuple_impl& __t)
550 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
552 _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
555 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
556 void swap(const __tuple_impl& __t) const
557 _NOEXCEPT_(__all<__is_nothrow_swappable<const _Tp>::value...>::value)
559 _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t))...);
563 template<class _Dest, class _Source, size_t ..._Np>
564 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
565 void __memberwise_copy_assign(_Dest& __dest, _Source const& __source, __tuple_indices<_Np...>) {
566 _VSTD::__swallow(((_VSTD::get<_Np>(__dest) = _VSTD::get<_Np>(__source)), void(), 0)...);
569 template<class _Dest, class _Source, class ..._Up, size_t ..._Np>
570 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
571 void __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up...>, __tuple_indices<_Np...>) {
573 _VSTD::get<_Np>(__dest) = _VSTD::forward<_Up>(_VSTD::get<_Np>(__source))
577 template <class ..._Tp>
578 class _LIBCPP_TEMPLATE_VIS tuple
580 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
584 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
585 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
586 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
587 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
588 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
589 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
590 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
591 const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
595 _LIBCPP_DIAGNOSTIC_PUSH
596 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions")
597 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions")
599 // tuple() constructors (including allocator_arg_t variants)
600 template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible,
601 template<class...> class _IsDefault = is_default_constructible, __enable_if_t<
606 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
607 explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value) tuple()
608 _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value)
611 template <class _Alloc,
612 template<class...> class _IsImpDefault = __is_implicitly_default_constructible,
613 template<class...> class _IsDefault = is_default_constructible, __enable_if_t<
618 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
619 explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value) tuple(allocator_arg_t, _Alloc const& __a)
620 : __base_(allocator_arg_t(), __a,
621 __tuple_indices<>(), __tuple_types<>(),
622 typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
623 __tuple_types<_Tp...>()) {}
625 // tuple(const T&...) constructors (including allocator_arg_t variants)
626 template <template<class...> class _And = _And, __enable_if_t<
628 _BoolConstant<sizeof...(_Tp) >= 1>,
629 is_copy_constructible<_Tp>...
632 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
633 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) tuple(const _Tp& ... __t)
634 _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
635 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
636 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
637 typename __make_tuple_indices<0>::type(),
638 typename __make_tuple_types<tuple, 0>::type(),
642 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
644 _BoolConstant<sizeof...(_Tp) >= 1>,
645 is_copy_constructible<_Tp>...
648 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
649 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
650 : __base_(allocator_arg_t(), __a,
651 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
652 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
653 typename __make_tuple_indices<0>::type(),
654 typename __make_tuple_types<tuple, 0>::type(),
658 // tuple(U&& ...) constructors (including allocator_arg_t variants)
659 template <class ..._Up> struct _IsThisTuple : false_type { };
660 template <class _Up> struct _IsThisTuple<_Up> : is_same<__remove_cvref_t<_Up>, tuple> { };
662 template <class ..._Up>
663 struct _EnableUTypesCtor : _And<
664 _BoolConstant<sizeof...(_Tp) >= 1>,
665 _Not<_IsThisTuple<_Up...> >, // extension to allow mis-behaved user constructors
666 is_constructible<_Tp, _Up>...
669 template <class ..._Up, __enable_if_t<
671 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
672 _EnableUTypesCtor<_Up...>
675 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
676 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) tuple(_Up&&... __u)
677 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
678 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
679 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
680 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
681 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
682 _VSTD::forward<_Up>(__u)...) {}
684 template <class _Alloc, class ..._Up, __enable_if_t<
686 _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
687 _EnableUTypesCtor<_Up...>
690 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
691 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
692 : __base_(allocator_arg_t(), __a,
693 typename __make_tuple_indices<sizeof...(_Up)>::type(),
694 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
695 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
696 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
697 _VSTD::forward<_Up>(__u)...) {}
699 // Copy and move constructors (including the allocator_arg_t variants)
700 tuple(const tuple&) = default;
701 tuple(tuple&&) = default;
703 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
704 _And<is_copy_constructible<_Tp>...>::value
706 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
707 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)
708 : __base_(allocator_arg_t(), __alloc, __t)
711 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
712 _And<is_move_constructible<_Tp>...>::value
714 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
715 tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)
716 : __base_(allocator_arg_t(), __alloc, _VSTD::move(__t))
719 // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants)
721 template <class _OtherTuple, class _DecayedOtherTuple = __remove_cvref_t<_OtherTuple>, class = void>
722 struct _EnableCtorFromUTypesTuple : false_type {};
724 template <class _OtherTuple, class... _Up>
725 struct _EnableCtorFromUTypesTuple<_OtherTuple, tuple<_Up...>,
726 // the length of the packs needs to checked first otherwise the 2 packs cannot be expanded simultaneously below
727 __enable_if_t<sizeof...(_Up) == sizeof...(_Tp)>> : _And<
728 // the two conditions below are not in spec. The purpose is to disable the UTypes Ctor when copy/move Ctor can work.
729 // Otherwise, is_constructible can trigger hard error in those cases https://godbolt.org/z/M94cGdKcE
730 _Not<is_same<_OtherTuple, const tuple&> >,
731 _Not<is_same<_OtherTuple, tuple&&> >,
732 is_constructible<_Tp, __copy_cvref_t<_OtherTuple, _Up> >...,
733 _Lazy<_Or, _BoolConstant<sizeof...(_Tp) != 1>,
734 // _Tp and _Up are 1-element packs - the pack expansions look
735 // weird to avoid tripping up the type traits in degenerate cases
737 _Not<is_same<_Tp, _Up> >...,
738 _Not<is_convertible<_OtherTuple, _Tp> >...,
739 _Not<is_constructible<_Tp, _OtherTuple> >...
744 template <class ..._Up, __enable_if_t<
746 _EnableCtorFromUTypesTuple<const tuple<_Up...>&>
749 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
750 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) tuple(const tuple<_Up...>& __t)
751 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
755 template <class ..._Up, class _Alloc, __enable_if_t<
757 _EnableCtorFromUTypesTuple<const tuple<_Up...>&>
760 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
761 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
762 : __base_(allocator_arg_t(), __a, __t)
765 #if _LIBCPP_STD_VER >= 23
766 // tuple(tuple<U...>&) constructors (including allocator_arg_t variants)
768 template <class... _Up, enable_if_t<
769 _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
770 _LIBCPP_HIDE_FROM_ABI constexpr
771 explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value)
772 tuple(tuple<_Up...>& __t) : __base_(__t) {}
774 template <class _Alloc, class... _Up, enable_if_t<
775 _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
776 _LIBCPP_HIDE_FROM_ABI constexpr
777 explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value)
778 tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t) : __base_(allocator_arg_t(), __alloc, __t) {}
779 #endif // _LIBCPP_STD_VER >= 23
781 // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)
782 template <class ..._Up, __enable_if_t<
784 _EnableCtorFromUTypesTuple<tuple<_Up...>&&>
787 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
788 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) tuple(tuple<_Up...>&& __t)
789 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
790 : __base_(_VSTD::move(__t))
793 template <class _Alloc, class ..._Up, __enable_if_t<
795 _EnableCtorFromUTypesTuple<tuple<_Up...>&&>
798 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
799 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
800 : __base_(allocator_arg_t(), __a, _VSTD::move(__t))
803 #if _LIBCPP_STD_VER >= 23
804 // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants)
806 template <class... _Up, enable_if_t<
807 _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
808 _LIBCPP_HIDE_FROM_ABI constexpr
809 explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value)
810 tuple(const tuple<_Up...>&& __t) : __base_(std::move(__t)) {}
812 template <class _Alloc, class... _Up, enable_if_t<
813 _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
814 _LIBCPP_HIDE_FROM_ABI constexpr
815 explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value)
816 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t)
817 : __base_(allocator_arg_t(), __alloc, std::move(__t)) {}
818 #endif // _LIBCPP_STD_VER >= 23
820 // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)
822 template <template <class...> class _Pred, class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
823 struct _CtorPredicateFromPair : false_type{};
825 template <template <class...> class _Pred, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
826 struct _CtorPredicateFromPair<_Pred, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > : _And<
827 _Pred<_Tp1, __copy_cvref_t<_Pair, _Up1> >,
828 _Pred<_Tp2, __copy_cvref_t<_Pair, _Up2> >
831 template <class _Pair>
832 struct _EnableCtorFromPair : _CtorPredicateFromPair<is_constructible, _Pair>{};
834 template <class _Pair>
835 struct _NothrowConstructibleFromPair : _CtorPredicateFromPair<is_nothrow_constructible, _Pair>{};
837 template <class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
838 struct _BothImplicitlyConvertible : false_type{};
840 template <class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
841 struct _BothImplicitlyConvertible<_Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > : _And<
842 is_convertible<__copy_cvref_t<_Pair, _Up1>, _Tp1>,
843 is_convertible<__copy_cvref_t<_Pair, _Up2>, _Tp2>
846 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
848 _EnableCtorFromPair<const pair<_Up1, _Up2>&>
851 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
852 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) tuple(const pair<_Up1, _Up2>& __p)
853 _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
857 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
859 _EnableCtorFromPair<const pair<_Up1, _Up2>&>
862 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
863 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
864 : __base_(allocator_arg_t(), __a, __p)
867 #if _LIBCPP_STD_VER >= 23
868 // tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants)
870 template <class _U1, class _U2, enable_if_t<
871 _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr>
872 _LIBCPP_HIDE_FROM_ABI constexpr
873 explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
874 tuple(pair<_U1, _U2>& __p) : __base_(__p) {}
876 template <class _Alloc, class _U1, class _U2, enable_if_t<
877 _EnableCtorFromPair<std::pair<_U1, _U2>&>::value>* = nullptr>
878 _LIBCPP_HIDE_FROM_ABI constexpr
879 explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
880 tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p) : __base_(allocator_arg_t(), __alloc, __p) {}
883 // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)
885 template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
887 _EnableCtorFromPair<pair<_Up1, _Up2>&&>
890 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
891 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) tuple(pair<_Up1, _Up2>&& __p)
892 _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
893 : __base_(_VSTD::move(__p))
896 template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
898 _EnableCtorFromPair<pair<_Up1, _Up2>&&>
901 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
902 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
903 : __base_(allocator_arg_t(), __a, _VSTD::move(__p))
906 #if _LIBCPP_STD_VER >= 23
907 // tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants)
909 template <class _U1, class _U2, enable_if_t<
910 _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
911 _LIBCPP_HIDE_FROM_ABI constexpr
912 explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
913 tuple(const pair<_U1, _U2>&& __p) : __base_(std::move(__p)) {}
915 template <class _Alloc, class _U1, class _U2, enable_if_t<
916 _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
917 _LIBCPP_HIDE_FROM_ABI constexpr
918 explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
919 tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p)
920 : __base_(allocator_arg_t(), __alloc, std::move(__p)) {}
921 #endif // _LIBCPP_STD_VER >= 23
923 _LIBCPP_DIAGNOSTIC_POP
926 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
927 tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)
928 _NOEXCEPT_((_And<is_nothrow_copy_assignable<_Tp>...>::value))
930 _VSTD::__memberwise_copy_assign(*this, __tuple,
931 typename __make_tuple_indices<sizeof...(_Tp)>::type());
935 #if _LIBCPP_STD_VER >= 23
936 _LIBCPP_HIDE_FROM_ABI constexpr
937 const tuple& operator=(tuple const& __tuple) const
938 requires (_And<is_copy_assignable<const _Tp>...>::value) {
939 std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
943 _LIBCPP_HIDE_FROM_ABI constexpr
944 const tuple& operator=(tuple&& __tuple) const
945 requires (_And<is_assignable<const _Tp&, _Tp>...>::value) {
946 std::__memberwise_forward_assign(*this,
948 __tuple_types<_Tp...>(),
949 typename __make_tuple_indices<sizeof...(_Tp)>::type());
952 #endif // _LIBCPP_STD_VER >= 23
954 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
955 tuple& operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)
956 _NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value))
958 _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__tuple),
959 __tuple_types<_Tp...>(),
960 typename __make_tuple_indices<sizeof...(_Tp)>::type());
964 template<class... _Up, __enable_if_t<
966 _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>,
967 is_assignable<_Tp&, _Up const&>...
970 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
971 tuple& operator=(tuple<_Up...> const& __tuple)
972 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
974 _VSTD::__memberwise_copy_assign(*this, __tuple,
975 typename __make_tuple_indices<sizeof...(_Tp)>::type());
979 template<class... _Up, __enable_if_t<
981 _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>,
982 is_assignable<_Tp&, _Up>...
985 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
986 tuple& operator=(tuple<_Up...>&& __tuple)
987 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
989 _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__tuple),
990 __tuple_types<_Up...>(),
991 typename __make_tuple_indices<sizeof...(_Tp)>::type());
996 #if _LIBCPP_STD_VER >= 23
997 template <class... _UTypes, enable_if_t<
998 _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
999 is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr>
1000 _LIBCPP_HIDE_FROM_ABI constexpr
1001 const tuple& operator=(const tuple<_UTypes...>& __u) const {
1002 std::__memberwise_copy_assign(*this,
1004 typename __make_tuple_indices<sizeof...(_Tp)>::type());
1008 template <class... _UTypes, enable_if_t<
1009 _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
1010 is_assignable<const _Tp&, _UTypes>...>::value>* = nullptr>
1011 _LIBCPP_HIDE_FROM_ABI constexpr
1012 const tuple& operator=(tuple<_UTypes...>&& __u) const {
1013 std::__memberwise_forward_assign(*this,
1015 __tuple_types<_UTypes...>(),
1016 typename __make_tuple_indices<sizeof...(_Tp)>::type());
1019 #endif // _LIBCPP_STD_VER >= 23
1021 template <template<class...> class _Pred, bool _Const,
1022 class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
1023 struct _AssignPredicateFromPair : false_type {};
1025 template <template<class...> class _Pred, bool _Const,
1026 class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
1027 struct _AssignPredicateFromPair<_Pred, _Const, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > :
1028 _And<_Pred<__maybe_const<_Const, _Tp1>&, __copy_cvref_t<_Pair, _Up1> >,
1029 _Pred<__maybe_const<_Const, _Tp2>&, __copy_cvref_t<_Pair, _Up2> >
1032 template <bool _Const, class _Pair>
1033 struct _EnableAssignFromPair : _AssignPredicateFromPair<is_assignable, _Const, _Pair> {};
1035 template <bool _Const, class _Pair>
1036 struct _NothrowAssignFromPair : _AssignPredicateFromPair<is_nothrow_assignable, _Const, _Pair> {};
1038 #if _LIBCPP_STD_VER >= 23
1039 template <class _U1, class _U2, enable_if_t<
1040 _EnableAssignFromPair<true, const pair<_U1, _U2>&>::value>* = nullptr>
1041 _LIBCPP_HIDE_FROM_ABI constexpr
1042 const tuple& operator=(const pair<_U1, _U2>& __pair) const
1043 noexcept(_NothrowAssignFromPair<true, const pair<_U1, _U2>&>::value) {
1044 std::get<0>(*this) = __pair.first;
1045 std::get<1>(*this) = __pair.second;
1049 template <class _U1, class _U2, enable_if_t<
1050 _EnableAssignFromPair<true, pair<_U1, _U2>&&>::value>* = nullptr>
1051 _LIBCPP_HIDE_FROM_ABI constexpr
1052 const tuple& operator=(pair<_U1, _U2>&& __pair) const
1053 noexcept(_NothrowAssignFromPair<true, pair<_U1, _U2>&&>::value) {
1054 std::get<0>(*this) = std::move(__pair.first);
1055 std::get<1>(*this) = std::move(__pair.second);
1058 #endif // _LIBCPP_STD_VER >= 23
1060 template<class _Up1, class _Up2, __enable_if_t<
1061 _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value
1063 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1064 tuple& operator=(pair<_Up1, _Up2> const& __pair)
1065 _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value))
1067 _VSTD::get<0>(*this) = __pair.first;
1068 _VSTD::get<1>(*this) = __pair.second;
1072 template<class _Up1, class _Up2, __enable_if_t<
1073 _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value
1075 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1076 tuple& operator=(pair<_Up1, _Up2>&& __pair)
1077 _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value))
1079 _VSTD::get<0>(*this) = _VSTD::forward<_Up1>(__pair.first);
1080 _VSTD::get<1>(*this) = _VSTD::forward<_Up2>(__pair.second);
1085 template<class _Up, size_t _Np, class = __enable_if_t<
1087 _BoolConstant<_Np == sizeof...(_Tp)>,
1088 is_assignable<_Tp&, _Up const&>...
1091 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1092 tuple& operator=(array<_Up, _Np> const& __array)
1093 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
1095 _VSTD::__memberwise_copy_assign(*this, __array,
1096 typename __make_tuple_indices<sizeof...(_Tp)>::type());
1101 template<class _Up, size_t _Np, class = void, class = __enable_if_t<
1103 _BoolConstant<_Np == sizeof...(_Tp)>,
1104 is_assignable<_Tp&, _Up>...
1107 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1108 tuple& operator=(array<_Up, _Np>&& __array)
1109 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
1111 _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__array),
1112 __tuple_types<_If<true, _Up, _Tp>...>(),
1113 typename __make_tuple_indices<sizeof...(_Tp)>::type());
1118 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1119 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
1120 {__base_.swap(__t.__base_);}
1122 #if _LIBCPP_STD_VER >= 23
1123 _LIBCPP_HIDE_FROM_ABI constexpr
1124 void swap(const tuple& __t) const noexcept(__all<is_nothrow_swappable_v<const _Tp&>...>::value) {
1125 __base_.swap(__t.__base_);
1127 #endif // _LIBCPP_STD_VER >= 23
1131 class _LIBCPP_TEMPLATE_VIS tuple<>
1134 constexpr tuple() _NOEXCEPT = default;
1135 template <class _Alloc>
1136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1137 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
1138 template <class _Alloc>
1139 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1140 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
1141 template <class _Up>
1142 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1143 tuple(array<_Up, 0>) _NOEXCEPT {}
1144 template <class _Alloc, class _Up>
1145 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1146 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
1147 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1148 void swap(tuple&) _NOEXCEPT {}
1149 #if _LIBCPP_STD_VER >= 23
1150 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}
1154 #if _LIBCPP_STD_VER >= 23
1155 template <class... _TTypes, class... _UTypes, template<class> class _TQual, template<class> class _UQual>
1156 requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; }
1157 struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> {
1158 using type = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>;
1161 template <class... _TTypes, class... _UTypes>
1162 requires requires { typename tuple<common_type_t<_TTypes, _UTypes>...>; }
1163 struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {
1164 using type = tuple<common_type_t<_TTypes, _UTypes>...>;
1166 #endif // _LIBCPP_STD_VER >= 23
1168 #if _LIBCPP_STD_VER >= 17
1169 template <class ..._Tp>
1170 tuple(_Tp...) -> tuple<_Tp...>;
1171 template <class _Tp1, class _Tp2>
1172 tuple(pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
1173 template <class _Alloc, class ..._Tp>
1174 tuple(allocator_arg_t, _Alloc, _Tp...) -> tuple<_Tp...>;
1175 template <class _Alloc, class _Tp1, class _Tp2>
1176 tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
1177 template <class _Alloc, class ..._Tp>
1178 tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
1181 template <class ..._Tp, __enable_if_t<__all<__is_swappable<_Tp>::value...>::value, int> = 0>
1182 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1184 swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
1185 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
1188 #if _LIBCPP_STD_VER >= 23
1189 template <class... _Tp>
1190 _LIBCPP_HIDE_FROM_ABI constexpr
1191 enable_if_t<__all<is_swappable_v<const _Tp>...>::value, void>
1192 swap(const tuple<_Tp...>& __lhs, const tuple<_Tp...>& __rhs)
1193 noexcept(__all<is_nothrow_swappable_v<const _Tp>...>::value) {
1200 template <size_t _Ip, class ..._Tp>
1201 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1202 typename tuple_element<_Ip, tuple<_Tp...> >::type&
1203 get(tuple<_Tp...>& __t) _NOEXCEPT
1205 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
1206 return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
1209 template <size_t _Ip, class ..._Tp>
1210 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1211 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
1212 get(const tuple<_Tp...>& __t) _NOEXCEPT
1214 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
1215 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
1218 template <size_t _Ip, class ..._Tp>
1219 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1220 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1221 get(tuple<_Tp...>&& __t) _NOEXCEPT
1223 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
1224 return static_cast<type&&>(
1225 static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
1228 template <size_t _Ip, class ..._Tp>
1229 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1230 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1231 get(const tuple<_Tp...>&& __t) _NOEXCEPT
1233 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
1234 return static_cast<const type&&>(
1235 static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
1238 #if _LIBCPP_STD_VER >= 14
1240 namespace __find_detail {
1242 static constexpr size_t __not_found = static_cast<size_t>(-1);
1243 static constexpr size_t __ambiguous = __not_found - 1;
1245 inline _LIBCPP_INLINE_VISIBILITY
1246 constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
1247 return !__matches ? __res :
1248 (__res == __not_found ? __curr_i : __ambiguous);
1251 template <size_t _Nx>
1252 inline _LIBCPP_INLINE_VISIBILITY
1253 constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
1254 return __i == _Nx ? __not_found :
1255 __find_detail::__find_idx_return(__i, __find_detail::__find_idx(__i + 1, __matches), __matches[__i]);
1258 template <class _T1, class ..._Args>
1259 struct __find_exactly_one_checked {
1260 static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
1261 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
1262 static_assert(value != __not_found, "type not found in type list" );
1263 static_assert(value != __ambiguous, "type occurs more than once in type list");
1266 template <class _T1>
1267 struct __find_exactly_one_checked<_T1> {
1268 static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
1271 } // namespace __find_detail
1273 template <typename _T1, typename... _Args>
1274 struct __find_exactly_one_t
1275 : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
1278 template <class _T1, class... _Args>
1279 inline _LIBCPP_INLINE_VISIBILITY
1280 constexpr _T1& get(tuple<_Args...>& __tup) noexcept
1282 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1285 template <class _T1, class... _Args>
1286 inline _LIBCPP_INLINE_VISIBILITY
1287 constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
1289 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1292 template <class _T1, class... _Args>
1293 inline _LIBCPP_INLINE_VISIBILITY
1294 constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
1296 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1299 template <class _T1, class... _Args>
1300 inline _LIBCPP_INLINE_VISIBILITY
1301 constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
1303 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1310 template <class ..._Tp>
1311 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1313 tie(_Tp&... __t) _NOEXCEPT
1315 return tuple<_Tp&...>(__t...);
1318 template <class _Up>
1321 template <class _Tp>
1322 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1323 const __ignore_t& operator=(_Tp&&) const {return *this;}
1326 # if _LIBCPP_STD_VER >= 17
1327 inline constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
1330 constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
1334 template <class... _Tp>
1335 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1336 tuple<typename __unwrap_ref_decay<_Tp>::type...>
1337 make_tuple(_Tp&&... __t)
1339 return tuple<typename __unwrap_ref_decay<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
1342 template <class... _Tp>
1343 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1345 forward_as_tuple(_Tp&&... __t) _NOEXCEPT
1347 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
1350 template <size_t _Ip>
1351 struct __tuple_equal
1353 template <class _Tp, class _Up>
1354 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1355 bool operator()(const _Tp& __x, const _Up& __y)
1357 return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
1362 struct __tuple_equal<0>
1364 template <class _Tp, class _Up>
1365 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1366 bool operator()(const _Tp&, const _Up&)
1372 template <class ..._Tp, class ..._Up>
1373 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1375 operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1377 static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
1378 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
1381 #if _LIBCPP_STD_VER >= 20
1385 template <class ..._Tp, class ..._Up, size_t ..._Is>
1386 _LIBCPP_HIDE_FROM_ABI constexpr
1388 __tuple_compare_three_way(const tuple<_Tp...>& __x, const tuple<_Up...>& __y, index_sequence<_Is...>) {
1389 common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> __result = strong_ordering::equal;
1390 static_cast<void>(((__result = _VSTD::__synth_three_way(_VSTD::get<_Is>(__x), _VSTD::get<_Is>(__y)), __result != 0) || ...));
1394 template <class ..._Tp, class ..._Up>
1395 requires (sizeof...(_Tp) == sizeof...(_Up))
1396 _LIBCPP_HIDE_FROM_ABI constexpr
1397 common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...>
1398 operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1400 return _VSTD::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{});
1403 #else // _LIBCPP_STD_VER >= 20
1405 template <class ..._Tp, class ..._Up>
1406 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1408 operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1410 return !(__x == __y);
1413 template <size_t _Ip>
1416 template <class _Tp, class _Up>
1417 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1418 bool operator()(const _Tp& __x, const _Up& __y)
1420 const size_t __idx = tuple_size<_Tp>::value - _Ip;
1421 if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
1423 if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
1425 return __tuple_less<_Ip-1>()(__x, __y);
1430 struct __tuple_less<0>
1432 template <class _Tp, class _Up>
1433 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1434 bool operator()(const _Tp&, const _Up&)
1440 template <class ..._Tp, class ..._Up>
1441 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1443 operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1445 static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
1446 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
1449 template <class ..._Tp, class ..._Up>
1450 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1452 operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1457 template <class ..._Tp, class ..._Up>
1458 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1460 operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1462 return !(__x < __y);
1465 template <class ..._Tp, class ..._Up>
1466 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1468 operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1470 return !(__y < __x);
1473 #endif // _LIBCPP_STD_VER >= 20
1477 template <class _Tp, class _Up> struct __tuple_cat_type;
1479 template <class ..._Ttypes, class ..._Utypes>
1480 struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
1482 typedef _LIBCPP_NODEBUG tuple<_Ttypes..., _Utypes...> type;
1485 template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
1486 struct __tuple_cat_return_1
1490 template <class ..._Types, class _Tuple0>
1491 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
1493 using type _LIBCPP_NODEBUG = typename __tuple_cat_type<
1495 typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type
1499 template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
1500 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
1501 : public __tuple_cat_return_1<
1502 typename __tuple_cat_type<
1504 typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type
1506 __tuple_like_ext<__libcpp_remove_reference_t<_Tuple1> >::value,
1507 _Tuple1, _Tuples...>
1511 template <class ..._Tuples> struct __tuple_cat_return;
1513 template <class _Tuple0, class ..._Tuples>
1514 struct __tuple_cat_return<_Tuple0, _Tuples...>
1515 : public __tuple_cat_return_1<tuple<>,
1516 __tuple_like_ext<__libcpp_remove_reference_t<_Tuple0> >::value, _Tuple0,
1522 struct __tuple_cat_return<>
1524 typedef _LIBCPP_NODEBUG tuple<> type;
1527 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1534 template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
1535 struct __tuple_cat_return_ref_imp;
1537 template <class ..._Types, size_t ..._I0, class _Tuple0>
1538 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
1540 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
1541 typedef tuple<_Types..., __apply_cv_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type;
1544 template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1545 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1546 _Tuple0, _Tuple1, _Tuples...>
1547 : public __tuple_cat_return_ref_imp<
1548 tuple<_Types..., __apply_cv_t<_Tuple0,
1549 typename tuple_element<_I0, __libcpp_remove_reference_t<_Tuple0>>::type>&&...>,
1550 typename __make_tuple_indices<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>::type,
1551 _Tuple1, _Tuples...>
1555 template <class _Tuple0, class ..._Tuples>
1556 struct __tuple_cat_return_ref
1557 : public __tuple_cat_return_ref_imp<tuple<>,
1558 typename __make_tuple_indices<
1559 tuple_size<__libcpp_remove_reference_t<_Tuple0> >::value
1560 >::type, _Tuple0, _Tuples...>
1564 template <class _Types, class _I0, class _J0>
1567 template <class ..._Types, size_t ..._I0, size_t ..._J0>
1568 struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
1570 template <class _Tuple0>
1571 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1572 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1573 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1575 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1576 return _VSTD::forward_as_tuple(
1577 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1578 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
1581 template <class _Tuple0, class _Tuple1, class ..._Tuples>
1582 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1583 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1584 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1586 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1587 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
1588 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple1> _T1;
1589 return __tuple_cat<tuple<_Types..., __apply_cv_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>,
1590 typename __make_tuple_indices<sizeof...(_Types) + tuple_size<_T0>::value>::type,
1591 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
1592 _VSTD::forward_as_tuple(
1593 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1594 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...),
1595 _VSTD::forward<_Tuple1>(__t1), _VSTD::forward<_Tuples>(__tpls)...);
1599 template <class _Tuple0, class... _Tuples>
1600 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1601 typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1602 tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1604 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
1605 return __tuple_cat<tuple<>, __tuple_indices<>,
1606 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
1607 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1608 _VSTD::forward<_Tuples>(__tpls)...);
1611 template <class ..._Tp, class _Alloc>
1612 struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
1615 template <class _T1, class _T2>
1616 template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1617 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1618 pair<_T1, _T2>::pair(piecewise_construct_t,
1619 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1620 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
1621 : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
1622 second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
1626 #if _LIBCPP_STD_VER >= 17
1627 template <class _Tp>
1628 inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
1630 #define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
1632 template <class _Fn, class _Tuple, size_t ..._Id>
1633 inline _LIBCPP_INLINE_VISIBILITY
1634 constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
1635 __tuple_indices<_Id...>)
1636 _LIBCPP_NOEXCEPT_RETURN(
1638 _VSTD::forward<_Fn>(__f),
1639 _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
1642 template <class _Fn, class _Tuple>
1643 inline _LIBCPP_INLINE_VISIBILITY
1644 constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
1645 _LIBCPP_NOEXCEPT_RETURN(
1646 _VSTD::__apply_tuple_impl(
1647 _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
1648 typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
1651 template <class _Tp, class _Tuple, size_t... _Idx>
1652 inline _LIBCPP_INLINE_VISIBILITY
1653 constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
1654 _LIBCPP_NOEXCEPT_RETURN(
1655 _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...)
1658 template <class _Tp, class _Tuple>
1659 inline _LIBCPP_INLINE_VISIBILITY
1660 constexpr _Tp make_from_tuple(_Tuple&& __t)
1661 _LIBCPP_NOEXCEPT_RETURN(
1662 _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
1663 typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
1666 #undef _LIBCPP_NOEXCEPT_RETURN
1668 #endif // _LIBCPP_STD_VER >= 17
1670 #endif // !defined(_LIBCPP_CXX03_LANG)
1672 _LIBCPP_END_NAMESPACE_STD
1676 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1677 # include <exception>
1680 # include <type_traits>
1681 # include <typeinfo>
1685 #endif // _LIBCPP_TUPLE