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