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