Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/c++/v1/tuple is written in an unsupported language. File is not indexed.

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP_TUPLE
0011 #define _LIBCPP_TUPLE
0012 
0013 // clang-format off
0014 
0015 /*
0016     tuple synopsis
0017 
0018 namespace std
0019 {
0020 
0021 template <class... T>
0022 class tuple {
0023 public:
0024     explicit(see-below) constexpr tuple();
0025     explicit(see-below) tuple(const T&...);  // constexpr in C++14
0026     template <class... U>
0027         explicit(see-below) tuple(U&&...);  // constexpr in C++14
0028     tuple(const tuple&) = default;
0029     tuple(tuple&&) = default;
0030 
0031     template<class... UTypes>
0032         constexpr explicit(see-below) tuple(tuple<UTypes...>&);  // C++23
0033     template <class... U>
0034         explicit(see-below) tuple(const tuple<U...>&);  // constexpr in C++14
0035     template <class... U>
0036         explicit(see-below) tuple(tuple<U...>&&);  // constexpr in C++14
0037     template<class... UTypes>
0038         constexpr explicit(see-below) tuple(const tuple<UTypes...>&&); // C++23
0039 
0040     template<class U1, class U2>
0041         constexpr explicit(see-below) tuple(pair<U1, U2>&);  // iff sizeof...(Types) == 2 // C++23
0042     template <class U1, class U2>
0043         explicit(see-below) tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
0044     template <class U1, class U2>
0045         explicit(see-below) tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2  // constexpr in C++14
0046     template<class U1, class U2>
0047         constexpr explicit(see-below) tuple(const pair<U1, U2>&&);  // iff sizeof...(Types) == 2 // C++23
0048 
0049     // allocator-extended constructors
0050     template <class Alloc>
0051         tuple(allocator_arg_t, const Alloc& a);
0052     template <class Alloc>
0053         explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const T&...);          // constexpr in C++20
0054     template <class Alloc, class... U>
0055         explicit(see-below) tuple(allocator_arg_t, const Alloc& a, U&&...);               // constexpr in C++20
0056     template <class Alloc>
0057         tuple(allocator_arg_t, const Alloc& a, const tuple&);                             // constexpr in C++20
0058     template <class Alloc>
0059         tuple(allocator_arg_t, const Alloc& a, tuple&&);                                  // constexpr in C++20
0060     template<class Alloc, class... UTypes>
0061         constexpr explicit(see-below)
0062           tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&);                      // C++23
0063     template <class Alloc, class... U>
0064         explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);   // constexpr in C++20
0065     template <class Alloc, class... U>
0066         explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);        // constexpr in C++20
0067     template<class Alloc, class... UTypes>
0068         constexpr explicit(see-below)
0069           tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&&);               // C++23
0070     template<class Alloc, class U1, class U2>
0071         constexpr explicit(see-below)
0072           tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&);                          // C++23
0073     template <class Alloc, class U1, class U2>
0074         explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);  // constexpr in C++20
0075     template <class Alloc, class U1, class U2>
0076         explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);       // constexpr in C++20
0077     template<class Alloc, class U1, class U2>
0078         constexpr explicit(see-below)
0079           tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&&);                   // C++23
0080 
0081     tuple& operator=(const tuple&);                                                       // constexpr in C++20
0082     constexpr const tuple& operator=(const tuple&) const;                                 // C++23
0083     tuple& operator=(tuple&&) noexcept(is_nothrow_move_assignable_v<T> && ...);           // constexpr in C++20
0084     constexpr const tuple& operator=(tuple&&) const;                                      // C++23
0085     template <class... U>
0086         tuple& operator=(const tuple<U...>&);                                             // constexpr in C++20
0087     template<class... UTypes>
0088         constexpr const tuple& operator=(const tuple<UTypes...>&) const;                  // C++23
0089     template <class... U>
0090         tuple& operator=(tuple<U...>&&);                                                  // constexpr in C++20
0091     template<class... UTypes>
0092         constexpr const tuple& operator=(tuple<UTypes...>&&) const;                       // C++23
0093     template <class U1, class U2>
0094         tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2                   // constexpr in C++20
0095     template<class U1, class U2>
0096         constexpr const tuple& operator=(const pair<U1, U2>&) const;   // iff sizeof...(Types) == 2 // C++23
0097     template <class U1, class U2>
0098         tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2                        // constexpr in C++20
0099     template<class U1, class U2>
0100         constexpr const tuple& operator=(pair<U1, U2>&&) const;  // iff sizeof...(Types) == 2 // C++23
0101 
0102     template<class U, size_t N>
0103         tuple& operator=(array<U, N> const&) // iff sizeof...(T) == N, EXTENSION
0104     template<class U, size_t N>
0105         tuple& operator=(array<U, N>&&) // iff sizeof...(T) == N, EXTENSION
0106 
0107     void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));               // constexpr in C++20
0108     constexpr void swap(const tuple&) const noexcept(see-below);                          // C++23
0109 };
0110 
0111 
0112 template<class... TTypes, class... UTypes, template<class> class TQual, template<class> class UQual> // since C++23
0113   requires requires { typename tuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...>; }
0114 struct basic_common_reference<tuple<TTypes...>, tuple<UTypes...>, TQual, UQual> {
0115   using type = tuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...>;
0116 };
0117 
0118 template<class... TTypes, class... UTypes>                                // since C++23
0119   requires requires { typename tuple<common_type_t<TTypes, UTypes>...>; }
0120 struct common_type<tuple<TTypes...>, tuple<UTypes...>> {
0121   using type = tuple<common_type_t<TTypes, UTypes>...>;
0122 };
0123 
0124 template <class ...T>
0125 tuple(T...) -> tuple<T...>;                                         // since C++17
0126 template <class T1, class T2>
0127 tuple(pair<T1, T2>) -> tuple<T1, T2>;                               // since C++17
0128 template <class Alloc, class ...T>
0129 tuple(allocator_arg_t, Alloc, T...) -> tuple<T...>;                 // since C++17
0130 template <class Alloc, class T1, class T2>
0131 tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>;       // since C++17
0132 template <class Alloc, class ...T>
0133 tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>;          // since C++17
0134 
0135 struct ignore-type { // exposition only                             // Since C++26
0136   constexpr const ignore-type&
0137     operator=(const auto &) const noexcept
0138       { return *this; }
0139 };
0140 inline constexpr ignore-type ignore;
0141 
0142 template <class... T> tuple<V...>  make_tuple(T&&...); // constexpr in C++14
0143 template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
0144 template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
0145 template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
0146 
0147 // [tuple.apply], calling a function with a tuple of arguments:
0148 template <class F, class Tuple>
0149   constexpr decltype(auto) apply(F&& f, Tuple&& t) noexcept(see below);  // C++17 noexcept since C++23
0150 template <class T, class Tuple>
0151   constexpr T make_from_tuple(Tuple&& t); // C++17
0152 
0153 // 20.4.1.4, tuple helper classes:
0154 template <class T> struct tuple_size; // undefined
0155 template <class... T> struct tuple_size<tuple<T...>>;
0156 template <class T>
0157  inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
0158 template <size_t I, class T> struct tuple_element; // undefined
0159 template <size_t I, class... T> struct tuple_element<I, tuple<T...>>;
0160 template <size_t I, class T>
0161   using tuple_element_t = typename tuple_element <I, T>::type; // C++14
0162 
0163 // 20.4.1.5, element access:
0164 template <size_t I, class... T>
0165     typename tuple_element<I, tuple<T...>>::type&
0166     get(tuple<T...>&) noexcept; // constexpr in C++14
0167 template <size_t I, class... T>
0168     const typename tuple_element<I, tuple<T...>>::type&
0169     get(const tuple<T...>&) noexcept; // constexpr in C++14
0170 template <size_t I, class... T>
0171     typename tuple_element<I, tuple<T...>>::type&&
0172     get(tuple<T...>&&) noexcept; // constexpr in C++14
0173 template <size_t I, class... T>
0174     const typename tuple_element<I, tuple<T...>>::type&&
0175     get(const tuple<T...>&&) noexcept; // constexpr in C++14
0176 
0177 template <class T1, class... T>
0178     constexpr T1& get(tuple<T...>&) noexcept;  // C++14
0179 template <class T1, class... T>
0180     constexpr const T1& get(const tuple<T...>&) noexcept;   // C++14
0181 template <class T1, class... T>
0182     constexpr T1&& get(tuple<T...>&&) noexcept;   // C++14
0183 template <class T1, class... T>
0184     constexpr const T1&& get(const tuple<T...>&&) noexcept;   // C++14
0185 
0186 // 20.4.1.6, relational operators:
0187 template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
0188 template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&);  // constexpr in C++14, removed in C++20
0189 template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
0190 template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&);  // constexpr in C++14, removed in C++20
0191 template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
0192 template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20
0193 template<class... T, class... U>
0194   constexpr common_comparison_category_t<synth-three-way-result<T, U>...>
0195     operator<=>(const tuple<T...>&, const tuple<U...>&);                                  // since C++20
0196 
0197 template <class... Types, class Alloc>
0198   struct uses_allocator<tuple<Types...>, Alloc>;
0199 
0200 template <class... Types>
0201   void
0202   swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
0203 
0204 template <class... Types>
0205   constexpr void swap(const tuple<Types...>& x, const tuple<Types...>& y) noexcept(see-below);   // C++23
0206 
0207 }  // std
0208 
0209 */
0210 
0211 // clang-format on
0212 
0213 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0214 #  include <__cxx03/tuple>
0215 #else
0216 #  include <__compare/common_comparison_category.h>
0217 #  include <__compare/ordering.h>
0218 #  include <__compare/synth_three_way.h>
0219 #  include <__config>
0220 #  include <__cstddef/size_t.h>
0221 #  include <__fwd/array.h>
0222 #  include <__fwd/pair.h>
0223 #  include <__fwd/tuple.h>
0224 #  include <__memory/allocator_arg_t.h>
0225 #  include <__memory/uses_allocator.h>
0226 #  include <__tuple/find_index.h>
0227 #  include <__tuple/ignore.h>
0228 #  include <__tuple/make_tuple_types.h>
0229 #  include <__tuple/sfinae_helpers.h>
0230 #  include <__tuple/tuple_element.h>
0231 #  include <__tuple/tuple_indices.h>
0232 #  include <__tuple/tuple_like_ext.h>
0233 #  include <__tuple/tuple_size.h>
0234 #  include <__tuple/tuple_types.h>
0235 #  include <__type_traits/common_reference.h>
0236 #  include <__type_traits/common_type.h>
0237 #  include <__type_traits/conditional.h>
0238 #  include <__type_traits/conjunction.h>
0239 #  include <__type_traits/copy_cvref.h>
0240 #  include <__type_traits/disjunction.h>
0241 #  include <__type_traits/enable_if.h>
0242 #  include <__type_traits/invoke.h>
0243 #  include <__type_traits/is_arithmetic.h>
0244 #  include <__type_traits/is_assignable.h>
0245 #  include <__type_traits/is_constructible.h>
0246 #  include <__type_traits/is_convertible.h>
0247 #  include <__type_traits/is_empty.h>
0248 #  include <__type_traits/is_final.h>
0249 #  include <__type_traits/is_implicitly_default_constructible.h>
0250 #  include <__type_traits/is_nothrow_assignable.h>
0251 #  include <__type_traits/is_nothrow_constructible.h>
0252 #  include <__type_traits/is_reference.h>
0253 #  include <__type_traits/is_same.h>
0254 #  include <__type_traits/is_swappable.h>
0255 #  include <__type_traits/is_trivially_relocatable.h>
0256 #  include <__type_traits/lazy.h>
0257 #  include <__type_traits/maybe_const.h>
0258 #  include <__type_traits/nat.h>
0259 #  include <__type_traits/negation.h>
0260 #  include <__type_traits/remove_cv.h>
0261 #  include <__type_traits/remove_cvref.h>
0262 #  include <__type_traits/remove_reference.h>
0263 #  include <__type_traits/unwrap_ref.h>
0264 #  include <__utility/declval.h>
0265 #  include <__utility/forward.h>
0266 #  include <__utility/integer_sequence.h>
0267 #  include <__utility/move.h>
0268 #  include <__utility/piecewise_construct.h>
0269 #  include <__utility/swap.h>
0270 #  include <version>
0271 
0272 // standard-mandated includes
0273 
0274 // [tuple.syn]
0275 #  include <compare>
0276 
0277 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0278 #    pragma GCC system_header
0279 #  endif
0280 
0281 _LIBCPP_PUSH_MACROS
0282 #  include <__undef_macros>
0283 
0284 _LIBCPP_BEGIN_NAMESPACE_STD
0285 
0286 #  ifndef _LIBCPP_CXX03_LANG
0287 
0288 // __tuple_leaf
0289 
0290 template <size_t _Ip, class _Hp, bool = is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value >
0291 class __tuple_leaf;
0292 
0293 template <size_t _Ip, class _Hp, bool _Ep>
0294 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
0295 swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y) noexcept(__is_nothrow_swappable_v<_Hp>) {
0296   swap(__x.get(), __y.get());
0297 }
0298 
0299 template <size_t _Ip, class _Hp, bool _Ep>
0300 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
0301 swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x,
0302      const __tuple_leaf<_Ip, _Hp, _Ep>& __y) noexcept(__is_nothrow_swappable_v<const _Hp>) {
0303   swap(__x.get(), __y.get());
0304 }
0305 
0306 template <size_t _Ip, class _Hp, bool>
0307 class __tuple_leaf {
0308   _Hp __value_;
0309 
0310   template <class _Tp>
0311   static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() {
0312 #    if __has_keyword(__reference_binds_to_temporary)
0313     return !__reference_binds_to_temporary(_Hp, _Tp);
0314 #    else
0315     return true;
0316 #    endif
0317   }
0318 
0319 public:
0320   _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete;
0321 
0322   _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf() noexcept(is_nothrow_default_constructible<_Hp>::value) : __value_() {
0323     static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");
0324   }
0325 
0326   template <class _Alloc>
0327   _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 0>, const _Alloc&) : __value_() {
0328     static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");
0329   }
0330 
0331   template <class _Alloc>
0332   _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
0333       : __value_(allocator_arg_t(), __a) {
0334     static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");
0335   }
0336 
0337   template <class _Alloc>
0338   _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a) : __value_(__a) {
0339     static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");
0340   }
0341 
0342   template <
0343       class _Tp,
0344       __enable_if_t<_And<_IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>, is_constructible<_Hp, _Tp> >::value, int> = 0>
0345   _LIBCPP_HIDE_FROM_ABI
0346   _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value)
0347       : __value_(std::forward<_Tp>(__t)) {
0348     static_assert(__can_bind_reference<_Tp&&>(),
0349                   "Attempted construction of reference element binds to a temporary whose lifetime has ended");
0350   }
0351 
0352   template <class _Tp, class _Alloc>
0353   _LIBCPP_HIDE_FROM_ABI
0354   _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
0355       : __value_(std::forward<_Tp>(__t)) {
0356     static_assert(__can_bind_reference<_Tp&&>(),
0357                   "Attempted construction of reference element binds to a temporary whose lifetime has ended");
0358   }
0359 
0360   template <class _Tp, class _Alloc>
0361   _LIBCPP_HIDE_FROM_ABI
0362   _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
0363       : __value_(allocator_arg_t(), __a, std::forward<_Tp>(__t)) {
0364     static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple");
0365   }
0366 
0367   template <class _Tp, class _Alloc>
0368   _LIBCPP_HIDE_FROM_ABI
0369   _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
0370       : __value_(std::forward<_Tp>(__t), __a) {
0371     static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple");
0372   }
0373 
0374   _LIBCPP_HIDE_FROM_ABI __tuple_leaf(const __tuple_leaf& __t) = default;
0375   _LIBCPP_HIDE_FROM_ABI __tuple_leaf(__tuple_leaf&& __t)      = default;
0376 
0377   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
0378   swap(__tuple_leaf& __t) noexcept(__is_nothrow_swappable_v<__tuple_leaf>) {
0379     std::swap(*this, __t);
0380     return 0;
0381   }
0382 
0383   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(const __tuple_leaf& __t) const
0384       noexcept(__is_nothrow_swappable_v<const __tuple_leaf>) {
0385     std::swap(*this, __t);
0386     return 0;
0387   }
0388 
0389   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Hp& get() _NOEXCEPT { return __value_; }
0390   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT { return __value_; }
0391 };
0392 
0393 template <size_t _Ip, class _Hp>
0394 class __tuple_leaf<_Ip, _Hp, true> : private __remove_cv_t<_Hp> {
0395 public:
0396   _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete;
0397 
0398   _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf() noexcept(is_nothrow_default_constructible<_Hp>::value) {}
0399 
0400   template <class _Alloc>
0401   _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
0402 
0403   template <class _Alloc>
0404   _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
0405       : _Hp(allocator_arg_t(), __a) {}
0406 
0407   template <class _Alloc>
0408   _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a) : _Hp(__a) {}
0409 
0410   template <class _Tp,
0411             __enable_if_t< _And< _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>, is_constructible<_Hp, _Tp> >::value,
0412                            int> = 0>
0413   _LIBCPP_HIDE_FROM_ABI
0414   _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value)
0415       : _Hp(std::forward<_Tp>(__t)) {}
0416 
0417   template <class _Tp, class _Alloc>
0418   _LIBCPP_HIDE_FROM_ABI constexpr explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
0419       : _Hp(std::forward<_Tp>(__t)) {}
0420 
0421   template <class _Tp, class _Alloc>
0422   _LIBCPP_HIDE_FROM_ABI constexpr explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
0423       : _Hp(allocator_arg_t(), __a, std::forward<_Tp>(__t)) {}
0424 
0425   template <class _Tp, class _Alloc>
0426   _LIBCPP_HIDE_FROM_ABI constexpr explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
0427       : _Hp(std::forward<_Tp>(__t), __a) {}
0428 
0429   __tuple_leaf(__tuple_leaf const&) = default;
0430   __tuple_leaf(__tuple_leaf&&)      = default;
0431 
0432   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
0433   swap(__tuple_leaf& __t) noexcept(__is_nothrow_swappable_v<__tuple_leaf>) {
0434     std::swap(*this, __t);
0435     return 0;
0436   }
0437 
0438   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(const __tuple_leaf& __rhs) const
0439       noexcept(__is_nothrow_swappable_v<const __tuple_leaf>) {
0440     std::swap(*this, __rhs);
0441     return 0;
0442   }
0443 
0444   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Hp& get() _NOEXCEPT { return static_cast<_Hp&>(*this); }
0445   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT {
0446     return static_cast<const _Hp&>(*this);
0447   }
0448 };
0449 
0450 template <class... _Tp>
0451 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swallow(_Tp&&...) _NOEXCEPT {}
0452 
0453 template <class _Tp>
0454 struct __all_default_constructible;
0455 
0456 template <class... _Tp>
0457 struct __all_default_constructible<__tuple_types<_Tp...>> : __all<is_default_constructible<_Tp>::value...> {};
0458 
0459 // __tuple_impl
0460 
0461 template <class _Indx, class... _Tp>
0462 struct __tuple_impl;
0463 
0464 template <size_t... _Indx, class... _Tp>
0465 struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
0466     : public __tuple_leaf<_Indx, _Tp>... {
0467   _LIBCPP_HIDE_FROM_ABI constexpr __tuple_impl() noexcept(
0468       __all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
0469 
0470   template <size_t... _Uf, class... _Tf, size_t... _Ul, class... _Tl, class... _Up>
0471   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_impl(
0472       __tuple_indices<_Uf...>,
0473       __tuple_types<_Tf...>,
0474       __tuple_indices<_Ul...>,
0475       __tuple_types<_Tl...>,
0476       _Up&&... __u) noexcept(__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
0477                              __all<is_nothrow_default_constructible<_Tl>::value...>::value)
0478       : __tuple_leaf<_Uf, _Tf>(std::forward<_Up>(__u))..., __tuple_leaf<_Ul, _Tl>()... {}
0479 
0480   template <class _Alloc, size_t... _Uf, class... _Tf, size_t... _Ul, class... _Tl, class... _Up>
0481   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_impl(
0482       allocator_arg_t,
0483       const _Alloc& __a,
0484       __tuple_indices<_Uf...>,
0485       __tuple_types<_Tf...>,
0486       __tuple_indices<_Ul...>,
0487       __tuple_types<_Tl...>,
0488       _Up&&... __u)
0489       : __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a, std::forward<_Up>(__u))...,
0490         __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)... {}
0491 
0492   template <class _Tuple, __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value, int> = 0>
0493   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(_Tuple&& __t) noexcept(
0494       (__all<is_nothrow_constructible<
0495            _Tp,
0496            typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
0497       : __tuple_leaf<_Indx, _Tp>(
0498             std::forward<typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>(
0499                 std::get<_Indx>(__t)))... {}
0500 
0501   template <class _Alloc, class _Tuple, __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value, int> = 0>
0502   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
0503       : __tuple_leaf<_Indx, _Tp>(
0504             __uses_alloc_ctor<_Tp,
0505                               _Alloc,
0506                               typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>(),
0507             __a,
0508             std::forward<typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>(
0509                 std::get<_Indx>(__t)))... {}
0510 
0511   __tuple_impl(const __tuple_impl&) = default;
0512   __tuple_impl(__tuple_impl&&)      = default;
0513 
0514   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
0515   swap(__tuple_impl& __t) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {
0516     std::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
0517   }
0518 
0519   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(const __tuple_impl& __t) const
0520       noexcept(__all<__is_nothrow_swappable_v<const _Tp>...>::value) {
0521     std::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t))...);
0522   }
0523 };
0524 
0525 template <class _Dest, class _Source, size_t... _Np>
0526 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
0527 __memberwise_copy_assign(_Dest& __dest, _Source const& __source, __tuple_indices<_Np...>) {
0528   std::__swallow(((std::get<_Np>(__dest) = std::get<_Np>(__source)), void(), 0)...);
0529 }
0530 
0531 template <class _Dest, class _Source, class... _Up, size_t... _Np>
0532 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
0533 __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up...>, __tuple_indices<_Np...>) {
0534   std::__swallow(((std::get<_Np>(__dest) = std::forward<_Up>(std::get<_Np>(__source))), void(), 0)...);
0535 }
0536 
0537 template <class... _Tp>
0538 class _LIBCPP_TEMPLATE_VIS tuple {
0539   typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
0540 
0541   _BaseT __base_;
0542 
0543   template <size_t _Jp, class... _Up>
0544   friend _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
0545   template <size_t _Jp, class... _Up>
0546   friend _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Jp, tuple<_Up...> >::type&
0547   get(const tuple<_Up...>&) _NOEXCEPT;
0548   template <size_t _Jp, class... _Up>
0549   friend _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Jp, tuple<_Up...> >::type&&
0550   get(tuple<_Up...>&&) _NOEXCEPT;
0551   template <size_t _Jp, class... _Up>
0552   friend _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Jp, tuple<_Up...> >::type&&
0553   get(const tuple<_Up...>&&) _NOEXCEPT;
0554 
0555 public:
0556   using __trivially_relocatable _LIBCPP_NODEBUG =
0557       __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>;
0558 
0559   // [tuple.cnstr]
0560 
0561   // tuple() constructors (including allocator_arg_t variants)
0562   template <template <class...> class _IsImpDefault                = __is_implicitly_default_constructible,
0563             template <class...> class _IsDefault                   = is_default_constructible,
0564             __enable_if_t< _And< _IsDefault<_Tp>... >::value, int> = 0>
0565   _LIBCPP_HIDE_FROM_ABI constexpr explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value)
0566       tuple() noexcept(_And<is_nothrow_default_constructible<_Tp>...>::value) {}
0567 
0568   template <class _Alloc,
0569             template <class...> class _IsImpDefault                = __is_implicitly_default_constructible,
0570             template <class...> class _IsDefault                   = is_default_constructible,
0571             __enable_if_t< _And< _IsDefault<_Tp>... >::value, int> = 0>
0572   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value)
0573       tuple(allocator_arg_t, _Alloc const& __a)
0574       : __base_(allocator_arg_t(),
0575                 __a,
0576                 __tuple_indices<>(),
0577                 __tuple_types<>(),
0578                 typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
0579                 __tuple_types<_Tp...>()) {}
0580 
0581   // tuple(const T&...) constructors (including allocator_arg_t variants)
0582   template <template <class...> class _And = _And,
0583             __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0>
0584   _LIBCPP_HIDE_FROM_ABI
0585   _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value)
0586       tuple(const _Tp&... __t) noexcept(_And<is_nothrow_copy_constructible<_Tp>...>::value)
0587       : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
0588                 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
0589                 typename __make_tuple_indices<0>::type(),
0590                 typename __make_tuple_types<tuple, 0>::type(),
0591                 __t...) {}
0592 
0593   template <class _Alloc,
0594             template <class...> class _And = _And,
0595             __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0>
0596   _LIBCPP_HIDE_FROM_ABI
0597   _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value)
0598       tuple(allocator_arg_t, const _Alloc& __a, const _Tp&... __t)
0599       : __base_(allocator_arg_t(),
0600                 __a,
0601                 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
0602                 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
0603                 typename __make_tuple_indices<0>::type(),
0604                 typename __make_tuple_types<tuple, 0>::type(),
0605                 __t...) {}
0606 
0607   // tuple(U&& ...) constructors (including allocator_arg_t variants)
0608   template <class... _Up>
0609   struct _IsThisTuple : false_type {};
0610   template <class _Up>
0611   struct _IsThisTuple<_Up> : is_same<__remove_cvref_t<_Up>, tuple> {};
0612 
0613   template <class... _Up>
0614   struct _EnableUTypesCtor
0615       : _And< _BoolConstant<sizeof...(_Tp) >= 1>,
0616               _Not<_IsThisTuple<_Up...> >, // extension to allow mis-behaved user constructors
0617               is_constructible<_Tp, _Up>... > {};
0618 
0619   template <class... _Up,
0620             __enable_if_t< _And< _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, _EnableUTypesCtor<_Up...> >::value,
0621                            int> = 0>
0622   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
0623       tuple(_Up&&... __u) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value)
0624       : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
0625                 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
0626                 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
0627                 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
0628                 std::forward<_Up>(__u)...) {}
0629 
0630   template <class _Alloc,
0631             class... _Up,
0632             __enable_if_t< _And< _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, _EnableUTypesCtor<_Up...> >::value,
0633                            int> = 0>
0634   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
0635       tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
0636       : __base_(allocator_arg_t(),
0637                 __a,
0638                 typename __make_tuple_indices<sizeof...(_Up)>::type(),
0639                 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
0640                 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
0641                 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
0642                 std::forward<_Up>(__u)...) {}
0643 
0644   // Copy and move constructors (including the allocator_arg_t variants)
0645   tuple(const tuple&) = default;
0646   tuple(tuple&&)      = default;
0647 
0648   template <class _Alloc,
0649             template <class...> class _And                                  = _And,
0650             __enable_if_t< _And<is_copy_constructible<_Tp>...>::value, int> = 0>
0651   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)
0652       : __base_(allocator_arg_t(), __alloc, __t) {}
0653 
0654   template <class _Alloc,
0655             template <class...> class _And                                  = _And,
0656             __enable_if_t< _And<is_move_constructible<_Tp>...>::value, int> = 0>
0657   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)
0658       : __base_(allocator_arg_t(), __alloc, std::move(__t)) {}
0659 
0660   // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants)
0661 
0662   template <class _OtherTuple, class _DecayedOtherTuple = __remove_cvref_t<_OtherTuple>, class = void>
0663   struct _EnableCtorFromUTypesTuple : false_type {};
0664 
0665   template <class _OtherTuple, class... _Up>
0666   struct _EnableCtorFromUTypesTuple<
0667       _OtherTuple,
0668       tuple<_Up...>,
0669       // the length of the packs needs to checked first otherwise the 2 packs cannot be expanded simultaneously below
0670       __enable_if_t<sizeof...(_Up) == sizeof...(_Tp)>>
0671       : _And<
0672             // the two conditions below are not in spec. The purpose is to disable the UTypes Ctor when copy/move Ctor
0673             // can work. Otherwise, is_constructible can trigger hard error in those cases
0674             // https://godbolt.org/z/M94cGdKcE
0675             _Not<is_same<_OtherTuple, const tuple&> >,
0676             _Not<is_same<_OtherTuple, tuple&&> >,
0677             is_constructible<_Tp, __copy_cvref_t<_OtherTuple, _Up> >...,
0678             _Lazy<_Or,
0679                   _BoolConstant<sizeof...(_Tp) != 1>,
0680                   // _Tp and _Up are 1-element packs - the pack expansions look
0681                   // weird to avoid tripping up the type traits in degenerate cases
0682                   _Lazy<_And,
0683                         _Not<is_same<_Tp, _Up> >...,
0684                         _Not<is_convertible<_OtherTuple, _Tp> >...,
0685                         _Not<is_constructible<_Tp, _OtherTuple> >... > > > {};
0686 
0687   template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0>
0688   _LIBCPP_HIDE_FROM_ABI
0689   _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value)
0690       tuple(const tuple<_Up...>& __t) noexcept(_And<is_nothrow_constructible<_Tp, const _Up&>...>::value)
0691       : __base_(__t) {}
0692 
0693   template <class... _Up,
0694             class _Alloc,
0695             __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0>
0696   _LIBCPP_HIDE_FROM_ABI
0697   _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value)
0698       tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
0699       : __base_(allocator_arg_t(), __a, __t) {}
0700 
0701 #    if _LIBCPP_STD_VER >= 23
0702   // tuple(tuple<U...>&) constructors (including allocator_arg_t variants)
0703 
0704   template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
0705   _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value) tuple(tuple<_Up...>& __t)
0706       : __base_(__t) {}
0707 
0708   template <class _Alloc, class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
0709   _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value)
0710       tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t)
0711       : __base_(allocator_arg_t(), __alloc, __t) {}
0712 #    endif // _LIBCPP_STD_VER >= 23
0713 
0714   // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)
0715   template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0>
0716   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
0717       tuple(tuple<_Up...>&& __t) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value)
0718       : __base_(std::move(__t)) {}
0719 
0720   template <class _Alloc,
0721             class... _Up,
0722             __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0>
0723   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
0724       tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
0725       : __base_(allocator_arg_t(), __a, std::move(__t)) {}
0726 
0727 #    if _LIBCPP_STD_VER >= 23
0728   // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants)
0729 
0730   template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
0731   _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value)
0732       tuple(const tuple<_Up...>&& __t)
0733       : __base_(std::move(__t)) {}
0734 
0735   template <class _Alloc,
0736             class... _Up,
0737             enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
0738   _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value)
0739       tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t)
0740       : __base_(allocator_arg_t(), __alloc, std::move(__t)) {}
0741 #    endif // _LIBCPP_STD_VER >= 23
0742 
0743   // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)
0744 
0745   template <template <class...> class _Pred,
0746             class _Pair,
0747             class _DecayedPair = __remove_cvref_t<_Pair>,
0748             class _Tuple       = tuple>
0749   struct _CtorPredicateFromPair : false_type {};
0750 
0751   template <template <class...> class _Pred, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
0752   struct _CtorPredicateFromPair<_Pred, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> >
0753       : _And< _Pred<_Tp1, __copy_cvref_t<_Pair, _Up1> >, _Pred<_Tp2, __copy_cvref_t<_Pair, _Up2> > > {};
0754 
0755   template <class _Pair>
0756   struct _EnableCtorFromPair : _CtorPredicateFromPair<is_constructible, _Pair> {};
0757 
0758   template <class _Pair>
0759   struct _NothrowConstructibleFromPair : _CtorPredicateFromPair<is_nothrow_constructible, _Pair> {};
0760 
0761   template <class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
0762   struct _BothImplicitlyConvertible : false_type {};
0763 
0764   template <class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
0765   struct _BothImplicitlyConvertible<_Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> >
0766       : _And< is_convertible<__copy_cvref_t<_Pair, _Up1>, _Tp1>, is_convertible<__copy_cvref_t<_Pair, _Up2>, _Tp2> > {};
0767 
0768   template <class _Up1,
0769             class _Up2,
0770             template <class...> class _And                                                   = _And,
0771             __enable_if_t< _And< _EnableCtorFromPair<const pair<_Up1, _Up2>&> >::value, int> = 0>
0772   _LIBCPP_HIDE_FROM_ABI
0773   _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value)
0774       tuple(const pair<_Up1, _Up2>& __p) noexcept(_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value)
0775       : __base_(__p) {}
0776 
0777   template <class _Alloc,
0778             class _Up1,
0779             class _Up2,
0780             template <class...> class _And                                                   = _And,
0781             __enable_if_t< _And< _EnableCtorFromPair<const pair<_Up1, _Up2>&> >::value, int> = 0>
0782   _LIBCPP_HIDE_FROM_ABI
0783   _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value)
0784       tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
0785       : __base_(allocator_arg_t(), __a, __p) {}
0786 
0787 #    if _LIBCPP_STD_VER >= 23
0788   // tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants)
0789 
0790   template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr>
0791   _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
0792       tuple(pair<_U1, _U2>& __p)
0793       : __base_(__p) {}
0794 
0795   template <class _Alloc,
0796             class _U1,
0797             class _U2,
0798             enable_if_t< _EnableCtorFromPair<std::pair<_U1, _U2>&>::value>* = nullptr>
0799   _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value)
0800       tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p)
0801       : __base_(allocator_arg_t(), __alloc, __p) {}
0802 #    endif
0803 
0804   // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)
0805 
0806   template <class _Up1,
0807             class _Up2,
0808             template <class...> class _And                                              = _And,
0809             __enable_if_t< _And< _EnableCtorFromPair<pair<_Up1, _Up2>&&> >::value, int> = 0>
0810   _LIBCPP_HIDE_FROM_ABI
0811   _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value)
0812       tuple(pair<_Up1, _Up2>&& __p) noexcept(_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value)
0813       : __base_(std::move(__p)) {}
0814 
0815   template <class _Alloc,
0816             class _Up1,
0817             class _Up2,
0818             template <class...> class _And                                              = _And,
0819             __enable_if_t< _And< _EnableCtorFromPair<pair<_Up1, _Up2>&&> >::value, int> = 0>
0820   _LIBCPP_HIDE_FROM_ABI
0821   _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value)
0822       tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
0823       : __base_(allocator_arg_t(), __a, std::move(__p)) {}
0824 
0825 #    if _LIBCPP_STD_VER >= 23
0826   // tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants)
0827 
0828   template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
0829   _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
0830       tuple(const pair<_U1, _U2>&& __p)
0831       : __base_(std::move(__p)) {}
0832 
0833   template <class _Alloc,
0834             class _U1,
0835             class _U2,
0836             enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr>
0837   _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value)
0838       tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p)
0839       : __base_(allocator_arg_t(), __alloc, std::move(__p)) {}
0840 #    endif // _LIBCPP_STD_VER >= 23
0841 
0842   // [tuple.assign]
0843   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
0844   operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) noexcept(
0845       _And<is_nothrow_copy_assignable<_Tp>...>::value) {
0846     std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
0847     return *this;
0848   }
0849 
0850 #    if _LIBCPP_STD_VER >= 23
0851   _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple const& __tuple) const
0852     requires(_And<is_copy_assignable<const _Tp>...>::value)
0853   {
0854     std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
0855     return *this;
0856   }
0857 
0858   _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple&& __tuple) const
0859     requires(_And<is_assignable<const _Tp&, _Tp>...>::value)
0860   {
0861     std::__memberwise_forward_assign(
0862         *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
0863     return *this;
0864   }
0865 #    endif // _LIBCPP_STD_VER >= 23
0866 
0867   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
0868   operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) noexcept(
0869       _And<is_nothrow_move_assignable<_Tp>...>::value) {
0870     std::__memberwise_forward_assign(
0871         *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
0872     return *this;
0873   }
0874 
0875   template <
0876       class... _Up,
0877       __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up const&>... >::value,
0878                      int> = 0>
0879   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
0880   operator=(tuple<_Up...> const& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) {
0881     std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
0882     return *this;
0883   }
0884 
0885   template <class... _Up,
0886             __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up>... >::value,
0887                            int> = 0>
0888   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
0889   operator=(tuple<_Up...>&& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) {
0890     std::__memberwise_forward_assign(
0891         *this, std::move(__tuple), __tuple_types<_Up...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
0892     return *this;
0893   }
0894 
0895 #    if _LIBCPP_STD_VER >= 23
0896   template <class... _UTypes,
0897             enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
0898                               is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr>
0899   _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(const tuple<_UTypes...>& __u) const {
0900     std::__memberwise_copy_assign(*this, __u, typename __make_tuple_indices<sizeof...(_Tp)>::type());
0901     return *this;
0902   }
0903 
0904   template <class... _UTypes,
0905             enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
0906                               is_assignable<const _Tp&, _UTypes>...>::value>* = nullptr>
0907   _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple<_UTypes...>&& __u) const {
0908     std::__memberwise_forward_assign(
0909         *this, __u, __tuple_types<_UTypes...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
0910     return *this;
0911   }
0912 #    endif // _LIBCPP_STD_VER >= 23
0913 
0914   template <template <class...> class _Pred,
0915             bool _Const,
0916             class _Pair,
0917             class _DecayedPair = __remove_cvref_t<_Pair>,
0918             class _Tuple       = tuple>
0919   struct _AssignPredicateFromPair : false_type {};
0920 
0921   template <template <class...> class _Pred, bool _Const, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
0922   struct _AssignPredicateFromPair<_Pred, _Const, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> >
0923       : _And<_Pred<__maybe_const<_Const, _Tp1>&, __copy_cvref_t<_Pair, _Up1> >,
0924              _Pred<__maybe_const<_Const, _Tp2>&, __copy_cvref_t<_Pair, _Up2> > > {};
0925 
0926   template <bool _Const, class _Pair>
0927   struct _EnableAssignFromPair : _AssignPredicateFromPair<is_assignable, _Const, _Pair> {};
0928 
0929   template <bool _Const, class _Pair>
0930   struct _NothrowAssignFromPair : _AssignPredicateFromPair<is_nothrow_assignable, _Const, _Pair> {};
0931 
0932 #    if _LIBCPP_STD_VER >= 23
0933   template <class _U1, class _U2, enable_if_t< _EnableAssignFromPair<true, const pair<_U1, _U2>&>::value>* = nullptr>
0934   _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(const pair<_U1, _U2>& __pair) const
0935       noexcept(_NothrowAssignFromPair<true, const pair<_U1, _U2>&>::value) {
0936     std::get<0>(*this) = __pair.first;
0937     std::get<1>(*this) = __pair.second;
0938     return *this;
0939   }
0940 
0941   template <class _U1, class _U2, enable_if_t< _EnableAssignFromPair<true, pair<_U1, _U2>&&>::value>* = nullptr>
0942   _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(pair<_U1, _U2>&& __pair) const
0943       noexcept(_NothrowAssignFromPair<true, pair<_U1, _U2>&&>::value) {
0944     std::get<0>(*this) = std::move(__pair.first);
0945     std::get<1>(*this) = std::move(__pair.second);
0946     return *this;
0947   }
0948 #    endif // _LIBCPP_STD_VER >= 23
0949 
0950   template <class _Up1,
0951             class _Up2,
0952             __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value, int> = 0>
0953   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
0954   operator=(pair<_Up1, _Up2> const& __pair) noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value) {
0955     std::get<0>(*this) = __pair.first;
0956     std::get<1>(*this) = __pair.second;
0957     return *this;
0958   }
0959 
0960   template <class _Up1, class _Up2, __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value, int> = 0>
0961   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
0962   operator=(pair<_Up1, _Up2>&& __pair) noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value) {
0963     std::get<0>(*this) = std::forward<_Up1>(__pair.first);
0964     std::get<1>(*this) = std::forward<_Up2>(__pair.second);
0965     return *this;
0966   }
0967 
0968   // EXTENSION
0969   template <
0970       class _Up,
0971       size_t _Np,
0972       __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value, int> = 0>
0973   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
0974   operator=(array<_Up, _Np> const& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) {
0975     std::__memberwise_copy_assign(*this, __array, typename __make_tuple_indices<sizeof...(_Tp)>::type());
0976     return *this;
0977   }
0978 
0979   // EXTENSION
0980   template <class _Up,
0981             size_t _Np,
0982             class = void,
0983             __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up>... >::value, int> = 0>
0984   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
0985   operator=(array<_Up, _Np>&& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) {
0986     std::__memberwise_forward_assign(
0987         *this,
0988         std::move(__array),
0989         __tuple_types<_If<true, _Up, _Tp>...>(),
0990         typename __make_tuple_indices<sizeof...(_Tp)>::type());
0991     return *this;
0992   }
0993 
0994   // [tuple.swap]
0995   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
0996   swap(tuple& __t) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {
0997     __base_.swap(__t.__base_);
0998   }
0999 
1000 #    if _LIBCPP_STD_VER >= 23
1001   _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple& __t) const
1002       noexcept(__all<is_nothrow_swappable_v<const _Tp&>...>::value) {
1003     __base_.swap(__t.__base_);
1004   }
1005 #    endif // _LIBCPP_STD_VER >= 23
1006 };
1007 
1008 template <>
1009 class _LIBCPP_TEMPLATE_VIS tuple<> {
1010 public:
1011   constexpr tuple() _NOEXCEPT = default;
1012   template <class _Alloc>
1013   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
1014   template <class _Alloc>
1015   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
1016   template <class _Up>
1017   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(array<_Up, 0>) _NOEXCEPT {}
1018   template <class _Alloc, class _Up>
1019   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
1020   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple&) _NOEXCEPT {}
1021 #    if _LIBCPP_STD_VER >= 23
1022   _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}
1023 #    endif
1024 };
1025 
1026 #    if _LIBCPP_STD_VER >= 23
1027 template <class... _TTypes, class... _UTypes, template <class> class _TQual, template <class> class _UQual>
1028   requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; }
1029 struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> {
1030   using type = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>;
1031 };
1032 
1033 template <class... _TTypes, class... _UTypes>
1034   requires requires { typename tuple<common_type_t<_TTypes, _UTypes>...>; }
1035 struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {
1036   using type = tuple<common_type_t<_TTypes, _UTypes>...>;
1037 };
1038 #    endif // _LIBCPP_STD_VER >= 23
1039 
1040 #    if _LIBCPP_STD_VER >= 17
1041 template <class... _Tp>
1042 tuple(_Tp...) -> tuple<_Tp...>;
1043 template <class _Tp1, class _Tp2>
1044 tuple(pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
1045 template <class _Alloc, class... _Tp>
1046 tuple(allocator_arg_t, _Alloc, _Tp...) -> tuple<_Tp...>;
1047 template <class _Alloc, class _Tp1, class _Tp2>
1048 tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
1049 template <class _Alloc, class... _Tp>
1050 tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
1051 #    endif
1052 
1053 template <class... _Tp, __enable_if_t<__all<__is_swappable_v<_Tp>...>::value, int> = 0>
1054 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
1055 swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {
1056   __t.swap(__u);
1057 }
1058 
1059 #    if _LIBCPP_STD_VER >= 23
1060 template <class... _Tp>
1061 _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<__all<is_swappable_v<const _Tp>...>::value, void>
1062 swap(const tuple<_Tp...>& __lhs,
1063      const tuple<_Tp...>& __rhs) noexcept(__all<is_nothrow_swappable_v<const _Tp>...>::value) {
1064   __lhs.swap(__rhs);
1065 }
1066 #    endif
1067 
1068 // get
1069 
1070 template <size_t _Ip, class... _Tp>
1071 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&
1072 get(tuple<_Tp...>& __t) _NOEXCEPT {
1073   using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type;
1074   return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
1075 }
1076 
1077 template <size_t _Ip, class... _Tp>
1078 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
1079 get(const tuple<_Tp...>& __t) _NOEXCEPT {
1080   using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type;
1081   return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
1082 }
1083 
1084 template <size_t _Ip, class... _Tp>
1085 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1086 get(tuple<_Tp...>&& __t) _NOEXCEPT {
1087   using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type;
1088   return static_cast<type&&>(static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
1089 }
1090 
1091 template <size_t _Ip, class... _Tp>
1092 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1093 get(const tuple<_Tp...>&& __t) _NOEXCEPT {
1094   using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type;
1095   return static_cast<const type&&>(static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
1096 }
1097 
1098 #    if _LIBCPP_STD_VER >= 14
1099 
1100 template <class _T1, class... _Args>
1101 inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(tuple<_Args...>& __tup) noexcept {
1102   return std::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1103 }
1104 
1105 template <class _T1, class... _Args>
1106 inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept {
1107   return std::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1108 }
1109 
1110 template <class _T1, class... _Args>
1111 inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept {
1112   return std::get<__find_exactly_one_t<_T1, _Args...>::value>(std::move(__tup));
1113 }
1114 
1115 template <class _T1, class... _Args>
1116 inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept {
1117   return std::get<__find_exactly_one_t<_T1, _Args...>::value>(std::move(__tup));
1118 }
1119 
1120 #    endif
1121 
1122 // tie
1123 
1124 template <class... _Tp>
1125 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_Tp&... __t) _NOEXCEPT {
1126   return tuple<_Tp&...>(__t...);
1127 }
1128 
1129 template <class... _Tp>
1130 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<__unwrap_ref_decay_t<_Tp>...>
1131 make_tuple(_Tp&&... __t) {
1132   return tuple<__unwrap_ref_decay_t<_Tp>...>(std::forward<_Tp>(__t)...);
1133 }
1134 
1135 template <class... _Tp>
1136 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&&...> forward_as_tuple(_Tp&&... __t) _NOEXCEPT {
1137   return tuple<_Tp&&...>(std::forward<_Tp>(__t)...);
1138 }
1139 
1140 template <size_t _Ip>
1141 struct __tuple_equal {
1142   template <class _Tp, class _Up>
1143   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __x, const _Up& __y) {
1144     return __tuple_equal<_Ip - 1>()(__x, __y) && std::get<_Ip - 1>(__x) == std::get<_Ip - 1>(__y);
1145   }
1146 };
1147 
1148 template <>
1149 struct __tuple_equal<0> {
1150   template <class _Tp, class _Up>
1151   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp&, const _Up&) {
1152     return true;
1153   }
1154 };
1155 
1156 template <class... _Tp, class... _Up>
1157 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1158 operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1159   static_assert(sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
1160   return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
1161 }
1162 
1163 #    if _LIBCPP_STD_VER >= 20
1164 
1165 // operator<=>
1166 
1167 template <class... _Tp, class... _Up, size_t... _Is>
1168 _LIBCPP_HIDE_FROM_ABI constexpr auto
1169 __tuple_compare_three_way(const tuple<_Tp...>& __x, const tuple<_Up...>& __y, index_sequence<_Is...>) {
1170   common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> __result = strong_ordering::equal;
1171   static_cast<void>(
1172       ((__result = std::__synth_three_way(std::get<_Is>(__x), std::get<_Is>(__y)), __result != 0) || ...));
1173   return __result;
1174 }
1175 
1176 template <class... _Tp, class... _Up>
1177   requires(sizeof...(_Tp) == sizeof...(_Up))
1178 _LIBCPP_HIDE_FROM_ABI constexpr common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...>
1179 operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1180   return std::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{});
1181 }
1182 
1183 #    else // _LIBCPP_STD_VER >= 20
1184 
1185 template <class... _Tp, class... _Up>
1186 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1187 operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1188   return !(__x == __y);
1189 }
1190 
1191 template <size_t _Ip>
1192 struct __tuple_less {
1193   template <class _Tp, class _Up>
1194   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp& __x, const _Up& __y) {
1195     const size_t __idx = tuple_size<_Tp>::value - _Ip;
1196     if (std::get<__idx>(__x) < std::get<__idx>(__y))
1197       return true;
1198     if (std::get<__idx>(__y) < std::get<__idx>(__x))
1199       return false;
1200     return __tuple_less<_Ip - 1>()(__x, __y);
1201   }
1202 };
1203 
1204 template <>
1205 struct __tuple_less<0> {
1206   template <class _Tp, class _Up>
1207   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _Tp&, const _Up&) {
1208     return false;
1209   }
1210 };
1211 
1212 template <class... _Tp, class... _Up>
1213 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1214 operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1215   static_assert(sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
1216   return __tuple_less<sizeof...(_Tp)>()(__x, __y);
1217 }
1218 
1219 template <class... _Tp, class... _Up>
1220 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1221 operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1222   return __y < __x;
1223 }
1224 
1225 template <class... _Tp, class... _Up>
1226 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1227 operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1228   return !(__x < __y);
1229 }
1230 
1231 template <class... _Tp, class... _Up>
1232 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1233 operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1234   return !(__y < __x);
1235 }
1236 
1237 #    endif // _LIBCPP_STD_VER >= 20
1238 
1239 // tuple_cat
1240 
1241 template <class _Tp, class _Up>
1242 struct __tuple_cat_type;
1243 
1244 template <class... _Ttypes, class... _Utypes>
1245 struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> > {
1246   using type _LIBCPP_NODEBUG = tuple<_Ttypes..., _Utypes...>;
1247 };
1248 
1249 template <class _ResultTuple, bool _Is_Tuple0TupleLike, class... _Tuples>
1250 struct __tuple_cat_return_1 {};
1251 
1252 template <class... _Types, class _Tuple0>
1253 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0> {
1254   using type _LIBCPP_NODEBUG =
1255       typename __tuple_cat_type< tuple<_Types...>,
1256                                  typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type >::type;
1257 };
1258 
1259 template <class... _Types, class _Tuple0, class _Tuple1, class... _Tuples>
1260 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
1261     : public __tuple_cat_return_1<
1262           typename __tuple_cat_type< tuple<_Types...>,
1263                                      typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type >::type,
1264           __tuple_like_ext<__libcpp_remove_reference_t<_Tuple1> >::value,
1265           _Tuple1,
1266           _Tuples...> {};
1267 
1268 template <class... _Tuples>
1269 struct __tuple_cat_return;
1270 
1271 template <class _Tuple0, class... _Tuples>
1272 struct __tuple_cat_return<_Tuple0, _Tuples...>
1273     : public __tuple_cat_return_1<tuple<>,
1274                                   __tuple_like_ext<__libcpp_remove_reference_t<_Tuple0> >::value,
1275                                   _Tuple0,
1276                                   _Tuples...> {};
1277 
1278 template <>
1279 struct __tuple_cat_return<> {
1280   using type _LIBCPP_NODEBUG = tuple<>;
1281 };
1282 
1283 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<> tuple_cat() { return tuple<>(); }
1284 
1285 template <class _Rp, class _Indices, class _Tuple0, class... _Tuples>
1286 struct __tuple_cat_return_ref_imp;
1287 
1288 template <class... _Types, size_t... _I0, class _Tuple0>
1289 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> {
1290   using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>;
1291   typedef tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type;
1292 };
1293 
1294 template <class... _Types, size_t... _I0, class _Tuple0, class _Tuple1, class... _Tuples>
1295 struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0, _Tuple1, _Tuples...>
1296     : public __tuple_cat_return_ref_imp<
1297           tuple<_Types...,
1298                 __copy_cvref_t<_Tuple0, typename tuple_element<_I0, __libcpp_remove_reference_t<_Tuple0>>::type>&&...>,
1299           typename __make_tuple_indices<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>::type,
1300           _Tuple1,
1301           _Tuples...> {};
1302 
1303 template <class _Tuple0, class... _Tuples>
1304 struct __tuple_cat_return_ref
1305     : public __tuple_cat_return_ref_imp<
1306           tuple<>,
1307           typename __make_tuple_indices< tuple_size<__libcpp_remove_reference_t<_Tuple0> >::value >::type,
1308           _Tuple0,
1309           _Tuples...> {};
1310 
1311 template <class _Types, class _I0, class _J0>
1312 struct __tuple_cat;
1313 
1314 template <class... _Types, size_t... _I0, size_t... _J0>
1315 struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> > {
1316   template <class _Tuple0>
1317   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
1318   typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1319   operator()(tuple<_Types...> __t, _Tuple0&& __t0) {
1320     (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1321     return std::forward_as_tuple(
1322         std::forward<_Types>(std::get<_I0>(__t))..., std::get<_J0>(std::forward<_Tuple0>(__t0))...);
1323   }
1324 
1325   template <class _Tuple0, class _Tuple1, class... _Tuples>
1326   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
1327   typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1328   operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&&... __tpls) {
1329     (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1330     using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>;
1331     using _T1 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple1>;
1332     return __tuple_cat<tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>,
1333                        typename __make_tuple_indices<sizeof...(_Types) + tuple_size<_T0>::value>::type,
1334                        typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
1335         std::forward_as_tuple(
1336             std::forward<_Types>(std::get<_I0>(__t))..., std::get<_J0>(std::forward<_Tuple0>(__t0))...),
1337         std::forward<_Tuple1>(__t1),
1338         std::forward<_Tuples>(__tpls)...);
1339   }
1340 };
1341 
1342 template <class _TupleDst, class _TupleSrc, size_t... _Indices>
1343 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _TupleDst
1344 __tuple_cat_select_element_wise(_TupleSrc&& __src, __tuple_indices<_Indices...>) {
1345   static_assert(tuple_size<_TupleDst>::value == tuple_size<_TupleSrc>::value,
1346                 "misuse of __tuple_cat_select_element_wise with tuples of different sizes");
1347   return _TupleDst(std::get<_Indices>(std::forward<_TupleSrc>(__src))...);
1348 }
1349 
1350 template <class _Tuple0, class... _Tuples>
1351 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1352 tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) {
1353   using _T0 _LIBCPP_NODEBUG          = __libcpp_remove_reference_t<_Tuple0>;
1354   using _TRet _LIBCPP_NODEBUG        = typename __tuple_cat_return<_Tuple0, _Tuples...>::type;
1355   using _T0Indices _LIBCPP_NODEBUG   = typename __make_tuple_indices<tuple_size<_T0>::value>::type;
1356   using _TRetIndices _LIBCPP_NODEBUG = typename __make_tuple_indices<tuple_size<_TRet>::value>::type;
1357   return std::__tuple_cat_select_element_wise<_TRet>(
1358       __tuple_cat<tuple<>, __tuple_indices<>, _T0Indices>()(
1359           tuple<>(), std::forward<_Tuple0>(__t0), std::forward<_Tuples>(__tpls)...),
1360       _TRetIndices());
1361 }
1362 
1363 template <class... _Tp, class _Alloc>
1364 struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc> : true_type {};
1365 
1366 #    if _LIBCPP_STD_VER >= 17
1367 #      define _LIBCPP_NOEXCEPT_RETURN(...)                                                                             \
1368         noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
1369 
1370 // The _LIBCPP_NOEXCEPT_RETURN macro breaks formatting.
1371 // clang-format off
1372 template <class _Fn, class _Tuple, size_t... _Id>
1373 inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto)
1374 __apply_tuple_impl(_Fn&& __f, _Tuple&& __t, __tuple_indices<_Id...>)
1375     _LIBCPP_NOEXCEPT_RETURN(std::__invoke(std::forward<_Fn>(__f), std::get<_Id>(std::forward<_Tuple>(__t))...))
1376 
1377 template <class _Fn, class _Tuple>
1378 inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) apply(_Fn&& __f, _Tuple&& __t)
1379     _LIBCPP_NOEXCEPT_RETURN(std::__apply_tuple_impl(
1380         std::forward<_Fn>(__f),
1381         std::forward<_Tuple>(__t),
1382         typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{}))
1383 
1384 #if _LIBCPP_STD_VER >= 20
1385 template <class _Tp, class _Tuple, size_t... _Idx>
1386 inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
1387   noexcept(noexcept(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...)))
1388   requires is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...> {
1389   return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...);
1390 }
1391 #else
1392 template <class _Tp, class _Tuple, size_t... _Idx>
1393 inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>,
1394     enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...>> * = nullptr)
1395     _LIBCPP_NOEXCEPT_RETURN(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...))
1396 #endif // _LIBCPP_STD_VER >= 20
1397 
1398 template <class _Tp, class _Tuple,
1399           class _Seq = typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type, class = void>
1400 inline constexpr bool __can_make_from_tuple = false;
1401 
1402 template <class _Tp, class _Tuple, size_t... _Idx>
1403 inline constexpr bool __can_make_from_tuple<_Tp, _Tuple, __tuple_indices<_Idx...>,
1404     enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::declval<_Tuple>()))...>>> = true;
1405 
1406 // Based on LWG3528(https://wg21.link/LWG3528) and http://eel.is/c++draft/description#structure.requirements-9,
1407 // the standard allows to impose requirements, we constraint std::make_from_tuple to make std::make_from_tuple
1408 // SFINAE friendly and also avoid worse diagnostic messages. We still keep the constraints of std::__make_from_tuple_impl
1409 // so that std::__make_from_tuple_impl will have the same advantages when used alone.
1410 #if _LIBCPP_STD_VER >= 20
1411 template <class _Tp, class _Tuple>
1412   requires __can_make_from_tuple<_Tp, _Tuple> // strengthen
1413 #else
1414 template <class _Tp, class _Tuple, class = enable_if_t<__can_make_from_tuple<_Tp, _Tuple>>> // strengthen
1415 #endif // _LIBCPP_STD_VER >= 20
1416 inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp make_from_tuple(_Tuple&& __t)
1417     _LIBCPP_NOEXCEPT_RETURN(std::__make_from_tuple_impl<_Tp>(
1418         std::forward<_Tuple>(__t), typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{}))
1419 #    undef _LIBCPP_NOEXCEPT_RETURN
1420 
1421 #  endif // _LIBCPP_STD_VER >= 17
1422 
1423 #endif // !defined(_LIBCPP_CXX03_LANG)
1424 
1425 _LIBCPP_END_NAMESPACE_STD
1426 
1427 _LIBCPP_POP_MACROS
1428 
1429 // clang-format on
1430 
1431 #  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1432 #    include <cstddef>
1433 #    include <exception>
1434 #    include <iosfwd>
1435 #    include <new>
1436 #    include <type_traits>
1437 #    include <typeinfo>
1438 #    include <utility>
1439 #  endif
1440 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
1441 
1442 #endif // _LIBCPP_TUPLE