• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
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
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_TUPLE
11#define _LIBCPP_TUPLE
12
13/*
14    tuple synopsis
15
16namespace std
17{
18
19template <class... T>
20class tuple {
21public:
22    explicit(see-below) constexpr tuple();
23    explicit(see-below) tuple(const T&...);  // constexpr in C++14
24    template <class... U>
25        explicit(see-below) tuple(U&&...);  // constexpr in C++14
26    tuple(const tuple&) = default;
27    tuple(tuple&&) = default;
28
29    template<class... UTypes>
30        constexpr explicit(see-below) tuple(tuple<UTypes...>&);  // C++23
31    template <class... U>
32        explicit(see-below) tuple(const tuple<U...>&);  // constexpr in C++14
33    template <class... U>
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
37
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
46
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
78
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
83    template <class... U>
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
87    template <class... U>
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
99
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
104
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
107};
108
109
110template<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>>...>; }
112struct basic_common_reference<tuple<TTypes...>, tuple<UTypes...>, TQual, UQual> {
113  using type = tuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...>;
114};
115
116template<class... TTypes, class... UTypes>                                // since C++23
117  requires requires { typename tuple<common_type_t<TTypes, UTypes>...>; }
118struct common_type<tuple<TTypes...>, tuple<UTypes...>> {
119  using type = tuple<common_type_t<TTypes, UTypes>...>;
120};
121
122template <class ...T>
123tuple(T...) -> tuple<T...>;                                         // since C++17
124template <class T1, class T2>
125tuple(pair<T1, T2>) -> tuple<T1, T2>;                               // since C++17
126template <class Alloc, class ...T>
127tuple(allocator_arg_t, Alloc, T...) -> tuple<T...>;                 // since C++17
128template <class Alloc, class T1, class T2>
129tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>;       // since C++17
130template <class Alloc, class ...T>
131tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>;          // since C++17
132
133inline constexpr unspecified ignore;
134
135template <class... T> tuple<V...>  make_tuple(T&&...); // constexpr in C++14
136template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
137template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
138template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
139
140// [tuple.apply], calling a function with a tuple of arguments:
141template <class F, class Tuple>
142  constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17
143template <class T, class Tuple>
144  constexpr T make_from_tuple(Tuple&& t); // C++17
145
146// 20.4.1.4, tuple helper classes:
147template <class T> struct tuple_size; // undefined
148template <class... T> struct tuple_size<tuple<T...>>;
149template <class T>
150 inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
151template <size_t I, class T> struct tuple_element; // undefined
152template <size_t I, class... T> struct tuple_element<I, tuple<T...>>;
153template <size_t I, class T>
154  using tuple_element_t = typename tuple_element <I, T>::type; // C++14
155
156// 20.4.1.5, element access:
157template <size_t I, class... T>
158    typename tuple_element<I, tuple<T...>>::type&
159    get(tuple<T...>&) noexcept; // constexpr in C++14
160template <size_t I, class... T>
161    const typename tuple_element<I, tuple<T...>>::type&
162    get(const tuple<T...>&) noexcept; // constexpr in C++14
163template <size_t I, class... T>
164    typename tuple_element<I, tuple<T...>>::type&&
165    get(tuple<T...>&&) noexcept; // constexpr in C++14
166template <size_t I, class... T>
167    const typename tuple_element<I, tuple<T...>>::type&&
168    get(const tuple<T...>&&) noexcept; // constexpr in C++14
169
170template <class T1, class... T>
171    constexpr T1& get(tuple<T...>&) noexcept;  // C++14
172template <class T1, class... T>
173    constexpr const T1& get(const tuple<T...>&) noexcept;   // C++14
174template <class T1, class... T>
175    constexpr T1&& get(tuple<T...>&&) noexcept;   // C++14
176template <class T1, class... T>
177    constexpr const T1&& get(const tuple<T...>&&) noexcept;   // C++14
178
179// 20.4.1.6, relational operators:
180template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
181template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&);  // constexpr in C++14, removed in C++20
182template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
183template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&);  // constexpr in C++14, removed in C++20
184template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
185template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
186template<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
189
190template <class... Types, class Alloc>
191  struct uses_allocator<tuple<Types...>, Alloc>;
192
193template <class... Types>
194  void
195  swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
196
197template <class... Types>
198  constexpr void swap(const tuple<Types...>& x, const tuple<Types...>& y) noexcept(see-below);   // C++23
199
200}  // std
201
202*/
203
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>
207#include <__config>
208#include <__functional/invoke.h>
209#include <__functional/unwrap_ref.h>
210#include <__fwd/array.h>
211#include <__memory/allocator_arg_t.h>
212#include <__memory/uses_allocator.h>
213#include <__type_traits/apply_cv.h>
214#include <__type_traits/common_reference.h>
215#include <__type_traits/common_type.h>
216#include <__type_traits/conditional.h>
217#include <__type_traits/conjunction.h>
218#include <__type_traits/copy_cvref.h>
219#include <__type_traits/disjunction.h>
220#include <__type_traits/is_arithmetic.h>
221#include <__type_traits/is_assignable.h>
222#include <__type_traits/is_constructible.h>
223#include <__type_traits/is_convertible.h>
224#include <__type_traits/is_copy_assignable.h>
225#include <__type_traits/is_copy_constructible.h>
226#include <__type_traits/is_default_constructible.h>
227#include <__type_traits/is_empty.h>
228#include <__type_traits/is_final.h>
229#include <__type_traits/is_implicitly_default_constructible.h>
230#include <__type_traits/is_move_assignable.h>
231#include <__type_traits/is_move_constructible.h>
232#include <__type_traits/is_nothrow_assignable.h>
233#include <__type_traits/is_nothrow_constructible.h>
234#include <__type_traits/is_nothrow_copy_assignable.h>
235#include <__type_traits/is_nothrow_copy_constructible.h>
236#include <__type_traits/is_nothrow_default_constructible.h>
237#include <__type_traits/is_nothrow_move_assignable.h>
238#include <__type_traits/is_reference.h>
239#include <__type_traits/is_same.h>
240#include <__type_traits/is_swappable.h>
241#include <__type_traits/lazy.h>
242#include <__type_traits/maybe_const.h>
243#include <__type_traits/nat.h>
244#include <__type_traits/negation.h>
245#include <__type_traits/remove_cvref.h>
246#include <__type_traits/remove_reference.h>
247#include <__utility/forward.h>
248#include <__utility/integer_sequence.h>
249#include <__utility/move.h>
250#include <__utility/pair.h>
251#include <__utility/piecewise_construct.h>
252#include <__utility/swap.h>
253#include <cstddef>
254#include <version>
255
256// standard-mandated includes
257
258// [tuple.syn]
259#include <compare>
260
261#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
262#  pragma GCC system_header
263#endif
264
265_LIBCPP_BEGIN_NAMESPACE_STD
266
267#ifndef _LIBCPP_CXX03_LANG
268
269
270// __tuple_leaf
271
272template <size_t _Ip, class _Hp,
273          bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
274         >
275class __tuple_leaf;
276
277template <size_t _Ip, class _Hp, bool _Ep>
278inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
279void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
280    _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
281{
282    swap(__x.get(), __y.get());
283}
284
285template <size_t _Ip, class _Hp, bool _Ep>
286_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
287void swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x, const __tuple_leaf<_Ip, _Hp, _Ep>& __y)
288     _NOEXCEPT_(__is_nothrow_swappable<const _Hp>::value) {
289  swap(__x.get(), __y.get());
290}
291
292template <size_t _Ip, class _Hp, bool>
293class __tuple_leaf
294{
295    _Hp __value_;
296
297    template <class _Tp>
298    static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() {
299#if __has_keyword(__reference_binds_to_temporary)
300      return !__reference_binds_to_temporary(_Hp, _Tp);
301#else
302      return true;
303#endif
304    }
305
306    _LIBCPP_CONSTEXPR_SINCE_CXX14
307    __tuple_leaf& operator=(const __tuple_leaf&);
308public:
309    _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
310             _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_()
311       {static_assert(!is_reference<_Hp>::value,
312              "Attempted to default construct a reference element in a tuple");}
313
314    template <class _Alloc>
315        _LIBCPP_INLINE_VISIBILITY constexpr
316        __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
317            : __value_()
318        {static_assert(!is_reference<_Hp>::value,
319              "Attempted to default construct a reference element in a tuple");}
320
321    template <class _Alloc>
322        _LIBCPP_INLINE_VISIBILITY constexpr
323        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
324            : __value_(allocator_arg_t(), __a)
325        {static_assert(!is_reference<_Hp>::value,
326              "Attempted to default construct a reference element in a tuple");}
327
328    template <class _Alloc>
329        _LIBCPP_INLINE_VISIBILITY constexpr
330        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
331            : __value_(__a)
332        {static_assert(!is_reference<_Hp>::value,
333              "Attempted to default construct a reference element in a tuple");}
334
335    template <class _Tp,
336              class = __enable_if_t<
337                  _And<
338                      _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>,
339                      is_constructible<_Hp, _Tp>
340                    >::value
341                >
342            >
343        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
344        explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
345            : __value_(_VSTD::forward<_Tp>(__t))
346        {static_assert(__can_bind_reference<_Tp&&>(),
347       "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
348
349    template <class _Tp, class _Alloc>
350        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
351        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
352            : __value_(_VSTD::forward<_Tp>(__t))
353        {static_assert(__can_bind_reference<_Tp&&>(),
354       "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
355
356    template <class _Tp, class _Alloc>
357        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
358        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
359            : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
360        {static_assert(!is_reference<_Hp>::value,
361            "Attempted to uses-allocator construct a reference element in a tuple");}
362
363    template <class _Tp, class _Alloc>
364        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
365        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
366            : __value_(_VSTD::forward<_Tp>(__t), __a)
367        {static_assert(!is_reference<_Hp>::value,
368           "Attempted to uses-allocator construct a reference element in a tuple");}
369
370    _LIBCPP_HIDE_FROM_ABI __tuple_leaf(const __tuple_leaf& __t) = default;
371    _LIBCPP_HIDE_FROM_ABI __tuple_leaf(__tuple_leaf&& __t) = default;
372
373    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
374    int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
375    {
376        _VSTD::swap(*this, __t);
377        return 0;
378    }
379
380    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
381    int swap(const __tuple_leaf& __t) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
382        _VSTD::swap(*this, __t);
383        return 0;
384    }
385
386    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14       _Hp& get()       _NOEXCEPT {return __value_;}
387    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT {return __value_;}
388};
389
390template <size_t _Ip, class _Hp>
391class __tuple_leaf<_Ip, _Hp, true>
392    : private _Hp
393{
394    _LIBCPP_CONSTEXPR_SINCE_CXX14
395    __tuple_leaf& operator=(const __tuple_leaf&);
396public:
397    _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
398             _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
399
400    template <class _Alloc>
401        _LIBCPP_INLINE_VISIBILITY constexpr
402        __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
403
404    template <class _Alloc>
405        _LIBCPP_INLINE_VISIBILITY constexpr
406        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
407            : _Hp(allocator_arg_t(), __a) {}
408
409    template <class _Alloc>
410        _LIBCPP_INLINE_VISIBILITY constexpr
411        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
412            : _Hp(__a) {}
413
414    template <class _Tp,
415              class = __enable_if_t<
416                  _And<
417                    _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>,
418                    is_constructible<_Hp, _Tp>
419                  >::value
420                >
421            >
422        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
423        explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
424            : _Hp(_VSTD::forward<_Tp>(__t)) {}
425
426    template <class _Tp, class _Alloc>
427        _LIBCPP_INLINE_VISIBILITY constexpr
428        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
429            : _Hp(_VSTD::forward<_Tp>(__t)) {}
430
431    template <class _Tp, class _Alloc>
432        _LIBCPP_INLINE_VISIBILITY constexpr
433        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
434            : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
435
436    template <class _Tp, class _Alloc>
437        _LIBCPP_INLINE_VISIBILITY constexpr
438        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
439            : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
440
441    __tuple_leaf(__tuple_leaf const &) = default;
442    __tuple_leaf(__tuple_leaf &&) = default;
443
444    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
445    int
446    swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
447    {
448        _VSTD::swap(*this, __t);
449        return 0;
450    }
451
452    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
453    int swap(const __tuple_leaf& __rhs) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
454        _VSTD::swap(*this, __rhs);
455        return 0;
456    }
457
458    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14       _Hp& get()       _NOEXCEPT {return static_cast<_Hp&>(*this);}
459    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
460};
461
462template <class ..._Tp>
463_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
464void __swallow(_Tp&&...) _NOEXCEPT {}
465
466template <class _Tp>
467struct __all_default_constructible;
468
469template <class ..._Tp>
470struct __all_default_constructible<__tuple_types<_Tp...>>
471    : __all<is_default_constructible<_Tp>::value...>
472{ };
473
474// __tuple_impl
475
476template<class _Indx, class ..._Tp> struct __tuple_impl;
477
478template<size_t ..._Indx, class ..._Tp>
479struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
480    : public __tuple_leaf<_Indx, _Tp>...
481{
482    _LIBCPP_INLINE_VISIBILITY
483    constexpr __tuple_impl()
484        _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
485
486    template <size_t ..._Uf, class ..._Tf,
487              size_t ..._Ul, class ..._Tl, class ..._Up>
488        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
489        explicit
490        __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
491                     __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
492                     _Up&&... __u)
493                     _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
494                                 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
495            __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
496            __tuple_leaf<_Ul, _Tl>()...
497            {}
498
499    template <class _Alloc, size_t ..._Uf, class ..._Tf,
500              size_t ..._Ul, class ..._Tl, class ..._Up>
501        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
502        explicit
503        __tuple_impl(allocator_arg_t, const _Alloc& __a,
504                     __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
505                     __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
506                     _Up&&... __u) :
507            __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
508            _VSTD::forward<_Up>(__u))...,
509            __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
510            {}
511
512    template <class _Tuple,
513              class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
514             >
515        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
516        __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
517                                       typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
518            : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
519                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
520            {}
521
522    template <class _Alloc, class _Tuple,
523              class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
524             >
525        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
526        __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
527            : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
528                                       typename __make_tuple_types<_Tuple>::type>::type>(), __a,
529                                       _VSTD::forward<typename tuple_element<_Indx,
530                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
531            {}
532
533    __tuple_impl(const __tuple_impl&) = default;
534    __tuple_impl(__tuple_impl&&) = default;
535
536    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
537    void swap(__tuple_impl& __t)
538        _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
539    {
540        _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
541    }
542
543    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
544    void swap(const __tuple_impl& __t) const
545        _NOEXCEPT_(__all<__is_nothrow_swappable<const _Tp>::value...>::value)
546    {
547        _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t))...);
548    }
549};
550
551template<class _Dest, class _Source, size_t ..._Np>
552_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
553void __memberwise_copy_assign(_Dest& __dest, _Source const& __source, __tuple_indices<_Np...>) {
554    _VSTD::__swallow(((_VSTD::get<_Np>(__dest) = _VSTD::get<_Np>(__source)), void(), 0)...);
555}
556
557template<class _Dest, class _Source, class ..._Up, size_t ..._Np>
558_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
559void __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up...>, __tuple_indices<_Np...>) {
560    _VSTD::__swallow(((
561        _VSTD::get<_Np>(__dest) = _VSTD::forward<_Up>(_VSTD::get<_Np>(__source))
562    ), void(), 0)...);
563}
564
565template <class ..._Tp>
566class _LIBCPP_TEMPLATE_VIS tuple
567{
568    typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
569
570    _BaseT __base_;
571
572    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
573        typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
574    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
575        const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
576    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
577        typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
578    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
579        const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
580public:
581    // [tuple.cnstr]
582
583    // tuple() constructors (including allocator_arg_t variants)
584    template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible, __enable_if_t<
585        _And<
586            _IsImpDefault<_Tp>... // explicit check
587        >::value
588    , int> = 0>
589    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
590    tuple()
591        _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value)
592    { }
593
594    template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible,
595              template<class...> class _IsDefault = is_default_constructible, __enable_if_t<
596        _And<
597            _IsDefault<_Tp>...,
598            _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check
599        >::value
600    , int> = 0>
601    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
602    explicit tuple()
603        _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value)
604    { }
605
606    template <class _Alloc, template<class...> class _IsImpDefault = __is_implicitly_default_constructible, __enable_if_t<
607        _And<
608            _IsImpDefault<_Tp>... // explicit check
609        >::value
610    , int> = 0>
611    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
612    tuple(allocator_arg_t, _Alloc const& __a)
613      : __base_(allocator_arg_t(), __a,
614                    __tuple_indices<>(), __tuple_types<>(),
615                    typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
616                    __tuple_types<_Tp...>()) {}
617
618    template <class _Alloc,
619              template<class...> class _IsImpDefault = __is_implicitly_default_constructible,
620              template<class...> class _IsDefault = is_default_constructible, __enable_if_t<
621        _And<
622            _IsDefault<_Tp>...,
623            _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check
624        >::value
625    , int> = 0>
626    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
627    explicit tuple(allocator_arg_t, _Alloc const& __a)
628      : __base_(allocator_arg_t(), __a,
629                    __tuple_indices<>(), __tuple_types<>(),
630                    typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
631                    __tuple_types<_Tp...>()) {}
632
633    // tuple(const T&...) constructors (including allocator_arg_t variants)
634    template <template<class...> class _And = _And, __enable_if_t<
635        _And<
636            _BoolConstant<sizeof...(_Tp) >= 1>,
637            is_copy_constructible<_Tp>...,
638            is_convertible<const _Tp&, _Tp>... // explicit check
639        >::value
640    , int> = 0>
641    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
642    tuple(const _Tp& ... __t)
643        _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
644        : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
645                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
646                typename __make_tuple_indices<0>::type(),
647                typename __make_tuple_types<tuple, 0>::type(),
648                __t...
649               ) {}
650
651    template <template<class...> class _And = _And, __enable_if_t<
652        _And<
653            _BoolConstant<sizeof...(_Tp) >= 1>,
654            is_copy_constructible<_Tp>...,
655            _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check
656        >::value
657    , int> = 0>
658    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
659    explicit tuple(const _Tp& ... __t)
660        _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
661        : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
662                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
663                typename __make_tuple_indices<0>::type(),
664                typename __make_tuple_types<tuple, 0>::type(),
665                __t...
666               ) {}
667
668    template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
669        _And<
670            _BoolConstant<sizeof...(_Tp) >= 1>,
671            is_copy_constructible<_Tp>...,
672            is_convertible<const _Tp&, _Tp>... // explicit check
673        >::value
674    , int> = 0>
675    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
676    tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
677        : __base_(allocator_arg_t(), __a,
678                typename __make_tuple_indices<sizeof...(_Tp)>::type(),
679                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
680                typename __make_tuple_indices<0>::type(),
681                typename __make_tuple_types<tuple, 0>::type(),
682                __t...
683               ) {}
684
685    template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
686        _And<
687            _BoolConstant<sizeof...(_Tp) >= 1>,
688            is_copy_constructible<_Tp>...,
689            _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check
690        >::value
691    , int> = 0>
692    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
693    explicit tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
694        : __base_(allocator_arg_t(), __a,
695                typename __make_tuple_indices<sizeof...(_Tp)>::type(),
696                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
697                typename __make_tuple_indices<0>::type(),
698                typename __make_tuple_types<tuple, 0>::type(),
699                __t...
700               ) {}
701
702    // tuple(U&& ...) constructors (including allocator_arg_t variants)
703    template <class ..._Up> struct _IsThisTuple : false_type { };
704    template <class _Up> struct _IsThisTuple<_Up> : is_same<__remove_cvref_t<_Up>, tuple> { };
705
706    template <class ..._Up>
707    struct _EnableUTypesCtor : _And<
708        _BoolConstant<sizeof...(_Tp) >= 1>,
709        _Not<_IsThisTuple<_Up...> >, // extension to allow mis-behaved user constructors
710        is_constructible<_Tp, _Up>...
711    > { };
712
713    template <class ..._Up, __enable_if_t<
714        _And<
715            _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
716            _EnableUTypesCtor<_Up...>,
717            is_convertible<_Up, _Tp>... // explicit check
718        >::value
719    , int> = 0>
720    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
721    tuple(_Up&&... __u)
722        _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
723        : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
724                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
725                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
726                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
727                    _VSTD::forward<_Up>(__u)...) {}
728
729    template <class ..._Up, __enable_if_t<
730        _And<
731            _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
732            _EnableUTypesCtor<_Up...>,
733            _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
734        >::value
735    , int> = 0>
736    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
737    explicit tuple(_Up&&... __u)
738        _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
739        : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
740                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
741                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
742                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
743                    _VSTD::forward<_Up>(__u)...) {}
744
745    template <class _Alloc, class ..._Up, __enable_if_t<
746        _And<
747            _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
748            _EnableUTypesCtor<_Up...>,
749            is_convertible<_Up, _Tp>... // explicit check
750        >::value
751    , int> = 0>
752    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
753    tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
754        : __base_(allocator_arg_t(), __a,
755                    typename __make_tuple_indices<sizeof...(_Up)>::type(),
756                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
757                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
758                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
759                    _VSTD::forward<_Up>(__u)...) {}
760
761    template <class _Alloc, class ..._Up, __enable_if_t<
762        _And<
763            _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
764            _EnableUTypesCtor<_Up...>,
765            _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
766        >::value
767    , int> = 0>
768    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
769    explicit tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
770        : __base_(allocator_arg_t(), __a,
771                    typename __make_tuple_indices<sizeof...(_Up)>::type(),
772                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
773                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
774                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
775                    _VSTD::forward<_Up>(__u)...) {}
776
777    // Copy and move constructors (including the allocator_arg_t variants)
778    tuple(const tuple&) = default;
779    tuple(tuple&&) = default;
780
781    template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
782        _And<is_copy_constructible<_Tp>...>::value
783    , int> = 0>
784    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
785    tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)
786        : __base_(allocator_arg_t(), __alloc, __t)
787    { }
788
789    template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
790        _And<is_move_constructible<_Tp>...>::value
791    , int> = 0>
792    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
793    tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)
794        : __base_(allocator_arg_t(), __alloc, _VSTD::move(__t))
795    { }
796
797    // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants)
798
799    template <class _OtherTuple, class _DecayedOtherTuple = __remove_cvref_t<_OtherTuple>, class = void>
800    struct _EnableCtorFromUTypesTuple : false_type {};
801
802    template <class _OtherTuple, class... _Up>
803    struct _EnableCtorFromUTypesTuple<_OtherTuple, tuple<_Up...>,
804              // the length of the packs needs to checked first otherwise the 2 packs cannot be expanded simultaneously below
805               __enable_if_t<sizeof...(_Up) == sizeof...(_Tp)>> : _And<
806        // the two conditions below are not in spec. The purpose is to disable the UTypes Ctor when copy/move Ctor can work.
807        // Otherwise, is_constructible can trigger hard error in those cases https://godbolt.org/z/M94cGdKcE
808        _Not<is_same<_OtherTuple, const tuple&> >,
809        _Not<is_same<_OtherTuple, tuple&&> >,
810        is_constructible<_Tp, __copy_cvref_t<_OtherTuple, _Up> >...,
811        _Lazy<_Or, _BoolConstant<sizeof...(_Tp) != 1>,
812            // _Tp and _Up are 1-element packs - the pack expansions look
813            // weird to avoid tripping up the type traits in degenerate cases
814            _Lazy<_And,
815                _Not<is_same<_Tp, _Up> >...,
816                _Not<is_convertible<_OtherTuple, _Tp> >...,
817                _Not<is_constructible<_Tp, _OtherTuple> >...
818            >
819        >
820    > {};
821
822    template <class ..._Up, __enable_if_t<
823        _And<
824            _EnableCtorFromUTypesTuple<const tuple<_Up...>&>,
825            is_convertible<const _Up&, _Tp>... // explicit check
826        >::value
827    , int> = 0>
828    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
829    tuple(const tuple<_Up...>& __t)
830        _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
831        : __base_(__t)
832    { }
833
834    template <class ..._Up, __enable_if_t<
835        _And<
836            _EnableCtorFromUTypesTuple<const tuple<_Up...>&>,
837            _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
838        >::value
839    , int> = 0>
840    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
841    explicit tuple(const tuple<_Up...>& __t)
842        _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
843        : __base_(__t)
844    { }
845
846    template <class ..._Up, class _Alloc, __enable_if_t<
847        _And<
848            _EnableCtorFromUTypesTuple<const tuple<_Up...>&>,
849            is_convertible<const _Up&, _Tp>... // explicit check
850        >::value
851    , int> = 0>
852    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
853    tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
854        : __base_(allocator_arg_t(), __a, __t)
855    { }
856
857    template <class ..._Up, class _Alloc, __enable_if_t<
858        _And<
859            _EnableCtorFromUTypesTuple<const tuple<_Up...>&>,
860            _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
861        >::value
862    , int> = 0>
863    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
864    explicit tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
865        : __base_(allocator_arg_t(), __a, __t)
866    { }
867
868#if _LIBCPP_STD_VER >= 23
869    // tuple(tuple<U...>&) constructors (including allocator_arg_t variants)
870
871    template <class... _Up, enable_if_t<
872        _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
873    _LIBCPP_HIDE_FROM_ABI constexpr
874        explicit(!(is_convertible_v<_Up&, _Tp> && ...))
875    tuple(tuple<_Up...>& __t) : __base_(__t) {}
876
877    template <class _Alloc, class... _Up, enable_if_t<
878        _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
879    _LIBCPP_HIDE_FROM_ABI constexpr
880        explicit(!(is_convertible_v<_Up&, _Tp> && ...))
881    tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t) : __base_(allocator_arg_t(), __alloc, __t) {}
882#endif // _LIBCPP_STD_VER >= 23
883
884    // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)
885
886    template <class ..._Up, __enable_if_t<
887        _And<
888            _EnableCtorFromUTypesTuple<tuple<_Up...>&&>,
889            is_convertible<_Up, _Tp>... // explicit check
890        >::value
891    , int> = 0>
892    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
893    tuple(tuple<_Up...>&& __t)
894        _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
895        : __base_(_VSTD::move(__t))
896    { }
897
898    template <class ..._Up, __enable_if_t<
899        _And<
900            _EnableCtorFromUTypesTuple<tuple<_Up...>&&>,
901            _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
902        >::value
903    , int> = 0>
904    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
905    explicit tuple(tuple<_Up...>&& __t)
906        _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
907        : __base_(_VSTD::move(__t))
908    { }
909
910    template <class _Alloc, class ..._Up, __enable_if_t<
911        _And<
912            _EnableCtorFromUTypesTuple<tuple<_Up...>&&>,
913            is_convertible<_Up, _Tp>... // explicit check
914        >::value
915    , int> = 0>
916    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
917    tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
918        : __base_(allocator_arg_t(), __a, _VSTD::move(__t))
919    { }
920
921    template <class _Alloc, class ..._Up, __enable_if_t<
922        _And<
923            _EnableCtorFromUTypesTuple<tuple<_Up...>&&>,
924            _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
925        >::value
926    , int> = 0>
927    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
928    explicit tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
929        : __base_(allocator_arg_t(), __a, _VSTD::move(__t))
930    { }
931
932#if _LIBCPP_STD_VER >= 23
933    // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants)
934
935    template <class... _Up, enable_if_t<
936        _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
937    _LIBCPP_HIDE_FROM_ABI constexpr
938        explicit(!(is_convertible_v<const _Up&&, _Tp> && ...))
939    tuple(const tuple<_Up...>&& __t) : __base_(std::move(__t)) {}
940
941    template <class _Alloc, class... _Up, enable_if_t<
942        _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
943    _LIBCPP_HIDE_FROM_ABI constexpr
944        explicit(!(is_convertible_v<const _Up&&, _Tp> && ...))
945    tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t)
946        : __base_(allocator_arg_t(), __alloc, std::move(__t)) {}
947#endif // _LIBCPP_STD_VER >= 23
948
949    // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)
950
951    template <template <class...> class Pred, class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
952    struct _CtorPredicateFromPair : false_type{};
953
954    template <template <class...> class Pred, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
955    struct _CtorPredicateFromPair<Pred, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > : _And<
956        Pred<_Tp1, __copy_cvref_t<_Pair, _Up1> >,
957        Pred<_Tp2, __copy_cvref_t<_Pair, _Up2> >
958    > {};
959
960    template <class _Pair>
961    struct _EnableCtorFromPair : _CtorPredicateFromPair<is_constructible, _Pair>{};
962
963    template <class _Pair>
964    struct _NothrowConstructibleFromPair : _CtorPredicateFromPair<is_nothrow_constructible, _Pair>{};
965
966    template <class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
967    struct _BothImplicitlyConvertible : false_type{};
968
969    template <class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
970    struct _BothImplicitlyConvertible<_Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > : _And<
971        is_convertible<__copy_cvref_t<_Pair, _Up1>, _Tp1>,
972        is_convertible<__copy_cvref_t<_Pair, _Up2>, _Tp2>
973    > {};
974
975    template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
976        _And<
977            _EnableCtorFromPair<const pair<_Up1, _Up2>&>,
978            _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check
979        >::value
980    , int> = 0>
981    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
982    tuple(const pair<_Up1, _Up2>& __p)
983        _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
984        : __base_(__p)
985    { }
986
987    template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
988        _And<
989            _EnableCtorFromPair<const pair<_Up1, _Up2>&>,
990            _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check
991        >::value
992    , int> = 0>
993    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
994    explicit tuple(const pair<_Up1, _Up2>& __p)
995        _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
996        : __base_(__p)
997    { }
998
999    template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
1000        _And<
1001            _EnableCtorFromPair<const pair<_Up1, _Up2>&>,
1002            _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check
1003        >::value
1004    , int> = 0>
1005    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1006    tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
1007        : __base_(allocator_arg_t(), __a, __p)
1008    { }
1009
1010    template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
1011        _And<
1012            _EnableCtorFromPair<const pair<_Up1, _Up2>&>,
1013            _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check
1014        >::value
1015    , int> = 0>
1016    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1017    explicit tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
1018        : __base_(allocator_arg_t(), __a, __p)
1019    { }
1020
1021#if _LIBCPP_STD_VER >= 23
1022    // tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants)
1023
1024    template <class _U1, class _U2, enable_if_t<
1025        _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr>
1026    _LIBCPP_HIDE_FROM_ABI constexpr
1027        explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
1028    tuple(pair<_U1, _U2>& __p) : __base_(__p) {}
1029
1030    template <class _Alloc, class _U1, class _U2, enable_if_t<
1031        _EnableCtorFromPair<std::pair<_U1, _U2>&>::value>* = nullptr>
1032    _LIBCPP_HIDE_FROM_ABI constexpr
1033        explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
1034    tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p) : __base_(allocator_arg_t(), __alloc, __p) {}
1035#endif
1036
1037    // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)
1038
1039    template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
1040        _And<
1041            _EnableCtorFromPair<pair<_Up1, _Up2>&&>,
1042            _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check
1043        >::value
1044    , int> = 0>
1045    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1046    tuple(pair<_Up1, _Up2>&& __p)
1047        _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
1048        : __base_(_VSTD::move(__p))
1049    { }
1050
1051    template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
1052        _And<
1053            _EnableCtorFromPair<pair<_Up1, _Up2>&&>,
1054            _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check
1055        >::value
1056    , int> = 0>
1057    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1058    explicit tuple(pair<_Up1, _Up2>&& __p)
1059        _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
1060        : __base_(_VSTD::move(__p))
1061    { }
1062
1063    template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
1064        _And<
1065            _EnableCtorFromPair<pair<_Up1, _Up2>&&>,
1066            _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check
1067        >::value
1068    , int> = 0>
1069    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1070    tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
1071        : __base_(allocator_arg_t(), __a, _VSTD::move(__p))
1072    { }
1073
1074    template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t<
1075        _And<
1076            _EnableCtorFromPair<pair<_Up1, _Up2>&&>,
1077            _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check
1078        >::value
1079    , int> = 0>
1080    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1081    explicit tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
1082        : __base_(allocator_arg_t(), __a, _VSTD::move(__p))
1083    { }
1084
1085#if _LIBCPP_STD_VER >= 23
1086    // tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants)
1087
1088    template <class _U1, class _U2, enable_if_t<
1089        _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
1090    _LIBCPP_HIDE_FROM_ABI constexpr
1091        explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
1092    tuple(const pair<_U1, _U2>&& __p) : __base_(std::move(__p)) {}
1093
1094    template <class _Alloc, class _U1, class _U2, enable_if_t<
1095        _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
1096    _LIBCPP_HIDE_FROM_ABI constexpr
1097        explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
1098    tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p)
1099        : __base_(allocator_arg_t(), __alloc, std::move(__p)) {}
1100#endif // _LIBCPP_STD_VER >= 23
1101
1102    // [tuple.assign]
1103    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1104    tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)
1105        _NOEXCEPT_((_And<is_nothrow_copy_assignable<_Tp>...>::value))
1106    {
1107        _VSTD::__memberwise_copy_assign(*this, __tuple,
1108            typename __make_tuple_indices<sizeof...(_Tp)>::type());
1109        return *this;
1110    }
1111
1112#if _LIBCPP_STD_VER >= 23
1113    _LIBCPP_HIDE_FROM_ABI constexpr
1114    const tuple& operator=(tuple const& __tuple) const
1115      requires (_And<is_copy_assignable<const _Tp>...>::value) {
1116        std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
1117        return *this;
1118    }
1119
1120    _LIBCPP_HIDE_FROM_ABI constexpr
1121    const tuple& operator=(tuple&& __tuple) const
1122      requires (_And<is_assignable<const _Tp&, _Tp>...>::value) {
1123        std::__memberwise_forward_assign(*this,
1124                                         std::move(__tuple),
1125                                         __tuple_types<_Tp...>(),
1126                                         typename __make_tuple_indices<sizeof...(_Tp)>::type());
1127        return *this;
1128    }
1129#endif // _LIBCPP_STD_VER >= 23
1130
1131    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1132    tuple& operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)
1133        _NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value))
1134    {
1135        _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__tuple),
1136            __tuple_types<_Tp...>(),
1137            typename __make_tuple_indices<sizeof...(_Tp)>::type());
1138        return *this;
1139    }
1140
1141    template<class... _Up, __enable_if_t<
1142        _And<
1143            _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>,
1144            is_assignable<_Tp&, _Up const&>...
1145        >::value
1146    ,int> = 0>
1147    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1148    tuple& operator=(tuple<_Up...> const& __tuple)
1149        _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
1150    {
1151        _VSTD::__memberwise_copy_assign(*this, __tuple,
1152            typename __make_tuple_indices<sizeof...(_Tp)>::type());
1153        return *this;
1154    }
1155
1156    template<class... _Up, __enable_if_t<
1157        _And<
1158            _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>,
1159            is_assignable<_Tp&, _Up>...
1160        >::value
1161    ,int> = 0>
1162    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1163    tuple& operator=(tuple<_Up...>&& __tuple)
1164        _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
1165    {
1166        _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__tuple),
1167            __tuple_types<_Up...>(),
1168            typename __make_tuple_indices<sizeof...(_Tp)>::type());
1169        return *this;
1170    }
1171
1172
1173#if _LIBCPP_STD_VER >= 23
1174    template <class... _UTypes, enable_if_t<
1175        _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
1176             is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr>
1177    _LIBCPP_HIDE_FROM_ABI constexpr
1178    const tuple& operator=(const tuple<_UTypes...>& __u) const {
1179        std::__memberwise_copy_assign(*this,
1180                                      __u,
1181                                      typename __make_tuple_indices<sizeof...(_Tp)>::type());
1182        return *this;
1183    }
1184
1185    template <class... _UTypes, enable_if_t<
1186        _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
1187             is_assignable<const _Tp&, _UTypes>...>::value>* = nullptr>
1188    _LIBCPP_HIDE_FROM_ABI constexpr
1189    const tuple& operator=(tuple<_UTypes...>&& __u) const {
1190        std::__memberwise_forward_assign(*this,
1191                                         __u,
1192                                         __tuple_types<_UTypes...>(),
1193                                         typename __make_tuple_indices<sizeof...(_Tp)>::type());
1194        return *this;
1195    }
1196#endif // _LIBCPP_STD_VER >= 23
1197
1198    template <template<class...> class Pred, bool _Const,
1199              class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
1200    struct _AssignPredicateFromPair : false_type {};
1201
1202    template <template<class...> class Pred, bool _Const,
1203              class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
1204    struct _AssignPredicateFromPair<Pred, _Const, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > :
1205        _And<Pred<__maybe_const<_Const, _Tp1>&, __copy_cvref_t<_Pair, _Up1> >,
1206             Pred<__maybe_const<_Const, _Tp2>&, __copy_cvref_t<_Pair, _Up2> >
1207            > {};
1208
1209    template <bool _Const, class _Pair>
1210    struct _EnableAssignFromPair : _AssignPredicateFromPair<is_assignable, _Const, _Pair> {};
1211
1212    template <bool _Const, class _Pair>
1213    struct _NothrowAssignFromPair : _AssignPredicateFromPair<is_nothrow_assignable, _Const, _Pair> {};
1214
1215#if _LIBCPP_STD_VER >= 23
1216    template <class _U1, class _U2, enable_if_t<
1217        _EnableAssignFromPair<true, const pair<_U1, _U2>&>::value>* = nullptr>
1218    _LIBCPP_HIDE_FROM_ABI constexpr
1219    const tuple& operator=(const pair<_U1, _U2>& __pair) const
1220      noexcept(_NothrowAssignFromPair<true, const pair<_U1, _U2>&>::value) {
1221        std::get<0>(*this) = __pair.first;
1222        std::get<1>(*this) = __pair.second;
1223        return *this;
1224    }
1225
1226    template <class _U1, class _U2, enable_if_t<
1227        _EnableAssignFromPair<true, pair<_U1, _U2>&&>::value>* = nullptr>
1228    _LIBCPP_HIDE_FROM_ABI constexpr
1229    const tuple& operator=(pair<_U1, _U2>&& __pair) const
1230      noexcept(_NothrowAssignFromPair<true, pair<_U1, _U2>&&>::value) {
1231        std::get<0>(*this) = std::move(__pair.first);
1232        std::get<1>(*this) = std::move(__pair.second);
1233        return *this;
1234    }
1235#endif // _LIBCPP_STD_VER >= 23
1236
1237    template<class _Up1, class _Up2, __enable_if_t<
1238        _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value
1239    ,int> = 0>
1240    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1241    tuple& operator=(pair<_Up1, _Up2> const& __pair)
1242        _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value))
1243    {
1244        _VSTD::get<0>(*this) = __pair.first;
1245        _VSTD::get<1>(*this) = __pair.second;
1246        return *this;
1247    }
1248
1249    template<class _Up1, class _Up2, __enable_if_t<
1250        _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value
1251    ,int> = 0>
1252    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1253    tuple& operator=(pair<_Up1, _Up2>&& __pair)
1254        _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value))
1255    {
1256        _VSTD::get<0>(*this) = _VSTD::forward<_Up1>(__pair.first);
1257        _VSTD::get<1>(*this) = _VSTD::forward<_Up2>(__pair.second);
1258        return *this;
1259    }
1260
1261    // EXTENSION
1262    template<class _Up, size_t _Np, class = __enable_if_t<
1263        _And<
1264            _BoolConstant<_Np == sizeof...(_Tp)>,
1265            is_assignable<_Tp&, _Up const&>...
1266        >::value
1267    > >
1268    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1269    tuple& operator=(array<_Up, _Np> const& __array)
1270        _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
1271    {
1272        _VSTD::__memberwise_copy_assign(*this, __array,
1273            typename __make_tuple_indices<sizeof...(_Tp)>::type());
1274        return *this;
1275    }
1276
1277    // EXTENSION
1278    template<class _Up, size_t _Np, class = void, class = __enable_if_t<
1279        _And<
1280            _BoolConstant<_Np == sizeof...(_Tp)>,
1281            is_assignable<_Tp&, _Up>...
1282        >::value
1283    > >
1284    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1285    tuple& operator=(array<_Up, _Np>&& __array)
1286        _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
1287    {
1288        _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__array),
1289            __tuple_types<_If<true, _Up, _Tp>...>(),
1290            typename __make_tuple_indices<sizeof...(_Tp)>::type());
1291        return *this;
1292    }
1293
1294    // [tuple.swap]
1295    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1296    void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
1297        {__base_.swap(__t.__base_);}
1298
1299#if _LIBCPP_STD_VER >= 23
1300    _LIBCPP_HIDE_FROM_ABI constexpr
1301    void swap(const tuple& __t) const noexcept(__all<is_nothrow_swappable_v<const _Tp&>...>::value) {
1302        __base_.swap(__t.__base_);
1303    }
1304#endif // _LIBCPP_STD_VER >= 23
1305};
1306
1307template <>
1308class _LIBCPP_TEMPLATE_VIS tuple<>
1309{
1310public:
1311    constexpr tuple() _NOEXCEPT = default;
1312    template <class _Alloc>
1313    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1314        tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
1315    template <class _Alloc>
1316    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1317        tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
1318    template <class _Up>
1319    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1320        tuple(array<_Up, 0>) _NOEXCEPT {}
1321    template <class _Alloc, class _Up>
1322    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1323        tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
1324    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1325    void swap(tuple&) _NOEXCEPT {}
1326#if _LIBCPP_STD_VER >= 23
1327    _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}
1328#endif
1329};
1330
1331#if _LIBCPP_STD_VER >= 23
1332template <class... _TTypes, class... _UTypes, template<class> class _TQual, template<class> class _UQual>
1333    requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; }
1334struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> {
1335    using type = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>;
1336};
1337
1338template <class... _TTypes, class... _UTypes>
1339    requires requires { typename tuple<common_type_t<_TTypes, _UTypes>...>; }
1340struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {
1341    using type = tuple<common_type_t<_TTypes, _UTypes>...>;
1342};
1343#endif // _LIBCPP_STD_VER >= 23
1344
1345#if _LIBCPP_STD_VER >= 17
1346template <class ..._Tp>
1347tuple(_Tp...) -> tuple<_Tp...>;
1348template <class _Tp1, class _Tp2>
1349tuple(pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
1350template <class _Alloc, class ..._Tp>
1351tuple(allocator_arg_t, _Alloc, _Tp...) -> tuple<_Tp...>;
1352template <class _Alloc, class _Tp1, class _Tp2>
1353tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
1354template <class _Alloc, class ..._Tp>
1355tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
1356#endif
1357
1358template <class ..._Tp>
1359inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1360__enable_if_t<__all<__is_swappable<_Tp>::value...>::value, void>
1361swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
1362                 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
1363    {__t.swap(__u);}
1364
1365#if _LIBCPP_STD_VER >= 23
1366template <class... _Tp>
1367_LIBCPP_HIDE_FROM_ABI constexpr
1368enable_if_t<__all<is_swappable_v<const _Tp>...>::value, void>
1369swap(const tuple<_Tp...>& __lhs, const tuple<_Tp...>& __rhs)
1370        noexcept(__all<is_nothrow_swappable_v<const _Tp>...>::value) {
1371    __lhs.swap(__rhs);
1372}
1373#endif
1374
1375// get
1376
1377template <size_t _Ip, class ..._Tp>
1378inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1379typename tuple_element<_Ip, tuple<_Tp...> >::type&
1380get(tuple<_Tp...>& __t) _NOEXCEPT
1381{
1382    typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
1383    return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
1384}
1385
1386template <size_t _Ip, class ..._Tp>
1387inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1388const typename tuple_element<_Ip, tuple<_Tp...> >::type&
1389get(const tuple<_Tp...>& __t) _NOEXCEPT
1390{
1391    typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
1392    return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
1393}
1394
1395template <size_t _Ip, class ..._Tp>
1396inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1397typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1398get(tuple<_Tp...>&& __t) _NOEXCEPT
1399{
1400    typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
1401    return static_cast<type&&>(
1402             static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
1403}
1404
1405template <size_t _Ip, class ..._Tp>
1406inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1407const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1408get(const tuple<_Tp...>&& __t) _NOEXCEPT
1409{
1410    typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type;
1411    return static_cast<const type&&>(
1412             static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
1413}
1414
1415#if _LIBCPP_STD_VER >= 14
1416
1417namespace __find_detail {
1418
1419static constexpr size_t __not_found = static_cast<size_t>(-1);
1420static constexpr size_t __ambiguous = __not_found - 1;
1421
1422inline _LIBCPP_INLINE_VISIBILITY
1423constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
1424    return !__matches ? __res :
1425        (__res == __not_found ? __curr_i : __ambiguous);
1426}
1427
1428template <size_t _Nx>
1429inline _LIBCPP_INLINE_VISIBILITY
1430constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
1431  return __i == _Nx ? __not_found :
1432      __find_detail::__find_idx_return(__i, __find_detail::__find_idx(__i + 1, __matches), __matches[__i]);
1433}
1434
1435template <class _T1, class ..._Args>
1436struct __find_exactly_one_checked {
1437    static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
1438    static constexpr size_t value = __find_detail::__find_idx(0, __matches);
1439    static_assert(value != __not_found, "type not found in type list" );
1440    static_assert(value != __ambiguous, "type occurs more than once in type list");
1441};
1442
1443template <class _T1>
1444struct __find_exactly_one_checked<_T1> {
1445    static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
1446};
1447
1448} // namespace __find_detail
1449
1450template <typename _T1, typename... _Args>
1451struct __find_exactly_one_t
1452    : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
1453};
1454
1455template <class _T1, class... _Args>
1456inline _LIBCPP_INLINE_VISIBILITY
1457constexpr _T1& get(tuple<_Args...>& __tup) noexcept
1458{
1459    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1460}
1461
1462template <class _T1, class... _Args>
1463inline _LIBCPP_INLINE_VISIBILITY
1464constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
1465{
1466    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1467}
1468
1469template <class _T1, class... _Args>
1470inline _LIBCPP_INLINE_VISIBILITY
1471constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
1472{
1473    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1474}
1475
1476template <class _T1, class... _Args>
1477inline _LIBCPP_INLINE_VISIBILITY
1478constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
1479{
1480    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1481}
1482
1483#endif
1484
1485// tie
1486
1487template <class ..._Tp>
1488inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1489tuple<_Tp&...>
1490tie(_Tp&... __t) _NOEXCEPT
1491{
1492    return tuple<_Tp&...>(__t...);
1493}
1494
1495template <class _Up>
1496struct __ignore_t
1497{
1498    template <class _Tp>
1499    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1500    const __ignore_t& operator=(_Tp&&) const {return *this;}
1501};
1502
1503namespace {
1504  constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
1505} // namespace
1506
1507template <class... _Tp>
1508inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1509tuple<typename __unwrap_ref_decay<_Tp>::type...>
1510make_tuple(_Tp&&... __t)
1511{
1512    return tuple<typename __unwrap_ref_decay<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
1513}
1514
1515template <class... _Tp>
1516inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1517tuple<_Tp&&...>
1518forward_as_tuple(_Tp&&... __t) _NOEXCEPT
1519{
1520    return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
1521}
1522
1523template <size_t _Ip>
1524struct __tuple_equal
1525{
1526    template <class _Tp, class _Up>
1527    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1528    bool operator()(const _Tp& __x, const _Up& __y)
1529    {
1530        return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
1531    }
1532};
1533
1534template <>
1535struct __tuple_equal<0>
1536{
1537    template <class _Tp, class _Up>
1538    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1539    bool operator()(const _Tp&, const _Up&)
1540    {
1541        return true;
1542    }
1543};
1544
1545template <class ..._Tp, class ..._Up>
1546inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1547bool
1548operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1549{
1550    static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
1551    return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
1552}
1553
1554#if _LIBCPP_STD_VER >= 20
1555
1556// operator<=>
1557
1558template <class ..._Tp, class ..._Up, size_t ..._Is>
1559_LIBCPP_HIDE_FROM_ABI constexpr
1560auto
1561__tuple_compare_three_way(const tuple<_Tp...>& __x, const tuple<_Up...>& __y, index_sequence<_Is...>) {
1562    common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> __result = strong_ordering::equal;
1563    static_cast<void>(((__result = _VSTD::__synth_three_way(_VSTD::get<_Is>(__x), _VSTD::get<_Is>(__y)), __result != 0) || ...));
1564    return __result;
1565}
1566
1567template <class ..._Tp, class ..._Up>
1568requires (sizeof...(_Tp) == sizeof...(_Up))
1569_LIBCPP_HIDE_FROM_ABI constexpr
1570common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...>
1571operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1572{
1573    return _VSTD::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{});
1574}
1575
1576#else // _LIBCPP_STD_VER >= 20
1577
1578template <class ..._Tp, class ..._Up>
1579inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1580bool
1581operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1582{
1583    return !(__x == __y);
1584}
1585
1586template <size_t _Ip>
1587struct __tuple_less
1588{
1589    template <class _Tp, class _Up>
1590    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1591    bool operator()(const _Tp& __x, const _Up& __y)
1592    {
1593        const size_t __idx = tuple_size<_Tp>::value - _Ip;
1594        if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
1595            return true;
1596        if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
1597            return false;
1598        return __tuple_less<_Ip-1>()(__x, __y);
1599    }
1600};
1601
1602template <>
1603struct __tuple_less<0>
1604{
1605    template <class _Tp, class _Up>
1606    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1607    bool operator()(const _Tp&, const _Up&)
1608    {
1609        return false;
1610    }
1611};
1612
1613template <class ..._Tp, class ..._Up>
1614inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1615bool
1616operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1617{
1618    static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
1619    return __tuple_less<sizeof...(_Tp)>()(__x, __y);
1620}
1621
1622template <class ..._Tp, class ..._Up>
1623inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1624bool
1625operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1626{
1627    return __y < __x;
1628}
1629
1630template <class ..._Tp, class ..._Up>
1631inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1632bool
1633operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1634{
1635    return !(__x < __y);
1636}
1637
1638template <class ..._Tp, class ..._Up>
1639inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1640bool
1641operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1642{
1643    return !(__y < __x);
1644}
1645
1646#endif // _LIBCPP_STD_VER >= 20
1647
1648// tuple_cat
1649
1650template <class _Tp, class _Up> struct __tuple_cat_type;
1651
1652template <class ..._Ttypes, class ..._Utypes>
1653struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
1654{
1655    typedef _LIBCPP_NODEBUG tuple<_Ttypes..., _Utypes...> type;
1656};
1657
1658template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
1659struct __tuple_cat_return_1
1660{
1661};
1662
1663template <class ..._Types, class _Tuple0>
1664struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
1665{
1666  using type _LIBCPP_NODEBUG = typename __tuple_cat_type<
1667      tuple<_Types...>,
1668      typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type
1669    >::type;
1670};
1671
1672template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
1673struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
1674    : public __tuple_cat_return_1<
1675                 typename __tuple_cat_type<
1676                     tuple<_Types...>,
1677                     typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type
1678                 >::type,
1679                 __tuple_like_ext<__libcpp_remove_reference_t<_Tuple1> >::value,
1680                 _Tuple1, _Tuples...>
1681{
1682};
1683
1684template <class ..._Tuples> struct __tuple_cat_return;
1685
1686template <class _Tuple0, class ..._Tuples>
1687struct __tuple_cat_return<_Tuple0, _Tuples...>
1688    : public __tuple_cat_return_1<tuple<>,
1689         __tuple_like_ext<__libcpp_remove_reference_t<_Tuple0> >::value, _Tuple0,
1690                                                                     _Tuples...>
1691{
1692};
1693
1694template <>
1695struct __tuple_cat_return<>
1696{
1697    typedef _LIBCPP_NODEBUG tuple<> type;
1698};
1699
1700inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1701tuple<>
1702tuple_cat()
1703{
1704    return tuple<>();
1705}
1706
1707template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
1708struct __tuple_cat_return_ref_imp;
1709
1710template <class ..._Types, size_t ..._I0, class _Tuple0>
1711struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
1712{
1713    typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
1714    typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1715                          typename tuple_element<_I0, _T0>::type>::type&&...> type;
1716};
1717
1718template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1719struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1720                                  _Tuple0, _Tuple1, _Tuples...>
1721    : public __tuple_cat_return_ref_imp<
1722         tuple<_Types..., typename __apply_cv<_Tuple0,
1723               typename tuple_element<_I0,
1724                  __libcpp_remove_reference_t<_Tuple0> >::type>::type&&...>,
1725         typename __make_tuple_indices<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>::type,
1726         _Tuple1, _Tuples...>
1727{
1728};
1729
1730template <class _Tuple0, class ..._Tuples>
1731struct __tuple_cat_return_ref
1732    : public __tuple_cat_return_ref_imp<tuple<>,
1733               typename __make_tuple_indices<
1734                        tuple_size<__libcpp_remove_reference_t<_Tuple0> >::value
1735               >::type, _Tuple0, _Tuples...>
1736{
1737};
1738
1739template <class _Types, class _I0, class _J0>
1740struct __tuple_cat;
1741
1742template <class ..._Types, size_t ..._I0, size_t ..._J0>
1743struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
1744{
1745    template <class _Tuple0>
1746    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1747    typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1748    operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1749    {
1750        (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1751        return _VSTD::forward_as_tuple(
1752            _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1753            _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
1754    }
1755
1756    template <class _Tuple0, class _Tuple1, class ..._Tuples>
1757    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1758    typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1759    operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1760    {
1761        (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1762        typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
1763        typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple1> _T1;
1764        return __tuple_cat<
1765            tuple<_Types...,
1766                  typename __apply_cv<_Tuple0, typename tuple_element<
1767                                                   _J0, _T0>::type>::type&&...>,
1768            typename __make_tuple_indices<sizeof...(_Types) +
1769                                          tuple_size<_T0>::value>::type,
1770            typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
1771            _VSTD::forward_as_tuple(
1772                _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1773                _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...),
1774            _VSTD::forward<_Tuple1>(__t1), _VSTD::forward<_Tuples>(__tpls)...);
1775    }
1776};
1777
1778template <class _Tuple0, class... _Tuples>
1779inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1780typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1781tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1782{
1783    typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
1784    return __tuple_cat<tuple<>, __tuple_indices<>,
1785                  typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
1786                  (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1787                                            _VSTD::forward<_Tuples>(__tpls)...);
1788}
1789
1790template <class ..._Tp, class _Alloc>
1791struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
1792    : true_type {};
1793
1794template <class _T1, class _T2>
1795template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1796inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1797pair<_T1, _T2>::pair(piecewise_construct_t,
1798                     tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1799                     __tuple_indices<_I1...>, __tuple_indices<_I2...>)
1800    :  first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
1801      second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
1802{
1803}
1804
1805#if _LIBCPP_STD_VER >= 17
1806template <class _Tp>
1807inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
1808
1809#define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
1810
1811template <class _Fn, class _Tuple, size_t ..._Id>
1812inline _LIBCPP_INLINE_VISIBILITY
1813constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
1814                                            __tuple_indices<_Id...>)
1815_LIBCPP_NOEXCEPT_RETURN(
1816    _VSTD::__invoke(
1817        _VSTD::forward<_Fn>(__f),
1818        _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
1819)
1820
1821template <class _Fn, class _Tuple>
1822inline _LIBCPP_INLINE_VISIBILITY
1823constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
1824_LIBCPP_NOEXCEPT_RETURN(
1825    _VSTD::__apply_tuple_impl(
1826        _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
1827        typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
1828)
1829
1830template <class _Tp, class _Tuple, size_t... _Idx>
1831inline _LIBCPP_INLINE_VISIBILITY
1832constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
1833_LIBCPP_NOEXCEPT_RETURN(
1834    _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...)
1835)
1836
1837template <class _Tp, class _Tuple>
1838inline _LIBCPP_INLINE_VISIBILITY
1839constexpr _Tp make_from_tuple(_Tuple&& __t)
1840_LIBCPP_NOEXCEPT_RETURN(
1841    _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
1842        typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
1843)
1844
1845#undef _LIBCPP_NOEXCEPT_RETURN
1846
1847#endif // _LIBCPP_STD_VER >= 17
1848
1849#endif // !defined(_LIBCPP_CXX03_LANG)
1850
1851_LIBCPP_END_NAMESPACE_STD
1852
1853#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1854#  include <exception>
1855#  include <iosfwd>
1856#  include <new>
1857#  include <type_traits>
1858#  include <typeinfo>
1859#  include <utility>
1860#endif
1861
1862#endif // _LIBCPP_TUPLE
1863