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 //===----------------------------------------------------------------------===//
24 explicit(see-below) constexpr tuple();
25 explicit(see-below) tuple(const T&...); // constexpr in C++14
27 explicit(see-below) tuple(U&&...); // constexpr in C++14
28 tuple(const tuple&) = default;
29 tuple(tuple&&) = default;
31 template<class... UTypes>
32 constexpr explicit(see-below) tuple(tuple<UTypes...>&); // C++23
34 explicit(see-below) tuple(const tuple<U...>&); // constexpr in C++14
36 explicit(see-below) tuple(tuple<U...>&&); // constexpr in C++14
37 template<class... UTypes>
38 constexpr explicit(see-below) tuple(const tuple<UTypes...>&&); // C++23
40 template<class U1, class U2>
41 constexpr explicit(see-below) tuple(pair<U1, U2>&); // iff sizeof...(Types) == 2 // C++23
42 template <class U1, class U2>
43 explicit(see-below) tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
44 template <class U1, class U2>
45 explicit(see-below) tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
46 template<class U1, class U2>
47 constexpr explicit(see-below) tuple(const pair<U1, U2>&&); // iff sizeof...(Types) == 2 // C++23
49 // allocator-extended constructors
50 template <class Alloc>
51 tuple(allocator_arg_t, const Alloc& a);
52 template <class Alloc>
53 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const T&...); // constexpr in C++20
54 template <class Alloc, class... U>
55 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, U&&...); // constexpr in C++20
56 template <class Alloc>
57 tuple(allocator_arg_t, const Alloc& a, const tuple&); // constexpr in C++20
58 template <class Alloc>
59 tuple(allocator_arg_t, const Alloc& a, tuple&&); // constexpr in C++20
60 template<class Alloc, class... UTypes>
61 constexpr explicit(see-below)
62 tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&); // C++23
63 template <class Alloc, class... U>
64 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&); // constexpr in C++20
65 template <class Alloc, class... U>
66 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&); // constexpr in C++20
67 template<class Alloc, class... UTypes>
68 constexpr explicit(see-below)
69 tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&&); // C++23
70 template<class Alloc, class U1, class U2>
71 constexpr explicit(see-below)
72 tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&); // C++23
73 template <class Alloc, class U1, class U2>
74 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&); // constexpr in C++20
75 template <class Alloc, class U1, class U2>
76 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&); // constexpr in C++20
77 template<class Alloc, class U1, class U2>
78 constexpr explicit(see-below)
79 tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&&); // C++23
81 tuple& operator=(const tuple&); // constexpr in C++20
82 constexpr const tuple& operator=(const tuple&) const; // C++23
83 tuple& operator=(tuple&&) noexcept(is_nothrow_move_assignable_v<T> && ...); // constexpr in C++20
84 constexpr const tuple& operator=(tuple&&) const; // C++23
86 tuple& operator=(const tuple<U...>&); // constexpr in C++20
87 template<class... UTypes>
88 constexpr const tuple& operator=(const tuple<UTypes...>&) const; // C++23
90 tuple& operator=(tuple<U...>&&); // constexpr in C++20
91 template<class... UTypes>
92 constexpr const tuple& operator=(tuple<UTypes...>&&) const; // C++23
93 template <class U1, class U2>
94 tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++20
95 template<class U1, class U2>
96 constexpr const tuple& operator=(const pair<U1, U2>&) const; // iff sizeof...(Types) == 2 // C++23
97 template <class U1, class U2>
98 tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++20
99 template<class U1, class U2>
100 constexpr const tuple& operator=(pair<U1, U2>&&) const; // iff sizeof...(Types) == 2 // C++23
102 template<class U, size_t N>
103 tuple& operator=(array<U, N> const&) // iff sizeof...(T) == N, EXTENSION
104 template<class U, size_t N>
105 tuple& operator=(array<U, N>&&) // iff sizeof...(T) == N, EXTENSION
107 void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); // constexpr in C++20
108 constexpr void swap(const tuple&) const noexcept(see-below); // C++23
112 template<class... TTypes, class... UTypes, template<class> class TQual, template<class> class UQual> // since C++23
113 requires requires { typename tuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...>; }
114 struct basic_common_reference<tuple<TTypes...>, tuple<UTypes...>, TQual, UQual> {
115 using type = tuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...>;
118 template<class... TTypes, class... UTypes> // since C++23
119 requires requires { typename tuple<common_type_t<TTypes, UTypes>...>; }
120 struct common_type<tuple<TTypes...>, tuple<UTypes...>> {
121 using type = tuple<common_type_t<TTypes, UTypes>...>;
124 template <class ...T>
125 tuple(T...) -> tuple<T...>; // since C++17
126 template <class T1, class T2>
127 tuple(pair<T1, T2>) -> tuple<T1, T2>; // since C++17
128 template <class Alloc, class ...T>
129 tuple(allocator_arg_t, Alloc, T...) -> tuple<T...>; // since C++17
130 template <class Alloc, class T1, class T2>
131 tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; // since C++17
132 template <class Alloc, class ...T>
133 tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>; // since C++17
135 struct ignore-type { // exposition only // Since C++26
136 constexpr const ignore-type&
137 operator=(const auto &) const noexcept
140 inline constexpr ignore-type ignore;
142 template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
143 template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
144 template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
145 template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
147 // [tuple.apply], calling a function with a tuple of arguments:
148 template <class F, class Tuple>
149 constexpr decltype(auto) apply(F&& f, Tuple&& t) noexcept(see below); // C++17 noexcept since C++23
150 template <class T, class Tuple>
151 constexpr T make_from_tuple(Tuple&& t); // C++17
153 // 20.4.1.4, tuple helper classes:
154 template <class T> struct tuple_size; // undefined
155 template <class... T> struct tuple_size<tuple<T...>>;
157 inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
158 template <size_t I, class T> struct tuple_element; // undefined
159 template <size_t I, class... T> struct tuple_element<I, tuple<T...>>;
160 template <size_t I, class T>
161 using tuple_element_t = typename tuple_element <I, T>::type; // C++14
163 // 20.4.1.5, element access:
164 template <size_t I, class... T>
165 typename tuple_element<I, tuple<T...>>::type&
166 get(tuple<T...>&) noexcept; // constexpr in C++14
167 template <size_t I, class... T>
168 const typename tuple_element<I, tuple<T...>>::type&
169 get(const tuple<T...>&) noexcept; // constexpr in C++14
170 template <size_t I, class... T>
171 typename tuple_element<I, tuple<T...>>::type&&
172 get(tuple<T...>&&) noexcept; // constexpr in C++14
173 template <size_t I, class... T>
174 const typename tuple_element<I, tuple<T...>>::type&&
175 get(const tuple<T...>&&) noexcept; // constexpr in C++14
177 template <class T1, class... T>
178 constexpr T1& get(tuple<T...>&) noexcept; // C++14
179 template <class T1, class... T>
180 constexpr const T1& get(const tuple<T...>&) noexcept; // C++14
181 template <class T1, class... T>
182 constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
183 template <class T1, class... T>
184 constexpr const T1&& get(const tuple<T...>&&) noexcept; // C++14
186 // 20.4.1.6, relational operators:
187 template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
188 template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
189 template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
190 template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
191 template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
192 template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
193 template<class... T, class... U>
194 constexpr common_comparison_category_t<synth-three-way-result<T, U>...>
195 operator<=>(const tuple<T...>&, const tuple<U...>&); // since C++20
197 template <class... Types, class Alloc>
198 struct uses_allocator<tuple<Types...>, Alloc>;
200 template <class... Types>
202 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
204 template <class... Types>
205 constexpr void swap(const tuple<Types...>& x, const tuple<Types...>& y) noexcept(see-below); // C++23
213 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
214 # include <__cxx03/tuple>
216 # include <__compare/common_comparison_category.h>
217 # include <__compare/ordering.h>
218 # include <__compare/synth_three_way.h>
220 # include <__cstddef/size_t.h>
221 # include <__fwd/array.h>
222 # include <__fwd/pair.h>
223 # include <__fwd/tuple.h>
224 # include <__memory/allocator_arg_t.h>
225 # include <__memory/uses_allocator.h>
226 # include <__tuple/find_index.h>
227 # include <__tuple/ignore.h>
228 # include <__tuple/make_tuple_types.h>
229 # include <__tuple/sfinae_helpers.h>
230 # include <__tuple/tuple_element.h>
231 # include <__tuple/tuple_indices.h>
232 # include <__tuple/tuple_like_ext.h>
233 # include <__tuple/tuple_size.h>
234 # include <__tuple/tuple_types.h>
235 # include <__type_traits/common_reference.h>
236 # include <__type_traits/common_type.h>
237 # include <__type_traits/conditional.h>
238 # include <__type_traits/conjunction.h>
239 # include <__type_traits/copy_cvref.h>
240 # include <__type_traits/disjunction.h>
241 # include <__type_traits/enable_if.h>
242 # include <__type_traits/invoke.h>
243 # include <__type_traits/is_arithmetic.h>
244 # include <__type_traits/is_assignable.h>
245 # include <__type_traits/is_constructible.h>
246 # include <__type_traits/is_convertible.h>
247 # include <__type_traits/is_empty.h>
248 # include <__type_traits/is_final.h>
249 # include <__type_traits/is_implicitly_default_constructible.h>
250 # include <__type_traits/is_nothrow_assignable.h>
251 # include <__type_traits/is_nothrow_constructible.h>
252 # include <__type_traits/is_reference.h>
253 # include <__type_traits/is_same.h>
254 # include <__type_traits/is_swappable.h>
255 # include <__type_traits/is_trivially_relocatable.h>
256 # include <__type_traits/lazy.h>
257 # include <__type_traits/maybe_const.h>
258 # include <__type_traits/nat.h>
259 # include <__type_traits/negation.h>
260 # include <__type_traits/remove_cvref.h>
261 # include <__type_traits/remove_reference.h>
262 # include <__type_traits/unwrap_ref.h>
263 # include <__utility/declval.h>
264 # include <__utility/forward.h>
265 # include <__utility/integer_sequence.h>
266 # include <__utility/move.h>
267 # include <__utility/piecewise_construct.h>
268 # include <__utility/swap.h>
271 // standard-mandated includes
276 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
277 # pragma GCC system_header
281 # include <__undef_macros>
283 _LIBCPP_BEGIN_NAMESPACE_STD
285 # ifndef _LIBCPP_CXX03_LANG
289 template <size_t _Ip, class _Hp, bool = is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value >
292 template <size_t _Ip, class _Hp, bool _Ep>
293 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
294 swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y) noexcept(__is_nothrow_swappable_v<_Hp>) {
295 swap(__x.get(), __y.get());
298 template <size_t _Ip, class _Hp, bool _Ep>
299 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
300 swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x,
301 const __tuple_leaf<_Ip, _Hp, _Ep>& __y) noexcept(__is_nothrow_swappable_v<const _Hp>) {
302 swap(__x.get(), __y.get());
305 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);
319 _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete;
321 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf() noexcept(is_nothrow_default_constructible<_Hp>::value) : __value_() {
322 static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");
325 template <class _Alloc>
326 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 0>, const _Alloc&) : __value_() {
327 static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");
330 template <class _Alloc>
331 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
332 : __value_(allocator_arg_t(), __a) {
333 static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");
336 template <class _Alloc>
337 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a) : __value_(__a) {
338 static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");
343 __enable_if_t<_And<_IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>, is_constructible<_Hp, _Tp> >::value, int> = 0>
344 _LIBCPP_HIDE_FROM_ABI
345 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value)
346 : __value_(std::forward<_Tp>(__t)) {
347 static_assert(__can_bind_reference<_Tp&&>(),
348 "Attempted construction of reference element binds to a temporary whose lifetime has ended");
351 template <class _Tp, class _Alloc>
352 _LIBCPP_HIDE_FROM_ABI
353 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
354 : __value_(std::forward<_Tp>(__t)) {
355 static_assert(__can_bind_reference<_Tp&&>(),
356 "Attempted construction of reference element binds to a temporary whose lifetime has ended");
359 template <class _Tp, class _Alloc>
360 _LIBCPP_HIDE_FROM_ABI
361 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
362 : __value_(allocator_arg_t(), __a, std::forward<_Tp>(__t)) {
363 static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple");
366 template <class _Tp, class _Alloc>
367 _LIBCPP_HIDE_FROM_ABI
368 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
369 : __value_(std::forward<_Tp>(__t), __a) {
370 static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple");
373 _LIBCPP_HIDE_FROM_ABI __tuple_leaf(const __tuple_leaf& __t) = default;
374 _LIBCPP_HIDE_FROM_ABI __tuple_leaf(__tuple_leaf&& __t) = default;
376 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
377 swap(__tuple_leaf& __t) noexcept(__is_nothrow_swappable_v<__tuple_leaf>) {
378 std::swap(*this, __t);
382 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(const __tuple_leaf& __t) const
383 noexcept(__is_nothrow_swappable_v<const __tuple_leaf>) {
384 std::swap(*this, __t);
388 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Hp& get() _NOEXCEPT { return __value_; }
389 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT { return __value_; }
392 template <size_t _Ip, class _Hp>
393 class __tuple_leaf<_Ip, _Hp, true> : private _Hp {
395 _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete;
397 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf() noexcept(is_nothrow_default_constructible<_Hp>::value) {}
399 template <class _Alloc>
400 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
402 template <class _Alloc>
403 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
404 : _Hp(allocator_arg_t(), __a) {}
406 template <class _Alloc>
407 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a) : _Hp(__a) {}
410 __enable_if_t< _And< _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>, is_constructible<_Hp, _Tp> >::value,
412 _LIBCPP_HIDE_FROM_ABI
413 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value)
414 : _Hp(std::forward<_Tp>(__t)) {}
416 template <class _Tp, class _Alloc>
417 _LIBCPP_HIDE_FROM_ABI constexpr explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
418 : _Hp(std::forward<_Tp>(__t)) {}
420 template <class _Tp, class _Alloc>
421 _LIBCPP_HIDE_FROM_ABI constexpr explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
422 : _Hp(allocator_arg_t(), __a, std::forward<_Tp>(__t)) {}
424 template <class _Tp, class _Alloc>
425 _LIBCPP_HIDE_FROM_ABI constexpr explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
426 : _Hp(std::forward<_Tp>(__t), __a) {}
428 __tuple_leaf(__tuple_leaf const&) = default;
429 __tuple_leaf(__tuple_leaf&&) = default;
431 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
432 swap(__tuple_leaf& __t) noexcept(__is_nothrow_swappable_v<__tuple_leaf>) {
433 std::swap(*this, __t);
437 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(const __tuple_leaf& __rhs) const
438 noexcept(__is_nothrow_swappable_v<const __tuple_leaf>) {
439 std::swap(*this, __rhs);
443 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Hp& get() _NOEXCEPT { return static_cast<_Hp&>(*this); }
444 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT {
445 return static_cast<const _Hp&>(*this);
449 template <class... _Tp>
450 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swallow(_Tp&&...) _NOEXCEPT {}
453 struct __all_default_constructible;
455 template <class... _Tp>
456 struct __all_default_constructible<__tuple_types<_Tp...>> : __all<is_default_constructible<_Tp>::value...> {};
460 template <class _Indx, class... _Tp>
463 template <size_t... _Indx, class... _Tp>
464 struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
465 : public __tuple_leaf<_Indx, _Tp>... {
466 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_impl() noexcept(
467 __all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
469 template <size_t... _Uf, class... _Tf, size_t... _Ul, class... _Tl, class... _Up>
470 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_impl(
471 __tuple_indices<_Uf...>,
472 __tuple_types<_Tf...>,
473 __tuple_indices<_Ul...>,
474 __tuple_types<_Tl...>,
475 _Up&&... __u) noexcept(__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
476 __all<is_nothrow_default_constructible<_Tl>::value...>::value)
477 : __tuple_leaf<_Uf, _Tf>(std::forward<_Up>(__u))..., __tuple_leaf<_Ul, _Tl>()... {}
479 template <class _Alloc, size_t... _Uf, class... _Tf, size_t... _Ul, class... _Tl, class... _Up>
480 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_impl(
483 __tuple_indices<_Uf...>,
484 __tuple_types<_Tf...>,
485 __tuple_indices<_Ul...>,
486 __tuple_types<_Tl...>,
488 : __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a, std::forward<_Up>(__u))...,
489 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)... {}
491 template <class _Tuple, __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value, int> = 0>
492 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(_Tuple&& __t) noexcept(
493 (__all<is_nothrow_constructible<
495 typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
496 : __tuple_leaf<_Indx, _Tp>(
497 std::forward<typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>(
498 std::get<_Indx>(__t)))... {}
500 template <class _Alloc, class _Tuple, __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value, int> = 0>
501 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
502 : __tuple_leaf<_Indx, _Tp>(
503 __uses_alloc_ctor<_Tp,
505 typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>(),
507 std::forward<typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>(
508 std::get<_Indx>(__t)))... {}
510 __tuple_impl(const __tuple_impl&) = default;
511 __tuple_impl(__tuple_impl&&) = default;
513 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
514 swap(__tuple_impl& __t) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {
515 std::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
518 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(const __tuple_impl& __t) const
519 noexcept(__all<__is_nothrow_swappable_v<const _Tp>...>::value) {
520 std::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t))...);
524 template <class _Dest, class _Source, size_t... _Np>
525 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
526 __memberwise_copy_assign(_Dest& __dest, _Source const& __source, __tuple_indices<_Np...>) {
527 std::__swallow(((std::get<_Np>(__dest) = std::get<_Np>(__source)), void(), 0)...);
530 template <class _Dest, class _Source, class... _Up, size_t... _Np>
531 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
532 __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up...>, __tuple_indices<_Np...>) {
533 std::__swallow(((std::get<_Np>(__dest) = std::forward<_Up>(std::get<_Np>(__source))), void(), 0)...);
536 template <class... _Tp>
537 class _LIBCPP_TEMPLATE_VIS tuple {
538 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
542 template <size_t _Jp, class... _Up>
543 friend _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
544 template <size_t _Jp, class... _Up>
545 friend _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Jp, tuple<_Up...> >::type&
546 get(const tuple<_Up...>&) _NOEXCEPT;
547 template <size_t _Jp, class... _Up>
548 friend _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Jp, tuple<_Up...> >::type&&
549 get(tuple<_Up...>&&) _NOEXCEPT;
550 template <size_t _Jp, class... _Up>
551 friend _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Jp, tuple<_Up...> >::type&&
552 get(const tuple<_Up...>&&) _NOEXCEPT;
555 using __trivially_relocatable = __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>;
559 // tuple() constructors (including allocator_arg_t variants)
560 template <template <class...> class _IsImpDefault = __is_implicitly_default_constructible,
561 template <class...> class _IsDefault = is_default_constructible,
562 __enable_if_t< _And< _IsDefault<_Tp>... >::value, int> = 0>
563 _LIBCPP_HIDE_FROM_ABI constexpr explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value)
564 tuple() noexcept(_And<is_nothrow_default_constructible<_Tp>...>::value) {}
566 template <class _Alloc,
567 template <class...> class _IsImpDefault = __is_implicitly_default_constructible,
568 template <class...> class _IsDefault = is_default_constructible,
569 __enable_if_t< _And< _IsDefault<_Tp>... >::value, int> = 0>
570 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value)
571 tuple(allocator_arg_t, _Alloc const& __a)
572 : __base_(allocator_arg_t(),
576 typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
577 __tuple_types<_Tp...>()) {}
579 // tuple(const T&...) constructors (including allocator_arg_t variants)
580 template <template <class...> class _And = _And,
581 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0>
582 _LIBCPP_HIDE_FROM_ABI
583 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value)
584 tuple(const _Tp&... __t) noexcept(_And<is_nothrow_copy_constructible<_Tp>...>::value)
585 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
586 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
587 typename __make_tuple_indices<0>::type(),
588 typename __make_tuple_types<tuple, 0>::type(),
591 template <class _Alloc,
592 template <class...> class _And = _And,
593 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0>
594 _LIBCPP_HIDE_FROM_ABI
595 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value)
596 tuple(allocator_arg_t, const _Alloc& __a, const _Tp&... __t)
597 : __base_(allocator_arg_t(),
599 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
600 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
601 typename __make_tuple_indices<0>::type(),
602 typename __make_tuple_types<tuple, 0>::type(),
605 // tuple(U&& ...) constructors (including allocator_arg_t variants)
606 template <class... _Up>
607 struct _IsThisTuple : false_type {};
609 struct _IsThisTuple<_Up> : is_same<__remove_cvref_t<_Up>, tuple> {};
611 template <class... _Up>
612 struct _EnableUTypesCtor
613 : _And< _BoolConstant<sizeof...(_Tp) >= 1>,
614 _Not<_IsThisTuple<_Up...> >, // extension to allow mis-behaved user constructors
615 is_constructible<_Tp, _Up>... > {};
617 template <class... _Up,
618 __enable_if_t< _And< _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, _EnableUTypesCtor<_Up...> >::value,
620 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
621 tuple(_Up&&... __u) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value)
622 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
623 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
624 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
625 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
626 std::forward<_Up>(__u)...) {}
628 template <class _Alloc,
630 __enable_if_t< _And< _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, _EnableUTypesCtor<_Up...> >::value,
632 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
633 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
634 : __base_(allocator_arg_t(),
636 typename __make_tuple_indices<sizeof...(_Up)>::type(),
637 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
638 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
639 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
640 std::forward<_Up>(__u)...) {}
642 // Copy and move constructors (including the allocator_arg_t variants)
643 tuple(const tuple&) = default;
644 tuple(tuple&&) = default;
646 template <class _Alloc,
647 template <class...> class _And = _And,
648 __enable_if_t< _And<is_copy_constructible<_Tp>...>::value, int> = 0>
649 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)
650 : __base_(allocator_arg_t(), __alloc, __t) {}
652 template <class _Alloc,
653 template <class...> class _And = _And,
654 __enable_if_t< _And<is_move_constructible<_Tp>...>::value, int> = 0>
655 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)
656 : __base_(allocator_arg_t(), __alloc, std::move(__t)) {}
658 // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants)
660 template <class _OtherTuple, class _DecayedOtherTuple = __remove_cvref_t<_OtherTuple>, class = void>
661 struct _EnableCtorFromUTypesTuple : false_type {};
663 template <class _OtherTuple, class... _Up>
664 struct _EnableCtorFromUTypesTuple<
667 // the length of the packs needs to checked first otherwise the 2 packs cannot be expanded simultaneously below
668 __enable_if_t<sizeof...(_Up) == sizeof...(_Tp)>>
670 // the two conditions below are not in spec. The purpose is to disable the UTypes Ctor when copy/move Ctor
671 // can work. Otherwise, is_constructible can trigger hard error in those cases
672 // https://godbolt.org/z/M94cGdKcE
673 _Not<is_same<_OtherTuple, const tuple&> >,
674 _Not<is_same<_OtherTuple, tuple&&> >,
675 is_constructible<_Tp, __copy_cvref_t<_OtherTuple, _Up> >...,
677 _BoolConstant<sizeof...(_Tp) != 1>,
678 // _Tp and _Up are 1-element packs - the pack expansions look
679 // weird to avoid tripping up the type traits in degenerate cases
681 _Not<is_same<_Tp, _Up> >...,
682 _Not<is_convertible<_OtherTuple, _Tp> >...,
683 _Not<is_constructible<_Tp, _OtherTuple> >... > > > {};
685 template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0>
686 _LIBCPP_HIDE_FROM_ABI
687 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value)
688 tuple(const tuple<_Up...>& __t) noexcept(_And<is_nothrow_constructible<_Tp, const _Up&>...>::value)
691 template <class... _Up,
693 __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0>
694 _LIBCPP_HIDE_FROM_ABI
695 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value)
696 tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
697 : __base_(allocator_arg_t(), __a, __t) {}
699 # if _LIBCPP_STD_VER >= 23
700 // tuple(tuple<U...>&) constructors (including allocator_arg_t variants)
702 template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
703 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value) tuple(tuple<_Up...>& __t)
706 template <class _Alloc, class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
707 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value)
708 tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t)
709 : __base_(allocator_arg_t(), __alloc, __t) {}
710 # endif // _LIBCPP_STD_VER >= 23
712 // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)
713 template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0>
714 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
715 tuple(tuple<_Up...>&& __t) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value)
716 : __base_(std::move(__t)) {}
718 template <class _Alloc,
720 __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0>
721 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
722 tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
723 : __base_(allocator_arg_t(), __a, std::move(__t)) {}
725 # if _LIBCPP_STD_VER >= 23
726 // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants)
728 template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
729 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value)
730 tuple(const tuple<_Up...>&& __t)
731 : __base_(std::move(__t)) {}
733 template <class _Alloc,
735 enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
736 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value)
737 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t)
738 : __base_(allocator_arg_t(), __alloc, std::move(__t)) {}
739 # endif // _LIBCPP_STD_VER >= 23
741 // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)
743 template <template <class...> class _Pred,
745 class _DecayedPair = __remove_cvref_t<_Pair>,
746 class _Tuple = tuple>
747 struct _CtorPredicateFromPair : false_type {};
749 template <template <class...> class _Pred, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
750 struct _CtorPredicateFromPair<_Pred, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> >
751 : _And< _Pred<_Tp1, __copy_cvref_t<_Pair, _Up1> >, _Pred<_Tp2, __copy_cvref_t<_Pair, _Up2> > > {};
753 template <class _Pair>
754 struct _EnableCtorFromPair : _CtorPredicateFromPair<is_constructible, _Pair> {};
756 template <class _Pair>
757 struct _NothrowConstructibleFromPair : _CtorPredicateFromPair<is_nothrow_constructible, _Pair> {};
759 template <class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
760 struct _BothImplicitlyConvertible : false_type {};
762 template <class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
763 struct _BothImplicitlyConvertible<_Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> >
764 : _And< is_convertible<__copy_cvref_t<_Pair, _Up1>, _Tp1>, is_convertible<__copy_cvref_t<_Pair, _Up2>, _Tp2> > {};
766 template <class _Up1,
768 template <class...> class _And = _And,
769 __enable_if_t< _And< _EnableCtorFromPair<const pair<_Up1, _Up2>&> >::value, int> = 0>
770 _LIBCPP_HIDE_FROM_ABI
771 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value)
772 tuple(const pair<_Up1, _Up2>& __p) noexcept(_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value)
775 template <class _Alloc,
778 template <class...> class _And = _And,
779 __enable_if_t< _And< _EnableCtorFromPair<const pair<_Up1, _Up2>&> >::value, int> = 0>
780 _LIBCPP_HIDE_FROM_ABI
781 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value)
782 tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
783 : __base_(allocator_arg_t(), __a, __p) {}
785 # if _LIBCPP_STD_VER >= 23
786 // tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants)
788 template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr>
789 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
790 tuple(pair<_U1, _U2>& __p)
793 template <class _Alloc,
796 enable_if_t< _EnableCtorFromPair<std::pair<_U1, _U2>&>::value>* = nullptr>
797 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
798 tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p)
799 : __base_(allocator_arg_t(), __alloc, __p) {}
802 // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)
804 template <class _Up1,
806 template <class...> class _And = _And,
807 __enable_if_t< _And< _EnableCtorFromPair<pair<_Up1, _Up2>&&> >::value, int> = 0>
808 _LIBCPP_HIDE_FROM_ABI
809 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value)
810 tuple(pair<_Up1, _Up2>&& __p) noexcept(_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value)
811 : __base_(std::move(__p)) {}
813 template <class _Alloc,
816 template <class...> class _And = _And,
817 __enable_if_t< _And< _EnableCtorFromPair<pair<_Up1, _Up2>&&> >::value, int> = 0>
818 _LIBCPP_HIDE_FROM_ABI
819 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value)
820 tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
821 : __base_(allocator_arg_t(), __a, std::move(__p)) {}
823 # if _LIBCPP_STD_VER >= 23
824 // tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants)
826 template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
827 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
828 tuple(const pair<_U1, _U2>&& __p)
829 : __base_(std::move(__p)) {}
831 template <class _Alloc,
834 enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
835 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
836 tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p)
837 : __base_(allocator_arg_t(), __alloc, std::move(__p)) {}
838 # endif // _LIBCPP_STD_VER >= 23
841 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
842 operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) noexcept(
843 _And<is_nothrow_copy_assignable<_Tp>...>::value) {
844 std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
848 # if _LIBCPP_STD_VER >= 23
849 _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple const& __tuple) const
850 requires(_And<is_copy_assignable<const _Tp>...>::value)
852 std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
856 _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple&& __tuple) const
857 requires(_And<is_assignable<const _Tp&, _Tp>...>::value)
859 std::__memberwise_forward_assign(
860 *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
863 # endif // _LIBCPP_STD_VER >= 23
865 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
866 operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) noexcept(
867 _And<is_nothrow_move_assignable<_Tp>...>::value) {
868 std::__memberwise_forward_assign(
869 *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
875 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up const&>... >::value,
877 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
878 operator=(tuple<_Up...> const& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) {
879 std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
883 template <class... _Up,
884 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up>... >::value,
886 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
887 operator=(tuple<_Up...>&& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) {
888 std::__memberwise_forward_assign(
889 *this, std::move(__tuple), __tuple_types<_Up...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
893 # if _LIBCPP_STD_VER >= 23
894 template <class... _UTypes,
895 enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
896 is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr>
897 _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(const tuple<_UTypes...>& __u) const {
898 std::__memberwise_copy_assign(*this, __u, typename __make_tuple_indices<sizeof...(_Tp)>::type());
902 template <class... _UTypes,
903 enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
904 is_assignable<const _Tp&, _UTypes>...>::value>* = nullptr>
905 _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple<_UTypes...>&& __u) const {
906 std::__memberwise_forward_assign(
907 *this, __u, __tuple_types<_UTypes...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
910 # endif // _LIBCPP_STD_VER >= 23
912 template <template <class...> class _Pred,
915 class _DecayedPair = __remove_cvref_t<_Pair>,
916 class _Tuple = tuple>
917 struct _AssignPredicateFromPair : false_type {};
919 template <template <class...> class _Pred, bool _Const, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
920 struct _AssignPredicateFromPair<_Pred, _Const, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> >
921 : _And<_Pred<__maybe_const<_Const, _Tp1>&, __copy_cvref_t<_Pair, _Up1> >,
922 _Pred<__maybe_const<_Const, _Tp2>&, __copy_cvref_t<_Pair, _Up2> > > {};
924 template <bool _Const, class _Pair>
925 struct _EnableAssignFromPair : _AssignPredicateFromPair<is_assignable, _Const, _Pair> {};
927 template <bool _Const, class _Pair>
928 struct _NothrowAssignFromPair : _AssignPredicateFromPair<is_nothrow_assignable, _Const, _Pair> {};
930 # if _LIBCPP_STD_VER >= 23
931 template <class _U1, class _U2, enable_if_t< _EnableAssignFromPair<true, const pair<_U1, _U2>&>::value>* = nullptr>
932 _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(const pair<_U1, _U2>& __pair) const
933 noexcept(_NothrowAssignFromPair<true, const pair<_U1, _U2>&>::value) {
934 std::get<0>(*this) = __pair.first;
935 std::get<1>(*this) = __pair.second;
939 template <class _U1, class _U2, enable_if_t< _EnableAssignFromPair<true, pair<_U1, _U2>&&>::value>* = nullptr>
940 _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(pair<_U1, _U2>&& __pair) const
941 noexcept(_NothrowAssignFromPair<true, pair<_U1, _U2>&&>::value) {
942 std::get<0>(*this) = std::move(__pair.first);
943 std::get<1>(*this) = std::move(__pair.second);
946 # endif // _LIBCPP_STD_VER >= 23
948 template <class _Up1,
950 __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value, int> = 0>
951 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
952 operator=(pair<_Up1, _Up2> const& __pair) noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value) {
953 std::get<0>(*this) = __pair.first;
954 std::get<1>(*this) = __pair.second;
958 template <class _Up1, class _Up2, __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value, int> = 0>
959 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
960 operator=(pair<_Up1, _Up2>&& __pair) noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value) {
961 std::get<0>(*this) = std::forward<_Up1>(__pair.first);
962 std::get<1>(*this) = std::forward<_Up2>(__pair.second);
970 __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value, int> = 0>
971 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
972 operator=(array<_Up, _Np> const& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) {
973 std::__memberwise_copy_assign(*this, __array, typename __make_tuple_indices<sizeof...(_Tp)>::type());
981 __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up>... >::value, int> = 0>
982 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
983 operator=(array<_Up, _Np>&& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) {
984 std::__memberwise_forward_assign(
987 __tuple_types<_If<true, _Up, _Tp>...>(),
988 typename __make_tuple_indices<sizeof...(_Tp)>::type());
993 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
994 swap(tuple& __t) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {
995 __base_.swap(__t.__base_);
998 # if _LIBCPP_STD_VER >= 23
999 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple& __t) const
1000 noexcept(__all<is_nothrow_swappable_v<const _Tp&>...>::value) {
1001 __base_.swap(__t.__base_);
1003 # endif // _LIBCPP_STD_VER >= 23
1007 class _LIBCPP_TEMPLATE_VIS tuple<> {
1009 constexpr tuple() _NOEXCEPT = default;
1010 template <class _Alloc>
1011 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
1012 template <class _Alloc>
1013 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
1014 template <class _Up>
1015 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(array<_Up, 0>) _NOEXCEPT {}
1016 template <class _Alloc, class _Up>
1017 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
1018 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple&) _NOEXCEPT {}
1019 # if _LIBCPP_STD_VER >= 23
1020 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}
1024 # if _LIBCPP_STD_VER >= 23
1025 template <class... _TTypes, class... _UTypes, template <class> class _TQual, template <class> class _UQual>
1026 requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; }
1027 struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> {
1028 using type = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>;
1031 template <class... _TTypes, class... _UTypes>
1032 requires requires { typename tuple<common_type_t<_TTypes, _UTypes>...>; }
1033 struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {
1034 using type = tuple<common_type_t<_TTypes, _UTypes>...>;
1036 # endif // _LIBCPP_STD_VER >= 23
1038 # if _LIBCPP_STD_VER >= 17
1039 template <class... _Tp>
1040 tuple(_Tp...) -> tuple<_Tp...>;
1041 template <class _Tp1, class _Tp2>
1042 tuple(pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
1043 template <class _Alloc, class... _Tp>
1044 tuple(allocator_arg_t, _Alloc, _Tp...) -> tuple<_Tp...>;
1045 template <class _Alloc, class _Tp1, class _Tp2>
1046 tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
1047 template <class _Alloc, class... _Tp>
1048 tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
1051 template <class... _Tp, __enable_if_t<__all<__is_swappable_v<_Tp>...>::value, int> = 0>
1052 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
1053 swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {
1057 # if _LIBCPP_STD_VER >= 23
1058 template <class... _Tp>
1059 _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<__all<is_swappable_v<const _Tp>...>::value, void>
1060 swap(const tuple<_Tp...>& __lhs,
1061 const tuple<_Tp...>& __rhs) noexcept(__all<is_nothrow_swappable_v<const _Tp>...>::value) {
1068 template <size_t _Ip, class... _Tp>
1069 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&
1070 get(tuple<_Tp...>& __t) _NOEXCEPT {
1071 using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type;
1072 return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
1075 template <size_t _Ip, class... _Tp>
1076 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
1077 get(const tuple<_Tp...>& __t) _NOEXCEPT {
1078 using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type;
1079 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
1082 template <size_t _Ip, class... _Tp>
1083 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1084 get(tuple<_Tp...>&& __t) _NOEXCEPT {
1085 using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type;
1086 return static_cast<type&&>(static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
1089 template <size_t _Ip, class... _Tp>
1090 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1091 get(const tuple<_Tp...>&& __t) _NOEXCEPT {
1092 using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type;
1093 return static_cast<const type&&>(static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
1096 # if _LIBCPP_STD_VER >= 14
1098 template <class _T1, class... _Args>
1099 inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(tuple<_Args...>& __tup) noexcept {
1100 return std::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1103 template <class _T1, class... _Args>
1104 inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept {
1105 return std::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1108 template <class _T1, class... _Args>
1109 inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept {
1110 return std::get<__find_exactly_one_t<_T1, _Args...>::value>(std::move(__tup));
1113 template <class _T1, class... _Args>
1114 inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept {
1115 return std::get<__find_exactly_one_t<_T1, _Args...>::value>(std::move(__tup));
1122 template <class... _Tp>
1123 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_Tp&... __t) _NOEXCEPT {
1124 return tuple<_Tp&...>(__t...);
1127 template <class... _Tp>
1128 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<typename __unwrap_ref_decay<_Tp>::type...>
1129 make_tuple(_Tp&&... __t) {
1130 return tuple<typename __unwrap_ref_decay<_Tp>::type...>(std::forward<_Tp>(__t)...);
1133 template <class... _Tp>
1134 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&&...> forward_as_tuple(_Tp&&... __t) _NOEXCEPT {
1135 return tuple<_Tp&&...>(std::forward<_Tp>(__t)...);
1138 template <size_t _Ip>
1139 struct __tuple_equal {
1140 template <class _Tp, class _Up>
1141 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __x, const _Up& __y) {
1142 return __tuple_equal<_Ip - 1>()(__x, __y) && std::get<_Ip - 1>(__x) == std::get<_Ip - 1>(__y);
1147 struct __tuple_equal<0> {
1148 template <class _Tp, class _Up>
1149 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp&, const _Up&) {
1154 template <class... _Tp, class... _Up>
1155 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1156 operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1157 static_assert(sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
1158 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
1161 # if _LIBCPP_STD_VER >= 20
1165 template <class... _Tp, class... _Up, size_t... _Is>
1166 _LIBCPP_HIDE_FROM_ABI constexpr auto
1167 __tuple_compare_three_way(const tuple<_Tp...>& __x, const tuple<_Up...>& __y, index_sequence<_Is...>) {
1168 common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> __result = strong_ordering::equal;
1170 ((__result = std::__synth_three_way(std::get<_Is>(__x), std::get<_Is>(__y)), __result != 0) || ...));
1174 template <class... _Tp, class... _Up>
1175 requires(sizeof...(_Tp) == sizeof...(_Up))
1176 _LIBCPP_HIDE_FROM_ABI constexpr common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...>
1177 operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1178 return std::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{});
1181 # else // _LIBCPP_STD_VER >= 20
1183 template <class... _Tp, class... _Up>
1184 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1185 operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1186 return !(__x == __y);
1189 template <size_t _Ip>
1190 struct __tuple_less {
1191 template <class _Tp, class _Up>
1192 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __x, const _Up& __y) {
1193 const size_t __idx = tuple_size<_Tp>::value - _Ip;
1194 if (std::get<__idx>(__x) < std::get<__idx>(__y))
1196 if (std::get<__idx>(__y) < std::get<__idx>(__x))
1198 return __tuple_less<_Ip - 1>()(__x, __y);
1203 struct __tuple_less<0> {
1204 template <class _Tp, class _Up>
1205 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp&, const _Up&) {
1210 template <class... _Tp, class... _Up>
1211 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1212 operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1213 static_assert(sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
1214 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
1217 template <class... _Tp, class... _Up>
1218 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1219 operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1223 template <class... _Tp, class... _Up>
1224 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1225 operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1226 return !(__x < __y);
1229 template <class... _Tp, class... _Up>
1230 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1231 operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1232 return !(__y < __x);
1235 # endif // _LIBCPP_STD_VER >= 20
1239 template <class _Tp, class _Up>
1240 struct __tuple_cat_type;
1242 template <class... _Ttypes, class... _Utypes>
1243 struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> > {
1244 using type _LIBCPP_NODEBUG = tuple<_Ttypes..., _Utypes...>;
1247 template <class _ResultTuple, bool _Is_Tuple0TupleLike, class... _Tuples>
1248 struct __tuple_cat_return_1 {};
1250 template <class... _Types, class _Tuple0>
1251 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0> {
1252 using type _LIBCPP_NODEBUG =
1253 typename __tuple_cat_type< tuple<_Types...>,
1254 typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type >::type;
1257 template <class... _Types, class _Tuple0, class _Tuple1, class... _Tuples>
1258 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
1259 : public __tuple_cat_return_1<
1260 typename __tuple_cat_type< tuple<_Types...>,
1261 typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type >::type,
1262 __tuple_like_ext<__libcpp_remove_reference_t<_Tuple1> >::value,
1266 template <class... _Tuples>
1267 struct __tuple_cat_return;
1269 template <class _Tuple0, class... _Tuples>
1270 struct __tuple_cat_return<_Tuple0, _Tuples...>
1271 : public __tuple_cat_return_1<tuple<>,
1272 __tuple_like_ext<__libcpp_remove_reference_t<_Tuple0> >::value,
1277 struct __tuple_cat_return<> {
1278 using type _LIBCPP_NODEBUG = tuple<>;
1281 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<> tuple_cat() { return tuple<>(); }
1283 template <class _Rp, class _Indices, class _Tuple0, class... _Tuples>
1284 struct __tuple_cat_return_ref_imp;
1286 template <class... _Types, size_t... _I0, class _Tuple0>
1287 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> {
1288 using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>;
1289 typedef tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type;
1292 template <class... _Types, size_t... _I0, class _Tuple0, class _Tuple1, class... _Tuples>
1293 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0, _Tuple1, _Tuples...>
1294 : public __tuple_cat_return_ref_imp<
1296 __copy_cvref_t<_Tuple0, typename tuple_element<_I0, __libcpp_remove_reference_t<_Tuple0>>::type>&&...>,
1297 typename __make_tuple_indices<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>::type,
1301 template <class _Tuple0, class... _Tuples>
1302 struct __tuple_cat_return_ref
1303 : public __tuple_cat_return_ref_imp<
1305 typename __make_tuple_indices< tuple_size<__libcpp_remove_reference_t<_Tuple0> >::value >::type,
1309 template <class _Types, class _I0, class _J0>
1312 template <class... _Types, size_t... _I0, size_t... _J0>
1313 struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> > {
1314 template <class _Tuple0>
1315 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
1316 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1317 operator()(tuple<_Types...> __t, _Tuple0&& __t0) {
1318 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1319 return std::forward_as_tuple(
1320 std::forward<_Types>(std::get<_I0>(__t))..., std::get<_J0>(std::forward<_Tuple0>(__t0))...);
1323 template <class _Tuple0, class _Tuple1, class... _Tuples>
1324 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
1325 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1326 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&&... __tpls) {
1327 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1328 using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>;
1329 using _T1 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple1>;
1330 return __tuple_cat<tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>,
1331 typename __make_tuple_indices<sizeof...(_Types) + tuple_size<_T0>::value>::type,
1332 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
1333 std::forward_as_tuple(
1334 std::forward<_Types>(std::get<_I0>(__t))..., std::get<_J0>(std::forward<_Tuple0>(__t0))...),
1335 std::forward<_Tuple1>(__t1),
1336 std::forward<_Tuples>(__tpls)...);
1340 template <class _Tuple0, class... _Tuples>
1341 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1342 tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) {
1343 using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>;
1344 return __tuple_cat<tuple<>, __tuple_indices<>, typename __make_tuple_indices<tuple_size<_T0>::value>::type>()(
1345 tuple<>(), std::forward<_Tuple0>(__t0), std::forward<_Tuples>(__tpls)...);
1348 template <class... _Tp, class _Alloc>
1349 struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc> : true_type {};
1351 # if _LIBCPP_STD_VER >= 17
1352 # define _LIBCPP_NOEXCEPT_RETURN(...) \
1353 noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
1355 // The _LIBCPP_NOEXCEPT_RETURN macro breaks formatting.
1357 template <class _Fn, class _Tuple, size_t... _Id>
1358 inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto)
1359 __apply_tuple_impl(_Fn&& __f, _Tuple&& __t, __tuple_indices<_Id...>)
1360 _LIBCPP_NOEXCEPT_RETURN(std::__invoke(std::forward<_Fn>(__f), std::get<_Id>(std::forward<_Tuple>(__t))...))
1362 template <class _Fn, class _Tuple>
1363 inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) apply(_Fn&& __f, _Tuple&& __t)
1364 _LIBCPP_NOEXCEPT_RETURN(std::__apply_tuple_impl(
1365 std::forward<_Fn>(__f),
1366 std::forward<_Tuple>(__t),
1367 typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{}))
1369 #if _LIBCPP_STD_VER >= 20
1370 template <class _Tp, class _Tuple, size_t... _Idx>
1371 inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
1372 noexcept(noexcept(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...)))
1373 requires is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...> {
1374 return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...);
1377 template <class _Tp, class _Tuple, size_t... _Idx>
1378 inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>,
1379 enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...>> * = nullptr)
1380 _LIBCPP_NOEXCEPT_RETURN(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...))
1381 #endif // _LIBCPP_STD_VER >= 20
1383 template <class _Tp, class _Tuple,
1384 class _Seq = typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type, class = void>
1385 inline constexpr bool __can_make_from_tuple = false;
1387 template <class _Tp, class _Tuple, size_t... _Idx>
1388 inline constexpr bool __can_make_from_tuple<_Tp, _Tuple, __tuple_indices<_Idx...>,
1389 enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::declval<_Tuple>()))...>>> = true;
1391 // Based on LWG3528(https://wg21.link/LWG3528) and http://eel.is/c++draft/description#structure.requirements-9,
1392 // the standard allows to impose requirements, we constraint std::make_from_tuple to make std::make_from_tuple
1393 // SFINAE friendly and also avoid worse diagnostic messages. We still keep the constraints of std::__make_from_tuple_impl
1394 // so that std::__make_from_tuple_impl will have the same advantages when used alone.
1395 #if _LIBCPP_STD_VER >= 20
1396 template <class _Tp, class _Tuple>
1397 requires __can_make_from_tuple<_Tp, _Tuple> // strengthen
1399 template <class _Tp, class _Tuple, class = enable_if_t<__can_make_from_tuple<_Tp, _Tuple>>> // strengthen
1400 #endif // _LIBCPP_STD_VER >= 20
1401 inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp make_from_tuple(_Tuple&& __t)
1402 _LIBCPP_NOEXCEPT_RETURN(std::__make_from_tuple_impl<_Tp>(
1403 std::forward<_Tuple>(__t), typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{}))
1404 # undef _LIBCPP_NOEXCEPT_RETURN
1406 # endif // _LIBCPP_STD_VER >= 17
1408 #endif // !defined(_LIBCPP_CXX03_LANG)
1410 _LIBCPP_END_NAMESPACE_STD
1416 # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1418 # include <exception>
1421 # include <type_traits>
1422 # include <typeinfo>
1425 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
1427 #endif // _LIBCPP_TUPLE