codekingpro/portable-devtools
114k
1// -*- C++ -*-2//===--------------------------- tuple ------------------------------------===//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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCUDACXX_TUPLE11#define _LIBCUDACXX_TUPLE12 13/*14 tuple synopsis15 16namespace std17{18 19template <class... T>20class tuple {21public:22 explicit(see-below) constexpr tuple();23 explicit(see-below) tuple(const T&...); // constexpr in C++1424 template <class... U>25 explicit(see-below) tuple(U&&...); // constexpr in C++1426 tuple(const tuple&) = default;27 tuple(tuple&&) = default;28 template <class... U>29 explicit(see-below) tuple(const tuple<U...>&); // constexpr in C++1430 template <class... U>31 explicit(see-below) tuple(tuple<U...>&&); // constexpr in C++1432 template <class U1, class U2>33 explicit(see-below) tuple(const pair<U1, U2>&); // iff sizeof...(T) == 234// constexpr in C++14 template <class U1, class U2> explicit(see-below)35tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++1436 37 // allocator-extended constructors38 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&...);42 template <class Alloc, class... U>43 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, U&&...);44 template <class Alloc>45 tuple(allocator_arg_t, const Alloc& a, const tuple&);46 template <class Alloc>47 tuple(allocator_arg_t, const Alloc& a, tuple&&);48 template <class Alloc, class... U>49 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const50tuple<U...>&); template <class Alloc, class... U> explicit(see-below)51tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&); template <class Alloc,52class U1, class U2> explicit(see-below) tuple(allocator_arg_t, const Alloc& a,53const pair<U1, U2>&); template <class Alloc, class U1, class U2>54 explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1,55U2>&&);56 57 tuple& operator=(const tuple&);58 tuple&59 operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value60...)); template <class... U> tuple& operator=(const tuple<U...>&); template61<class... U> tuple& operator=(tuple<U...>&&); template <class U1, class U2>62 tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 263 template <class U1, class U2>64 tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 265 66 void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));67};68 69template <class ...T>70tuple(T...) -> tuple<T...>; // since71C++17 template <class T1, class T2> tuple(pair<T1, T2>) -> tuple<T1, T2>; //72since C++17 template <class Alloc, class ...T> tuple(allocator_arg_t, Alloc,73T...) -> tuple<T...>; // since C++17 template <class Alloc,74class T1, class T2> tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1,75T2>; // since C++17 template <class Alloc, class ...T>76tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>; // since77C++1778 79inline constexpr unspecified ignore;80 81template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++1482template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; //83constexpr in C++14 template <class... T> tuple<T&...> tie(T&...) noexcept; //84constexpr in C++14 template <class... Tuples> tuple<CTypes...>85tuple_cat(Tuples&&... tpls); // constexpr in C++1486 87// [tuple.apply], calling a function with a tuple of arguments:88template <class F, class Tuple>89 constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++1790template <class T, class Tuple>91 constexpr T make_from_tuple(Tuple&& t); // C++1792 93// 20.4.1.4, tuple helper classes:94template <class T> struct tuple_size; // undefined95template <class... T> struct tuple_size<tuple<T...>>;96template <class T>97 inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++1798template <size_t I, class T> struct tuple_element; // undefined99template <size_t I, class... T> struct tuple_element<I, tuple<T...>>;100template <size_t I, class T>101 using tuple_element_t = typename tuple_element <I, T>::type; // C++14102 103// 20.4.1.5, element access:104template <size_t I, class... T>105 typename tuple_element<I, tuple<T...>>::type&106 get(tuple<T...>&) noexcept; // constexpr in C++14107template <size_t I, class... T>108 const typename tuple_element<I, tuple<T...>>::type&109 get(const tuple<T...>&) noexcept; // constexpr in C++14110template <size_t I, class... T>111 typename tuple_element<I, tuple<T...>>::type&&112 get(tuple<T...>&&) noexcept; // constexpr in C++14113template <size_t I, class... T>114 const typename tuple_element<I, tuple<T...>>::type&&115 get(const tuple<T...>&&) noexcept; // constexpr in C++14116 117template <class T1, class... T>118 constexpr T1& get(tuple<T...>&) noexcept; // C++14119template <class T1, class... T>120 constexpr const T1& get(const tuple<T...>&) noexcept; // C++14121template <class T1, class... T>122 constexpr T1&& get(tuple<T...>&&) noexcept; // C++14123template <class T1, class... T>124 constexpr const T1&& get(const tuple<T...>&&) noexcept; // C++14125 126// 20.4.1.6, relational operators:127template<class... T, class... U> bool operator==(const tuple<T...>&, const128tuple<U...>&); // constexpr in C++14 template<class... T, class... U> bool129operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14130template<class... T, class... U> bool operator!=(const tuple<T...>&, const131tuple<U...>&); // constexpr in C++14 template<class... T, class... U> bool132operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14133template<class... T, class... U> bool operator<=(const tuple<T...>&, const134tuple<U...>&); // constexpr in C++14 template<class... T, class... U> bool135operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14136 137template <class... Types, class Alloc>138 struct uses_allocator<tuple<Types...>, Alloc>;139 140template <class... Types>141 void142 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));143 144} // std145 146*/147 148#ifndef __cuda_std__149#include <__config>150#endif // __cuda_std__151 152#include "__assert" // all public C++ headers provide the assertion handler153#include "__functional/unwrap_ref.h"154#include "__functional_base"155#include "__fwd/array.h"156#include "__tuple_dir/apply_cv.h"157#include "__tuple_dir/make_tuple_types.h"158#include "__tuple_dir/sfinae_helpers.h"159#include "__tuple_dir/structured_bindings.h"160#include "__tuple_dir/tuple_element.h"161#include "__tuple_dir/tuple_indices.h"162#include "__tuple_dir/tuple_like.h"163#include "__tuple_dir/tuple_size.h"164#include "__tuple_dir/tuple_types.h"165#include "__type_traits/maybe_const.h"166#include "__utility/forward.h"167#include "__utility/integer_sequence.h"168#include "__utility/move.h"169#include "__utility/pair.h"170#include "__utility/piecewise_construct.h"171#include "__utility/swap.h"172#include "climits"173#include "cstddef"174#include "cstdint"175#include "type_traits"176#include "utility"177 178// standard-mandated includes179#include "version"180 181// [tuple.syn]182#ifndef _LIBCUDACXX_HAS_NO_SPACESHIP_OPERATOR183#include "compare"184#endif185 186#ifndef __cuda_std__187#include <__pragma_push>188#endif // __cuda_std__189 190#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)191# pragma GCC system_header192#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)193# pragma clang system_header194#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)195# pragma system_header196#endif // no system header197 198_LIBCUDACXX_BEGIN_NAMESPACE_STD199 200// __tuple_leaf201struct __tuple_leaf_default_constructor_tag {};202 203template <size_t _Ip, class _Hp,204 bool = _LIBCUDACXX_TRAIT(is_empty, _Hp) &&205 !__libcpp_is_final<_Hp>::value>206class __tuple_leaf;207 208template <size_t _Ip, class _Hp, bool _Ep>209inline _LIBCUDACXX_INLINE_VISIBILITY void210swap(__tuple_leaf<_Ip, _Hp, _Ep> &__x,211 __tuple_leaf<_Ip, _Hp, _Ep>212 &__y) noexcept(__is_nothrow_swappable<_Hp>::value) {213 swap(__x.get(), __y.get());214}215 216template <size_t _Ip, class _Hp, bool> class __tuple_leaf {217 _Hp __value_;218 219 template <class _Tp>220 _LIBCUDACXX_INLINE_VISIBILITY static constexpr bool __can_bind_reference() {221#if __has_keyword(__reference_binds_to_temporary)222 return !__reference_binds_to_temporary(_Hp, _Tp);223#else224 return true;225#endif226 }227 228 _LIBCUDACXX_INLINE_VISIBILITY __tuple_leaf &operator=(const __tuple_leaf &);229 230public:231 _LIBCUDACXX_INLINE_VISIBILITY constexpr __tuple_leaf() noexcept(232 _LIBCUDACXX_TRAIT(is_nothrow_default_constructible, _Hp))233 : __value_() {234 static_assert(235 !_LIBCUDACXX_TRAIT(is_reference, _Hp),236 "Attempted to default construct a reference element in a tuple");237 }238 239 _LIBCUDACXX_INLINE_VISIBILITY constexpr __tuple_leaf(240 __tuple_leaf_default_constructor_tag) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_default_constructible,241 _Hp))242 : __value_() {243 static_assert(244 !_LIBCUDACXX_TRAIT(is_reference, _Hp),245 "Attempted to default construct a reference element in a tuple");246 }247 248 template <class _Alloc>249 _LIBCUDACXX_INLINE_VISIBILITY __tuple_leaf(integral_constant<int, 0>,250 const _Alloc &)251 : __value_() {252 static_assert(253 !_LIBCUDACXX_TRAIT(is_reference, _Hp),254 "Attempted to default construct a reference element in a tuple");255 }256 257 template <class _Alloc>258 _LIBCUDACXX_INLINE_VISIBILITY __tuple_leaf(integral_constant<int, 1>,259 const _Alloc &__a)260 : __value_(allocator_arg_t(), __a) {261 static_assert(262 !_LIBCUDACXX_TRAIT(is_reference, _Hp),263 "Attempted to default construct a reference element in a tuple");264 }265 266 template <class _Alloc>267 _LIBCUDACXX_INLINE_VISIBILITY __tuple_leaf(integral_constant<int, 2>,268 const _Alloc &__a)269 : __value_(__a) {270 static_assert(271 !_LIBCUDACXX_TRAIT(is_reference, _Hp),272 "Attempted to default construct a reference element in a tuple");273 }274 275 template <class _Tp>276 using __can_forward = _And<_IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>,277 is_constructible<_Hp, _Tp>>;278 279 template <class _Tp, __enable_if_t<__can_forward<_Tp>::value, int> = 0>280 _LIBCUDACXX_INLINE_VISIBILITY281 _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(282 _Tp &&__t) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Hp,283 _Tp))284 : __value_(_CUDA_VSTD::forward<_Tp>(__t)) {285 static_assert(__can_bind_reference<_Tp &&>(),286 "Attempted construction of reference element binds to a "287 "temporary whose lifetime has ended");288 }289 290 template <class _Tp, class _Alloc>291 _LIBCUDACXX_INLINE_VISIBILITY explicit __tuple_leaf(integral_constant<int, 0>,292 const _Alloc &, _Tp &&__t)293 : __value_(_CUDA_VSTD::forward<_Tp>(__t)) {294 static_assert(__can_bind_reference<_Tp &&>(),295 "Attempted construction of reference element binds to a "296 "temporary whose lifetime has ended");297 }298 299 template <class _Tp, class _Alloc>300 _LIBCUDACXX_INLINE_VISIBILITY explicit __tuple_leaf(integral_constant<int, 1>,301 const _Alloc &__a,302 _Tp &&__t)303 : __value_(allocator_arg_t(), __a, _CUDA_VSTD::forward<_Tp>(__t)) {304 static_assert(305 !_LIBCUDACXX_TRAIT(is_reference, _Hp),306 "Attempted to uses-allocator construct a reference element in a tuple");307 }308 309 template <class _Tp, class _Alloc>310 _LIBCUDACXX_INLINE_VISIBILITY explicit __tuple_leaf(integral_constant<int, 2>,311 const _Alloc &__a,312 _Tp &&__t)313 : __value_(_CUDA_VSTD::forward<_Tp>(__t), __a) {314 static_assert(315 !_LIBCUDACXX_TRAIT(is_reference, _Hp),316 "Attempted to uses-allocator construct a reference element in a tuple");317 }318 319 __tuple_leaf(const __tuple_leaf &__t) = default;320 __tuple_leaf(__tuple_leaf &&__t) = default;321 322 template <class _Tp>323 _LIBCUDACXX_INLINE_VISIBILITY __tuple_leaf &operator=(_Tp &&__t) noexcept(324 _LIBCUDACXX_TRAIT(is_nothrow_assignable, _Hp &, _Tp)) {325 __value_ = _CUDA_VSTD::forward<_Tp>(__t);326 return *this;327 }328 329 _LIBCUDACXX_INLINE_VISIBILITY int swap(__tuple_leaf &__t) noexcept(330 __is_nothrow_swappable<__tuple_leaf>::value) {331 _CUDA_VSTD::swap(*this, __t);332 return 0;333 }334 335 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 _Hp &336 get() noexcept {337 return __value_;338 }339 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 const _Hp &340 get() const noexcept {341 return __value_;342 }343};344 345template <size_t _Ip, class _Hp>346class __tuple_leaf<_Ip, _Hp, true> : private _Hp {347 _LIBCUDACXX_INLINE_VISIBILITY __tuple_leaf &operator=(const __tuple_leaf &);348 349public:350 _LIBCUDACXX_INLINE_VISIBILITY constexpr __tuple_leaf() noexcept(351 is_nothrow_default_constructible<_Hp>::value) {}352 353 _LIBCUDACXX_INLINE_VISIBILITY constexpr __tuple_leaf(354 __tuple_leaf_default_constructor_tag) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_default_constructible,355 _Hp))356 : _Hp() {}357 358 template <class _Alloc>359 _LIBCUDACXX_INLINE_VISIBILITY __tuple_leaf(integral_constant<int, 0>,360 const _Alloc &) {}361 362 template <class _Alloc>363 _LIBCUDACXX_INLINE_VISIBILITY __tuple_leaf(integral_constant<int, 1>,364 const _Alloc &__a)365 : _Hp(allocator_arg_t(), __a) {}366 367 template <class _Alloc>368 _LIBCUDACXX_INLINE_VISIBILITY __tuple_leaf(integral_constant<int, 2>,369 const _Alloc &__a)370 : _Hp(__a) {}371 372 template <class _Tp>373 using __can_forward = _And<_IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>,374 is_constructible<_Hp, _Tp>>;375 376 template <class _Tp, __enable_if_t<__can_forward<_Tp>::value, int> = 0>377 _LIBCUDACXX_INLINE_VISIBILITY378 _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 explicit __tuple_leaf(379 _Tp &&__t) noexcept((is_nothrow_constructible<_Hp, _Tp>::value))380 : _Hp(_CUDA_VSTD::forward<_Tp>(__t)) {}381 382 template <class _Tp, class _Alloc>383 _LIBCUDACXX_INLINE_VISIBILITY explicit __tuple_leaf(integral_constant<int, 0>,384 const _Alloc &, _Tp &&__t)385 : _Hp(_CUDA_VSTD::forward<_Tp>(__t)) {}386 387 template <class _Tp, class _Alloc>388 _LIBCUDACXX_INLINE_VISIBILITY explicit __tuple_leaf(integral_constant<int, 1>,389 const _Alloc &__a,390 _Tp &&__t)391 : _Hp(allocator_arg_t(), __a, _CUDA_VSTD::forward<_Tp>(__t)) {}392 393 template <class _Tp, class _Alloc>394 _LIBCUDACXX_INLINE_VISIBILITY explicit __tuple_leaf(integral_constant<int, 2>,395 const _Alloc &__a,396 _Tp &&__t)397 : _Hp(_CUDA_VSTD::forward<_Tp>(__t), __a) {}398 399 __tuple_leaf(__tuple_leaf const &) = default;400 __tuple_leaf(__tuple_leaf &&) = default;401 402 template <class _Tp>403 _LIBCUDACXX_INLINE_VISIBILITY __tuple_leaf &operator=(_Tp &&__t) noexcept(404 _LIBCUDACXX_TRAIT(is_nothrow_assignable, _Hp &, _Tp)) {405 _Hp::operator=(_CUDA_VSTD::forward<_Tp>(__t));406 return *this;407 }408 409 _LIBCUDACXX_INLINE_VISIBILITY int swap(__tuple_leaf &__t) noexcept(410 __is_nothrow_swappable<__tuple_leaf>::value) {411 _CUDA_VSTD::swap(*this, __t);412 return 0;413 }414 415 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 _Hp &416 get() noexcept {417 return static_cast<_Hp &>(*this);418 }419 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 const _Hp &420 get() const noexcept {421 return static_cast<const _Hp &>(*this);422 }423};424 425template <class... _Tp>426_LIBCUDACXX_INLINE_VISIBILITY void __swallow(_Tp &&...) noexcept {}427 428template <class _Tp> struct __all_default_constructible;429 430template <class... _Tp>431struct __all_default_constructible<__tuple_types<_Tp...>>432 : __all<_LIBCUDACXX_TRAIT(is_default_constructible, _Tp)...> {};433 434struct __tuple_variadic_constructor_tag {};435 436// __tuple_impl437 438template <class _Indx, class... _Tp> struct __tuple_impl;439 440template <size_t... _Indx, class... _Tp>441struct _LIBCUDACXX_DECLSPEC_EMPTY_BASES442 __tuple_impl<__tuple_indices<_Indx...>, _Tp...>443 : public __tuple_leaf<_Indx, _Tp>... {444 _LIBCUDACXX_INLINE_VISIBILITY constexpr __tuple_impl() noexcept(445 __all<_LIBCUDACXX_TRAIT(is_nothrow_default_constructible,446 _Tp)...>::value) {}447 448 // Handle non-allocator, full initialization449 // Old MSVC cannot handle the noexept specifier outside of template arguments450 template <class... _Up,451 __enable_if_t<sizeof...(_Up) == sizeof...(_Tp), int> = 0,452 bool __all_nothrow_constructible = __all<_LIBCUDACXX_TRAIT(453 is_nothrow_constructible, _Tp, _Up)...>::value>454 _LIBCUDACXX_INLINE_VISIBILITY455 _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 explicit __tuple_impl(456 __tuple_variadic_constructor_tag,457 _Up &&...__u) noexcept(__all_nothrow_constructible)458 : __tuple_leaf<_Indx, _Tp>(_CUDA_VSTD::forward<_Up>(__u))... {}459 460 // Handle non-allocator, partial default initialization461 // Recursively delegate until we have full rank462 template <class... _Up,463 __enable_if_t<sizeof...(_Up) < sizeof...(_Tp), int> = 0>464 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 explicit __tuple_impl(465 __tuple_variadic_constructor_tag __tag,466 _Up &&...__u) noexcept(noexcept(__tuple_impl(__tag,467 _CUDA_VSTD::forward<_Up>(468 __u)...,469 __tuple_leaf_default_constructor_tag{})))470 : __tuple_impl(__tag, _CUDA_VSTD::forward<_Up>(__u)...,471 __tuple_leaf_default_constructor_tag{}) {}472 473 // Handle allocator aware, full initialization474 template <class _Alloc, class... _Up,475 __enable_if_t<sizeof...(_Up) == sizeof...(_Tp), int> = 0>476 _LIBCUDACXX_INLINE_VISIBILITY explicit __tuple_impl(477 allocator_arg_t, const _Alloc &__a, __tuple_variadic_constructor_tag,478 _Up &&...__u)479 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, _Up>(), __a,480 _CUDA_VSTD::forward<_Up>(__u))... {}481 482 // Handle allocator aware, full default initialization483 template <class _Alloc>484 _LIBCUDACXX_INLINE_VISIBILITY explicit __tuple_impl(allocator_arg_t,485 const _Alloc &__a)486 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc>(), __a)... {}487 488 template <class _Tuple, size_t _Indx2>489 using __tuple_elem_at =490 __tuple_element_t<_Indx2, __make_tuple_types_t<_Tuple>>;491 492 template <class _Tuple,493 __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...>>::value,494 int> = 0>495 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11496 __tuple_impl(_Tuple &&__t) noexcept(497 (__all<_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp,498 __tuple_elem_at<_Tuple, _Indx>)...>::value))499 : __tuple_leaf<_Indx, _Tp>(500 _CUDA_VSTD::forward<__tuple_elem_at<_Tuple, _Indx>>(501 _CUDA_VSTD::get<_Indx>(__t)))... {}502 503 template <class _Alloc, class _Tuple,504 __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...>>::value,505 int> = 0>506 _LIBCUDACXX_INLINE_VISIBILITY __tuple_impl(allocator_arg_t, const _Alloc &__a,507 _Tuple &&__t)508 : __tuple_leaf<_Indx, _Tp>(509 __uses_alloc_ctor<_Tp, _Alloc, __tuple_elem_at<_Tuple, _Indx>>(),510 __a,511 _CUDA_VSTD::forward<__tuple_elem_at<_Tuple, _Indx>>(512 _CUDA_VSTD::get<_Indx>(__t)))... {}513 514 template <515 class _Tuple,516 __enable_if_t<__tuple_assignable<_Tuple, tuple<_Tp...>>::value, int> = 0>517 _LIBCUDACXX_INLINE_VISIBILITY __tuple_impl &operator=(_Tuple &&__t) noexcept(518 (__all<_LIBCUDACXX_TRAIT(is_nothrow_assignable, _Tp &,519 __tuple_elem_at<_Tuple, _Indx>)...>::value)) {520 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(521 _CUDA_VSTD::forward<__tuple_elem_at<_Tuple, _Indx>>(522 _CUDA_VSTD::get<_Indx>(__t)))...);523 return *this;524 }525 526 __tuple_impl(const __tuple_impl &) = default;527 __tuple_impl(__tuple_impl &&) = default;528 529 _LIBCUDACXX_INLINE_VISIBILITY __tuple_impl &530 operator=(const __tuple_impl &__t) noexcept(531 (__all<_LIBCUDACXX_TRAIT(is_nothrow_copy_assignable, _Tp)...>::value)) {532 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(533 static_cast<const __tuple_leaf<_Indx, _Tp> &>(__t).get())...);534 return *this;535 }536 537 _LIBCUDACXX_INLINE_VISIBILITY __tuple_impl &538 operator=(__tuple_impl &&__t) noexcept(539 (__all<_LIBCUDACXX_TRAIT(is_nothrow_move_assignable, _Tp)...>::value)) {540 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_CUDA_VSTD::forward<_Tp>(541 static_cast<__tuple_leaf<_Indx, _Tp> &>(__t).get()))...);542 return *this;543 }544 545 _LIBCUDACXX_INLINE_VISIBILITY void swap(__tuple_impl &__t) noexcept(546 __all<__is_nothrow_swappable<_Tp>::value...>::value) {547 __swallow(__tuple_leaf<_Indx, _Tp>::swap(548 static_cast<__tuple_leaf<_Indx, _Tp> &>(__t))...);549 }550};551 552struct __invalid_tuple_constraints {553 static constexpr bool __implicit_constructible = false;554 static constexpr bool __explicit_constructible = false;555 static constexpr bool __nothrow_constructible = false;556};557 558template <class... _Tp> struct __tuple_constraints {559 static constexpr bool __implicit_default_constructible =560 __all<__is_implicitly_default_constructible<_Tp>::value...>::value;561 562 static constexpr bool __explicit_default_constructible =563 !__implicit_default_constructible &&564 __all<_LIBCUDACXX_TRAIT(is_default_constructible, _Tp)...>::value;565 566 static constexpr bool __nothrow_default_constructible =567 __all<_LIBCUDACXX_TRAIT(is_nothrow_default_constructible, _Tp)...>::value;568 569 static constexpr bool __implicit_variadic_copy_constructible =570 __tuple_constructible<tuple<const _Tp &...>, tuple<_Tp...>>::value &&571 __tuple_convertible<tuple<const _Tp &...>, tuple<_Tp...>>::value;572 573 static constexpr bool __explicit_variadic_copy_constructible =574 __tuple_constructible<tuple<const _Tp &...>, tuple<_Tp...>>::value &&575 !__tuple_convertible<tuple<const _Tp &...>, tuple<_Tp...>>::value;576 577 static constexpr bool __nothrow_variadic_copy_constructible =578 __all<_LIBCUDACXX_TRAIT(is_nothrow_copy_constructible, _Tp)...>::value;579 580 template <class... _Args> struct _PackExpandsToThisTuple : false_type {};581 582 template <class _Arg>583 struct _PackExpandsToThisTuple<_Arg>584 : is_same<__remove_cvref_t<_Arg>, tuple<_Tp...>> {};585 586 template <class... _Args> struct __variadic_constraints {587 static constexpr bool __implicit_constructible =588 __tuple_constructible<tuple<_Args...>, tuple<_Tp...>>::value &&589 __tuple_convertible<tuple<_Args...>, tuple<_Tp...>>::value;590 591 static constexpr bool __explicit_constructible =592 __tuple_constructible<tuple<_Args...>, tuple<_Tp...>>::value &&593 !__tuple_convertible<tuple<_Args...>, tuple<_Tp...>>::value;594 595 static constexpr bool __nothrow_constructible = __all<_LIBCUDACXX_TRAIT(596 is_nothrow_constructible, _Tp, _Args)...>::value;597 };598 599 template <class... _Args> struct __variadic_constraints_less_rank {600 static constexpr bool __implicit_constructible =601 __tuple_constructible<602 tuple<_Args...>,603 __make_tuple_types_t<tuple<_Tp...>, sizeof...(_Args)>>::value &&604 __tuple_convertible<605 tuple<_Args...>,606 __make_tuple_types_t<tuple<_Tp...>, sizeof...(_Args)>>::value &&607 __all_default_constructible<__make_tuple_types_t<608 tuple<_Tp...>, sizeof...(_Tp), sizeof...(_Args)>>::value;609 610 static constexpr bool __explicit_constructible =611 __tuple_constructible<612 tuple<_Args...>,613 __make_tuple_types_t<tuple<_Tp...>, sizeof...(_Args)>>::value &&614 !__tuple_convertible<615 tuple<_Args...>,616 __make_tuple_types_t<tuple<_Tp...>, sizeof...(_Args)>>::value &&617 __all_default_constructible<__make_tuple_types_t<618 tuple<_Tp...>, sizeof...(_Tp), sizeof...(_Args)>>::value;619 };620 621 template <class _Tuple> struct __valid_tuple_like_constraints {622 static constexpr bool __implicit_constructible =623 __tuple_constructible<_Tuple, tuple<_Tp...>>::value &&624 __tuple_convertible<_Tuple, tuple<_Tp...>>::value;625 626 static constexpr bool __explicit_constructible =627 __tuple_constructible<_Tuple, tuple<_Tp...>>::value &&628 !__tuple_convertible<_Tuple, tuple<_Tp...>>::value;629 };630 631 template <class _Tuple> struct __valid_tuple_like_constraints_rank_one {632 template <class _Tuple2>633 struct _PreferTupleLikeConstructorImpl634 : _Or<635 // Don't attempt the two checks below if the tuple we are given636 // has the same type as this tuple.637 _IsSame<__remove_cvref_t<_Tuple2>, tuple<_Tp...>>,638 _Lazy<_And, _Not<is_constructible<_Tp..., _Tuple2>>,639 _Not<is_convertible<_Tuple2, _Tp...>>>> {};640 641 // This trait is used to disable the tuple-like constructor when642 // the UTypes... constructor should be selected instead.643 // See LWG issue #2549.644 template <class _Tuple2>645 using _PreferTupleLikeConstructor =646 _PreferTupleLikeConstructorImpl<_Tuple2>;647 648 static constexpr bool __implicit_constructible =649 __tuple_constructible<_Tuple, tuple<_Tp...>>::value &&650 __tuple_convertible<_Tuple, tuple<_Tp...>>::value &&651 _PreferTupleLikeConstructor<_Tuple>::value;652 653 static constexpr bool __explicit_constructible =654 __tuple_constructible<_Tuple, tuple<_Tp...>>::value &&655 !__tuple_convertible<_Tuple, tuple<_Tp...>>::value &&656 _PreferTupleLikeConstructor<_Tuple>::value;657 };658 659 template <class _Tuple>660 using __tuple_like_constraints =661 _If<sizeof...(_Tp) == 1, __valid_tuple_like_constraints_rank_one<_Tuple>,662 __valid_tuple_like_constraints<_Tuple>>;663};664 665template <class... _Tp> class _LIBCUDACXX_TEMPLATE_VIS tuple {666 typedef __tuple_impl<__make_tuple_indices_t<sizeof...(_Tp)>, _Tp...> _BaseT;667 668 _BaseT __base_;669 670 template <class... _Args> struct _PackExpandsToThisTuple : false_type {};671 672 template <class _Arg>673 struct _PackExpandsToThisTuple<_Arg>674 : is_same<__remove_cvref_t<_Arg>, tuple> {};675 676public:677 template <size_t _Ip>678 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 __tuple_element_t<_Ip, tuple>&679 __get_impl() & noexcept680 {681 typedef _LIBCUDACXX_NODEBUG_TYPE __tuple_element_t<_Ip, tuple> type;682 return static_cast<__tuple_leaf<_Ip, type>&>(__base_).get();683 }684 685 template <size_t _Ip>686 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 const __tuple_element_t<_Ip, tuple>&687 __get_impl() const& noexcept688 {689 typedef _LIBCUDACXX_NODEBUG_TYPE __tuple_element_t<_Ip, tuple> type;690 return static_cast<const __tuple_leaf<_Ip, type>&>(__base_).get();691 }692 693 template <size_t _Ip>694 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 __tuple_element_t<_Ip, tuple>&&695 __get_impl() && noexcept696 {697 typedef _LIBCUDACXX_NODEBUG_TYPE __tuple_element_t<_Ip, tuple> type;698 return static_cast<type&&>(static_cast<__tuple_leaf<_Ip, type>&&>(__base_).get());699 }700 701 template <size_t _Ip>702 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 const __tuple_element_t<_Ip, tuple>&&703 __get_impl() const&& noexcept704 {705 typedef _LIBCUDACXX_NODEBUG_TYPE __tuple_element_t<_Ip, tuple> type;706 return static_cast<const type&&>(static_cast<const __tuple_leaf<_Ip, type>&&>(__base_).get());707 }708 709 template < class _Constraints = __tuple_constraints<_Tp...>,710 __enable_if_t<_Constraints::__implicit_default_constructible, int> = 0>711 _LIBCUDACXX_INLINE_VISIBILITY constexpr tuple() noexcept(712 _Constraints::__nothrow_default_constructible) {}713 714 template <715 class _Constraints = __tuple_constraints<_Tp...>,716 __enable_if_t<_Constraints::__explicit_default_constructible, int> = 0>717 _LIBCUDACXX_INLINE_VISIBILITY explicit constexpr tuple() noexcept(718 _Constraints::__nothrow_default_constructible) {}719 720 tuple(tuple const &) = default;721 tuple(tuple &&) = default;722 723 template <724 class _AllocArgT, class _Alloc,725 class _Constraints = __tuple_constraints<_Tp...>,726 __enable_if_t<_LIBCUDACXX_TRAIT(is_same, allocator_arg_t, _AllocArgT),727 int> = 0,728 __enable_if_t<_Constraints::__implicit_default_constructible, int> = 0>729 _LIBCUDACXX_INLINE_VISIBILITY tuple(_AllocArgT, _Alloc const &__a) noexcept(730 _Constraints::__nothrow_default_constructible)731 : __base_(allocator_arg_t(), __a) {}732 733 template <734 class _AllocArgT, class _Alloc,735 class _Constraints = __tuple_constraints<_Tp...>,736 __enable_if_t<_LIBCUDACXX_TRAIT(is_same, allocator_arg_t, _AllocArgT),737 int> = 0,738 __enable_if_t<_Constraints::__explicit_default_constructible, int> = 0>739 explicit _LIBCUDACXX_INLINE_VISIBILITY tuple(740 _AllocArgT,741 _Alloc const &__a) noexcept(_Constraints::__nothrow_default_constructible)742 : __base_(allocator_arg_t(), __a) {}743 744 template <class _Constraints = __tuple_constraints<_Tp...>,745 __enable_if_t<_Constraints::__implicit_variadic_copy_constructible,746 int> = 0>747 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11748 tuple(const _Tp &...__t) noexcept(749 _Constraints::__nothrow_variadic_copy_constructible)750 : __base_(__tuple_variadic_constructor_tag{}, __t...) {}751 752 template <class _Constraints = __tuple_constraints<_Tp...>,753 __enable_if_t<_Constraints::__explicit_variadic_copy_constructible,754 int> = 0>755 _LIBCUDACXX_INLINE_VISIBILITY756 _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 explicit tuple(757 const _Tp &...__t) noexcept(_Constraints::758 __nothrow_variadic_copy_constructible)759 : __base_(__tuple_variadic_constructor_tag{}, __t...) {}760 761 template <class _Alloc, class _Constraints = __tuple_constraints<_Tp...>,762 __enable_if_t<_Constraints::__implicit_variadic_copy_constructible,763 int> = 0>764 _LIBCUDACXX_INLINE_VISIBILITY765 tuple(allocator_arg_t, const _Alloc &__a, const _Tp &...__t) noexcept(766 _Constraints::__nothrow_variadic_copy_constructible)767 : __base_(allocator_arg_t(), __a, __tuple_variadic_constructor_tag{},768 __t...) {}769 770 template <class _Alloc, class _Constraints = __tuple_constraints<_Tp...>,771 __enable_if_t<_Constraints::__explicit_variadic_copy_constructible,772 int> = 0>773 _LIBCUDACXX_INLINE_VISIBILITY explicit tuple(774 allocator_arg_t, const _Alloc &__a,775 const _Tp776 &...__t) noexcept(_Constraints::__nothrow_variadic_copy_constructible)777 : __base_(allocator_arg_t(), __a, __tuple_variadic_constructor_tag{},778 __t...) {}779 780#if defined(_LIBCUDACXX_NO_TUPLE_NOEXCEPT)781 template <class... _Vp> using __base_noexcept_constructible = false_type;782#else783 template <class... _Vp>784 using __base_noexcept_constructible =785 is_nothrow_constructible<_BaseT, _Vp...>;786#endif // defined(_LIBCUDACXX_NO_TUPLE_NOEXCEPT)787 788 template <class... _Up>789 using __variadic_constraints =790 _If<!_PackExpandsToThisTuple<_Up...>::value &&791 sizeof...(_Up) == sizeof...(_Tp),792 typename __tuple_constraints<_Tp...>::template __variadic_constraints<793 _Up...>,794 __invalid_tuple_constraints>;795 796 template <class... _Up, class _Constraints = __variadic_constraints<_Up...>,797 __enable_if_t<_Constraints::__implicit_constructible, int> = 0>798 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11799 tuple(_Up &&...__u) noexcept(_Constraints::__nothrow_constructible)800 : __base_(__tuple_variadic_constructor_tag{},801 _CUDA_VSTD::forward<_Up>(__u)...) {}802 803 template <class... _Up, class _Constraints = __variadic_constraints<_Up...>,804 __enable_if_t<_Constraints::__explicit_constructible, int> = 0>805 _LIBCUDACXX_INLINE_VISIBILITY806 _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 explicit tuple(_Up &&...__u) noexcept(807 _Constraints::__nothrow_constructible)808 : __base_(__tuple_variadic_constructor_tag{},809 _CUDA_VSTD::forward<_Up>(__u)...) {}810 811 template <class... _Up>812 using __variadic_constraints_less_rank =813 _If<!_PackExpandsToThisTuple<_Up...>::value,814 typename __tuple_constraints<815 _Tp...>::template __variadic_constraints_less_rank<_Up...>,816 __invalid_tuple_constraints>;817 818 template <class... _Up,819 class _Constraints = __variadic_constraints_less_rank<_Up...>,820 __enable_if_t<sizeof...(_Up) < sizeof...(_Tp), int> = 0,821 __enable_if_t<_Constraints::__implicit_constructible, int> = 0>822 _LIBCUDACXX_INLINE_VISIBILITY823 _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 explicit tuple(_Up &&...__u) noexcept(824 __base_noexcept_constructible<__tuple_variadic_constructor_tag,825 _Up...>::value)826 : __base_(__tuple_variadic_constructor_tag{},827 _CUDA_VSTD::forward<_Up>(__u)...) {}828 829 template <class _Alloc, class... _Up,830 class _Constraints = __variadic_constraints<_Up...>,831 __enable_if_t<_Constraints::__implicit_constructible, int> = 0>832 _LIBCUDACXX_INLINE_VISIBILITY833 tuple(allocator_arg_t, const _Alloc &__a,834 _Up &&...__u) noexcept(_Constraints::__nothrow_constructible)835 : __base_(allocator_arg_t(), __a, __tuple_variadic_constructor_tag{},836 _CUDA_VSTD::forward<_Up>(__u)...) {}837 838 template <class _Alloc, class... _Up,839 class _Constraints = __variadic_constraints<_Up...>,840 __enable_if_t<_Constraints::__explicit_constructible, int> = 0>841 _LIBCUDACXX_INLINE_VISIBILITY explicit tuple(842 allocator_arg_t, const _Alloc &__a,843 _Up &&...__u) noexcept(_Constraints::__nothrow_constructible)844 : __base_(allocator_arg_t(), __a, __tuple_variadic_constructor_tag{},845 _CUDA_VSTD::forward<_Up>(__u)...) {}846 847 template <class _Tuple>848 using __tuple_like_constraints =849 _If<__tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value,850 typename __tuple_constraints<851 _Tp...>::template __tuple_like_constraints<_Tuple>,852 __invalid_tuple_constraints>;853 854 template <855 class _Tuple, class _Constraints = __tuple_like_constraints<_Tuple>,856 __enable_if_t<!_PackExpandsToThisTuple<_Tuple>::value, int> = 0,857 __enable_if_t<!_LIBCUDACXX_TRAIT(is_lvalue_reference, _Tuple), int> = 0,858 __enable_if_t<_Constraints::__implicit_constructible, int> = 0>859 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11860 tuple(_Tuple &&__t) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible,861 _BaseT, _Tuple))862 : __base_(_CUDA_VSTD::forward<_Tuple>(__t)) {}863 864 template <class _Tuple,865 class _Constraints = __tuple_like_constraints<const _Tuple &>,866 __enable_if_t<!_PackExpandsToThisTuple<_Tuple>::value, int> = 0,867 __enable_if_t<_Constraints::__implicit_constructible, int> = 0>868 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11869 tuple(const _Tuple &__t) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible,870 _BaseT, const _Tuple &))871 : __base_(__t) {}872 873 template <874 class _Tuple, class _Constraints = __tuple_like_constraints<_Tuple>,875 __enable_if_t<!_PackExpandsToThisTuple<_Tuple>::value, int> = 0,876 __enable_if_t<!_LIBCUDACXX_TRAIT(is_lvalue_reference, _Tuple), int> = 0,877 __enable_if_t<_Constraints::__explicit_constructible, int> = 0>878 _LIBCUDACXX_INLINE_VISIBILITY879 _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 explicit tuple(_Tuple &&__t) noexcept(880 _LIBCUDACXX_TRAIT(is_nothrow_constructible, _BaseT, _Tuple))881 : __base_(_CUDA_VSTD::forward<_Tuple>(__t)) {}882 883 template <class _Tuple,884 class _Constraints = __tuple_like_constraints<const _Tuple &>,885 __enable_if_t<!_PackExpandsToThisTuple<_Tuple>::value, int> = 0,886 __enable_if_t<_Constraints::__explicit_constructible, int> = 0>887 _LIBCUDACXX_INLINE_VISIBILITY888 _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 explicit tuple(889 const _Tuple890 &__t) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _BaseT,891 const _Tuple &))892 : __base_(__t) {}893 894 template <class _Alloc, class _Tuple,895 class _Constraints = __tuple_like_constraints<_Tuple>,896 __enable_if_t<_Constraints::__implicit_constructible, int> = 0>897 _LIBCUDACXX_INLINE_VISIBILITY tuple(allocator_arg_t, const _Alloc &__a,898 _Tuple &&__t)899 : __base_(allocator_arg_t(), __a, _CUDA_VSTD::forward<_Tuple>(__t)) {}900 901 template <class _Alloc, class _Tuple,902 class _Constraints = __tuple_like_constraints<_Tuple>,903 __enable_if_t<_Constraints::__explicit_constructible, int> = 0>904 _LIBCUDACXX_INLINE_VISIBILITY explicit tuple(allocator_arg_t,905 const _Alloc &__a, _Tuple &&__t)906 : __base_(allocator_arg_t(), __a, _CUDA_VSTD::forward<_Tuple>(__t)) {}907 908 using _CanCopyAssign = __all<_LIBCUDACXX_TRAIT(is_copy_assignable, _Tp)...>;909 using _CanMoveAssign = __all<_LIBCUDACXX_TRAIT(is_move_assignable, _Tp)...>;910 911 _LIBCUDACXX_INLINE_VISIBILITY tuple &operator=(912 __conditional_t<_CanCopyAssign::value, tuple, __nat> const913 &__t) noexcept((__all<_LIBCUDACXX_TRAIT(is_nothrow_copy_assignable,914 _Tp)...>::value)) {915 __base_.operator=(__t.__base_);916 return *this;917 }918 919 _LIBCUDACXX_INLINE_VISIBILITY tuple &operator=(920 __conditional_t<_CanMoveAssign::value, tuple, __nat>921 &&__t) noexcept((__all<_LIBCUDACXX_TRAIT(is_nothrow_move_assignable,922 _Tp)...>::value)) {923 __base_.operator=(static_cast<_BaseT &&>(__t.__base_));924 return *this;925 }926 927 template <928 class _Tuple,929 __enable_if_t<__tuple_assignable<_Tuple, tuple>::value, bool> = false>930 _LIBCUDACXX_INLINE_VISIBILITY tuple &operator=(_Tuple &&__t) noexcept(931 _LIBCUDACXX_TRAIT(is_nothrow_assignable, _BaseT &, _Tuple)) {932 __base_.operator=(_CUDA_VSTD::forward<_Tuple>(__t));933 return *this;934 }935 936 _LIBCUDACXX_INLINE_VISIBILITY void swap(tuple &__t) noexcept(937 __all<__is_nothrow_swappable<_Tp>::value...>::value) {938 __base_.swap(__t.__base_);939 }940};941 942template <> class _LIBCUDACXX_TEMPLATE_VIS tuple<> {943public:944 constexpr tuple() noexcept = default;945 template <class _Alloc>946 _LIBCUDACXX_INLINE_VISIBILITY tuple(allocator_arg_t,947 const _Alloc &) noexcept {}948 template <class _Alloc>949 _LIBCUDACXX_INLINE_VISIBILITY tuple(allocator_arg_t, const _Alloc &,950 const tuple &) noexcept {}951 template <class _Up>952 _LIBCUDACXX_INLINE_VISIBILITY tuple(array<_Up, 0>) noexcept {}953 template <class _Alloc, class _Up>954 _LIBCUDACXX_INLINE_VISIBILITY tuple(allocator_arg_t, const _Alloc &,955 array<_Up, 0>) noexcept {}956 _LIBCUDACXX_INLINE_VISIBILITY void swap(tuple &) noexcept {}957};958 959#ifndef _LIBCUDACXX_HAS_NO_DEDUCTION_GUIDES960template <class... _Tp> _LIBCUDACXX_HOST_DEVICE tuple(_Tp...) -> tuple<_Tp...>;961template <class _Tp1, class _Tp2>962_LIBCUDACXX_HOST_DEVICE tuple(pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;963template <class _Alloc, class... _Tp>964_LIBCUDACXX_HOST_DEVICE tuple(allocator_arg_t, _Alloc, _Tp...) -> tuple<_Tp...>;965template <class _Alloc, class _Tp1, class _Tp2>966_LIBCUDACXX_HOST_DEVICE tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>)967 -> tuple<_Tp1, _Tp2>;968template <class _Alloc, class... _Tp>969_LIBCUDACXX_HOST_DEVICE tuple(allocator_arg_t, _Alloc, tuple<_Tp...>)970 -> tuple<_Tp...>;971#endif // _LIBCUDACXX_HAS_NO_DEDUCTION_GUIDES972 973template <class... _Tp>974inline _LIBCUDACXX_INLINE_VISIBILITY975 __enable_if_t<_And<__is_swappable<_Tp>...>::value, void>976 swap(tuple<_Tp...> &__t, tuple<_Tp...> &__u) noexcept(977 __all<__is_nothrow_swappable<_Tp>::value...>::value) {978 __t.swap(__u);979}980 981// get982template <size_t _Ip, class... _Tp>983inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 __tuple_element_t<_Ip, tuple<_Tp...>>&984get(tuple<_Tp...>& __t) noexcept985{986 return __t.template __get_impl<_Ip>();987}988 989template <size_t _Ip, class... _Tp>990inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 const __tuple_element_t<_Ip, tuple<_Tp...>>&991get(const tuple<_Tp...>& __t) noexcept992{993 return __t.template __get_impl<_Ip>();994}995 996template <size_t _Ip, class... _Tp>997inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 __tuple_element_t<_Ip, tuple<_Tp...>>&&998get(tuple<_Tp...>&& __t) noexcept999{1000 return _CUDA_VSTD::move(__t).template __get_impl<_Ip>();1001}1002 1003template <size_t _Ip, class... _Tp>1004inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 const __tuple_element_t<_Ip, tuple<_Tp...>>&&1005get(const tuple<_Tp...>&& __t) noexcept1006{1007 return _CUDA_VSTD::move(__t).template __get_impl<_Ip>();1008}1009 1010#if _LIBCUDACXX_STD_VER > 111011 1012namespace __find_detail {1013 1014static constexpr size_t __not_found = ~size_t(0);1015static constexpr size_t __ambiguous = __not_found - 1;1016 1017inline _LIBCUDACXX_INLINE_VISIBILITY constexpr size_t1018__find_idx_return(size_t __curr_i, size_t __res, bool __matches) {1019 return !__matches ? __res : (__res == __not_found ? __curr_i : __ambiguous);1020}1021 1022template <size_t _Nx>1023inline _LIBCUDACXX_INLINE_VISIBILITY constexpr size_t1024__find_idx(size_t __i, const bool (&__matches)[_Nx]) {1025 return __i == _Nx ? __not_found1026 : __find_idx_return(__i, __find_idx(__i + 1, __matches),1027 __matches[__i]);1028}1029 1030template <class _T1, class... _Args> struct __find_exactly_one_checked {1031 static constexpr bool __matches[sizeof...(_Args)] = {1032 is_same<_T1, _Args>::value...};1033 static constexpr size_t value = __find_detail::__find_idx(0, __matches);1034 static_assert(value != __not_found, "type not found in type list");1035 static_assert(value != __ambiguous,1036 "type occurs more than once in type list");1037};1038 1039template <class _T1> struct __find_exactly_one_checked<_T1> {1040 static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");1041};1042 1043} // namespace __find_detail1044 1045template <typename _T1, typename... _Args>1046struct __find_exactly_one_t1047 : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {};1048 1049template <class _T1, class... _Args>1050inline _LIBCUDACXX_INLINE_VISIBILITY constexpr _T1 &1051get(tuple<_Args...> &__tup) noexcept {1052 return _CUDA_VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);1053}1054 1055template <class _T1, class... _Args>1056inline _LIBCUDACXX_INLINE_VISIBILITY constexpr _T1 const &1057get(tuple<_Args...> const &__tup) noexcept {1058 return _CUDA_VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);1059}1060 1061template <class _T1, class... _Args>1062inline _LIBCUDACXX_INLINE_VISIBILITY constexpr _T1 &&1063get(tuple<_Args...> &&__tup) noexcept {1064 return _CUDA_VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(1065 _CUDA_VSTD::move(__tup));1066}1067 1068template <class _T1, class... _Args>1069inline _LIBCUDACXX_INLINE_VISIBILITY constexpr _T1 const &&1070get(tuple<_Args...> const &&__tup) noexcept {1071 return _CUDA_VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(1072 _CUDA_VSTD::move(__tup));1073}1074 1075#endif1076 1077// tie1078 1079template <class... _Tp>1080inline _LIBCUDACXX_INLINE_VISIBILITY1081 _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 tuple<_Tp &...>1082 tie(_Tp &...__t) noexcept {1083 return tuple<_Tp &...>(__t...);1084}1085 1086template <class _Up> struct __ignore_t {1087 template <class _Tp>1088 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 const1089 __ignore_t &1090 operator=(_Tp &&) const {1091 return *this;1092 }1093};1094 1095namespace {1096#ifdef __CUDA_ARCH__1097static1098#endif1099 _LIBCUDACXX_INLINE_VAR constexpr __ignore_t<unsigned char>1100 ignore = __ignore_t<unsigned char>();1101} // namespace1102 1103template <class... _Tp>1104inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX111105 tuple<typename __unwrap_ref_decay<_Tp>::type...>1106 make_tuple(_Tp &&...__t) {1107 return tuple<typename __unwrap_ref_decay<_Tp>::type...>(1108 _CUDA_VSTD::forward<_Tp>(__t)...);1109}1110 1111template <class... _Tp>1112inline _LIBCUDACXX_INLINE_VISIBILITY1113 _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 tuple<_Tp &&...>1114 forward_as_tuple(_Tp &&...__t) noexcept {1115 return tuple<_Tp &&...>(_CUDA_VSTD::forward<_Tp>(__t)...);1116}1117 1118template <size_t _Ip> struct __tuple_equal {1119 template <class _Tp, class _Up>1120 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 bool1121 operator()(const _Tp &__x, const _Up &__y) {1122 return __tuple_equal<_Ip - 1>()(__x, __y) &&1123 _CUDA_VSTD::get<_Ip - 1>(__x) == _CUDA_VSTD::get<_Ip - 1>(__y);1124 }1125};1126 1127template <> struct __tuple_equal<0> {1128 template <class _Tp, class _Up>1129 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 bool1130 operator()(const _Tp &, const _Up &) {1131 return true;1132 }1133};1134 1135template <class... _Tp, class... _Up>1136inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 bool1137operator==(const tuple<_Tp...> &__x, const tuple<_Up...> &__y) {1138 static_assert(sizeof...(_Tp) == sizeof...(_Up),1139 "Can't compare tuples of different sizes");1140 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);1141}1142 1143template <class... _Tp, class... _Up>1144inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 bool1145operator!=(const tuple<_Tp...> &__x, const tuple<_Up...> &__y) {1146 return !(__x == __y);1147}1148 1149template <size_t _Ip> struct __tuple_less {1150 template <class _Tp, class _Up>1151 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 bool1152 operator()(const _Tp &__x, const _Up &__y) {1153 const size_t __idx = tuple_size<_Tp>::value - _Ip;1154 if (_CUDA_VSTD::get<__idx>(__x) < _CUDA_VSTD::get<__idx>(__y)) {1155 return true;1156 }1157 if (_CUDA_VSTD::get<__idx>(__y) < _CUDA_VSTD::get<__idx>(__x)) {1158 return false;1159 }1160 return __tuple_less<_Ip - 1>()(__x, __y);1161 }1162};1163 1164template <> struct __tuple_less<0> {1165 template <class _Tp, class _Up>1166 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 bool1167 operator()(const _Tp &, const _Up &) {1168 return false;1169 }1170};1171 1172template <class... _Tp, class... _Up>1173inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 bool1174operator<(const tuple<_Tp...> &__x, const tuple<_Up...> &__y) {1175 static_assert(sizeof...(_Tp) == sizeof...(_Up),1176 "Can't compare tuples of different sizes");1177 return __tuple_less<sizeof...(_Tp)>()(__x, __y);1178}1179 1180template <class... _Tp, class... _Up>1181inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 bool1182operator>(const tuple<_Tp...> &__x, const tuple<_Up...> &__y) {1183 return __y < __x;1184}1185 1186template <class... _Tp, class... _Up>1187inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 bool1188operator>=(const tuple<_Tp...> &__x, const tuple<_Up...> &__y) {1189 return !(__x < __y);1190}1191 1192template <class... _Tp, class... _Up>1193inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 bool1194operator<=(const tuple<_Tp...> &__x, const tuple<_Up...> &__y) {1195 return !(__y < __x);1196}1197 1198// tuple_cat1199 1200template <class _Tp, class _Up> struct __tuple_cat_type;