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