tuple 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462
  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-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_TUPLE
  10. #define _LIBCPP_TUPLE
  11. /*
  12. tuple synopsis
  13. namespace std
  14. {
  15. template <class... T>
  16. class tuple {
  17. public:
  18. explicit(see-below) constexpr tuple();
  19. explicit(see-below) tuple(const T&...); // constexpr in C++14
  20. template <class... U>
  21. explicit(see-below) tuple(U&&...); // constexpr in C++14
  22. tuple(const tuple&) = default;
  23. tuple(tuple&&) = default;
  24. template <class... U>
  25. explicit(see-below) tuple(const tuple<U...>&); // constexpr in C++14
  26. template <class... U>
  27. explicit(see-below) tuple(tuple<U...>&&); // constexpr in C++14
  28. template <class U1, class U2>
  29. explicit(see-below) tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
  30. template <class U1, class U2>
  31. explicit(see-below) tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
  32. // allocator-extended constructors
  33. template <class Alloc>
  34. tuple(allocator_arg_t, const Alloc& a);
  35. template <class Alloc>
  36. explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const T&...);
  37. template <class Alloc, class... U>
  38. explicit(see-below) tuple(allocator_arg_t, const Alloc& a, U&&...);
  39. template <class Alloc>
  40. tuple(allocator_arg_t, const Alloc& a, const tuple&);
  41. template <class Alloc>
  42. tuple(allocator_arg_t, const Alloc& a, tuple&&);
  43. template <class Alloc, class... U>
  44. explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
  45. template <class Alloc, class... U>
  46. explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
  47. template <class Alloc, class U1, class U2>
  48. explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
  49. template <class Alloc, class U1, class U2>
  50. explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
  51. tuple& operator=(const tuple&);
  52. tuple&
  53. operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
  54. template <class... U>
  55. tuple& operator=(const tuple<U...>&);
  56. template <class... U>
  57. tuple& operator=(tuple<U...>&&);
  58. template <class U1, class U2>
  59. tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
  60. template <class U1, class U2>
  61. tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2
  62. void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
  63. };
  64. template <class ...T>
  65. tuple(T...) -> tuple<T...>; // since C++17
  66. template <class T1, class T2>
  67. tuple(pair<T1, T2>) -> tuple<T1, T2>; // since C++17
  68. template <class Alloc, class ...T>
  69. tuple(allocator_arg_t, Alloc, T...) -> tuple<T...>; // since C++17
  70. template <class Alloc, class T1, class T2>
  71. tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; // since C++17
  72. template <class Alloc, class ...T>
  73. tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>; // since C++17
  74. inline constexpr unspecified ignore;
  75. template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
  76. template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
  77. template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
  78. template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
  79. // [tuple.apply], calling a function with a tuple of arguments:
  80. template <class F, class Tuple>
  81. constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17
  82. template <class T, class Tuple>
  83. constexpr T make_from_tuple(Tuple&& t); // C++17
  84. // 20.4.1.4, tuple helper classes:
  85. template <class T> struct tuple_size; // undefined
  86. template <class... T> struct tuple_size<tuple<T...>>;
  87. template <class T>
  88. inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
  89. template <size_t I, class T> struct tuple_element; // undefined
  90. template <size_t I, class... T> struct tuple_element<I, tuple<T...>>;
  91. template <size_t I, class T>
  92. using tuple_element_t = typename tuple_element <I, T>::type; // C++14
  93. // 20.4.1.5, element access:
  94. template <size_t I, class... T>
  95. typename tuple_element<I, tuple<T...>>::type&
  96. get(tuple<T...>&) noexcept; // constexpr in C++14
  97. template <size_t I, class... T>
  98. const typename tuple_element<I, tuple<T...>>::type&
  99. get(const tuple<T...>&) noexcept; // constexpr in C++14
  100. template <size_t I, class... T>
  101. typename tuple_element<I, tuple<T...>>::type&&
  102. get(tuple<T...>&&) noexcept; // constexpr in C++14
  103. template <size_t I, class... T>
  104. const typename tuple_element<I, tuple<T...>>::type&&
  105. get(const tuple<T...>&&) noexcept; // constexpr in C++14
  106. template <class T1, class... T>
  107. constexpr T1& get(tuple<T...>&) noexcept; // C++14
  108. template <class T1, class... T>
  109. constexpr const T1& get(const tuple<T...>&) noexcept; // C++14
  110. template <class T1, class... T>
  111. constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
  112. template <class T1, class... T>
  113. constexpr const T1&& get(const tuple<T...>&&) noexcept; // C++14
  114. // 20.4.1.6, relational operators:
  115. template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
  116. template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
  117. template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
  118. template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
  119. template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
  120. template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
  121. template <class... Types, class Alloc>
  122. struct uses_allocator<tuple<Types...>, Alloc>;
  123. template <class... Types>
  124. void
  125. swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
  126. } // std
  127. */
  128. #include <__config>
  129. #include <__tuple>
  130. #include <cstddef>
  131. #include <type_traits>
  132. #include <__functional_base>
  133. #include <utility>
  134. #include <version>
  135. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  136. #pragma GCC system_header
  137. #endif
  138. _LIBCPP_BEGIN_NAMESPACE_STD
  139. #ifndef _LIBCPP_CXX03_LANG
  140. // __tuple_leaf
  141. template <size_t _Ip, class _Hp,
  142. bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
  143. >
  144. class __tuple_leaf;
  145. template <size_t _Ip, class _Hp, bool _Ep>
  146. inline _LIBCPP_INLINE_VISIBILITY
  147. void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
  148. _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
  149. {
  150. swap(__x.get(), __y.get());
  151. }
  152. template <size_t _Ip, class _Hp, bool>
  153. class __tuple_leaf
  154. {
  155. _Hp __value_;
  156. template <class _Tp>
  157. static constexpr bool __can_bind_reference() {
  158. #if __has_keyword(__reference_binds_to_temporary)
  159. return !__reference_binds_to_temporary(_Hp, _Tp);
  160. #else
  161. return true;
  162. #endif
  163. }
  164. __tuple_leaf& operator=(const __tuple_leaf&);
  165. public:
  166. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
  167. _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_()
  168. {static_assert(!is_reference<_Hp>::value,
  169. "Attempted to default construct a reference element in a tuple");}
  170. template <class _Alloc>
  171. _LIBCPP_INLINE_VISIBILITY
  172. __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
  173. : __value_()
  174. {static_assert(!is_reference<_Hp>::value,
  175. "Attempted to default construct a reference element in a tuple");}
  176. template <class _Alloc>
  177. _LIBCPP_INLINE_VISIBILITY
  178. __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
  179. : __value_(allocator_arg_t(), __a)
  180. {static_assert(!is_reference<_Hp>::value,
  181. "Attempted to default construct a reference element in a tuple");}
  182. template <class _Alloc>
  183. _LIBCPP_INLINE_VISIBILITY
  184. __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
  185. : __value_(__a)
  186. {static_assert(!is_reference<_Hp>::value,
  187. "Attempted to default construct a reference element in a tuple");}
  188. template <class _Tp,
  189. class = _EnableIf<
  190. _And<
  191. _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,
  192. is_constructible<_Hp, _Tp>
  193. >::value
  194. >
  195. >
  196. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  197. explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
  198. : __value_(_VSTD::forward<_Tp>(__t))
  199. {static_assert(__can_bind_reference<_Tp&&>(),
  200. "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
  201. template <class _Tp, class _Alloc>
  202. _LIBCPP_INLINE_VISIBILITY
  203. explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
  204. : __value_(_VSTD::forward<_Tp>(__t))
  205. {static_assert(__can_bind_reference<_Tp&&>(),
  206. "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
  207. template <class _Tp, class _Alloc>
  208. _LIBCPP_INLINE_VISIBILITY
  209. explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
  210. : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
  211. {static_assert(!is_reference<_Hp>::value,
  212. "Attempted to uses-allocator construct a reference element in a tuple");}
  213. template <class _Tp, class _Alloc>
  214. _LIBCPP_INLINE_VISIBILITY
  215. explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
  216. : __value_(_VSTD::forward<_Tp>(__t), __a)
  217. {static_assert(!is_reference<_Hp>::value,
  218. "Attempted to uses-allocator construct a reference element in a tuple");}
  219. __tuple_leaf(const __tuple_leaf& __t) = default;
  220. __tuple_leaf(__tuple_leaf&& __t) = default;
  221. template <class _Tp>
  222. _LIBCPP_INLINE_VISIBILITY
  223. __tuple_leaf&
  224. operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
  225. {
  226. __value_ = _VSTD::forward<_Tp>(__t);
  227. return *this;
  228. }
  229. _LIBCPP_INLINE_VISIBILITY
  230. int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
  231. {
  232. _VSTD::swap(*this, __t);
  233. return 0;
  234. }
  235. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;}
  236. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;}
  237. };
  238. template <size_t _Ip, class _Hp>
  239. class __tuple_leaf<_Ip, _Hp, true>
  240. : private _Hp
  241. {
  242. __tuple_leaf& operator=(const __tuple_leaf&);
  243. public:
  244. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
  245. _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
  246. template <class _Alloc>
  247. _LIBCPP_INLINE_VISIBILITY
  248. __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
  249. template <class _Alloc>
  250. _LIBCPP_INLINE_VISIBILITY
  251. __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
  252. : _Hp(allocator_arg_t(), __a) {}
  253. template <class _Alloc>
  254. _LIBCPP_INLINE_VISIBILITY
  255. __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
  256. : _Hp(__a) {}
  257. template <class _Tp,
  258. class = _EnableIf<
  259. _And<
  260. _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,
  261. is_constructible<_Hp, _Tp>
  262. >::value
  263. >
  264. >
  265. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  266. explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
  267. : _Hp(_VSTD::forward<_Tp>(__t)) {}
  268. template <class _Tp, class _Alloc>
  269. _LIBCPP_INLINE_VISIBILITY
  270. explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
  271. : _Hp(_VSTD::forward<_Tp>(__t)) {}
  272. template <class _Tp, class _Alloc>
  273. _LIBCPP_INLINE_VISIBILITY
  274. explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
  275. : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
  276. template <class _Tp, class _Alloc>
  277. _LIBCPP_INLINE_VISIBILITY
  278. explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
  279. : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
  280. __tuple_leaf(__tuple_leaf const &) = default;
  281. __tuple_leaf(__tuple_leaf &&) = default;
  282. template <class _Tp>
  283. _LIBCPP_INLINE_VISIBILITY
  284. __tuple_leaf&
  285. operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
  286. {
  287. _Hp::operator=(_VSTD::forward<_Tp>(__t));
  288. return *this;
  289. }
  290. _LIBCPP_INLINE_VISIBILITY
  291. int
  292. swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
  293. {
  294. _VSTD::swap(*this, __t);
  295. return 0;
  296. }
  297. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
  298. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
  299. };
  300. template <class ..._Tp>
  301. _LIBCPP_INLINE_VISIBILITY
  302. void __swallow(_Tp&&...) _NOEXCEPT {}
  303. template <class _Tp>
  304. struct __all_default_constructible;
  305. template <class ..._Tp>
  306. struct __all_default_constructible<__tuple_types<_Tp...>>
  307. : __all<is_default_constructible<_Tp>::value...>
  308. { };
  309. // __tuple_impl
  310. template<class _Indx, class ..._Tp> struct __tuple_impl;
  311. template<size_t ..._Indx, class ..._Tp>
  312. struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
  313. : public __tuple_leaf<_Indx, _Tp>...
  314. {
  315. _LIBCPP_INLINE_VISIBILITY
  316. _LIBCPP_CONSTEXPR __tuple_impl()
  317. _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
  318. template <size_t ..._Uf, class ..._Tf,
  319. size_t ..._Ul, class ..._Tl, class ..._Up>
  320. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  321. explicit
  322. __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
  323. __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
  324. _Up&&... __u)
  325. _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
  326. __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
  327. __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
  328. __tuple_leaf<_Ul, _Tl>()...
  329. {}
  330. template <class _Alloc, size_t ..._Uf, class ..._Tf,
  331. size_t ..._Ul, class ..._Tl, class ..._Up>
  332. _LIBCPP_INLINE_VISIBILITY
  333. explicit
  334. __tuple_impl(allocator_arg_t, const _Alloc& __a,
  335. __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
  336. __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
  337. _Up&&... __u) :
  338. __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
  339. _VSTD::forward<_Up>(__u))...,
  340. __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
  341. {}
  342. template <class _Tuple,
  343. class = typename enable_if
  344. <
  345. __tuple_constructible<_Tuple, tuple<_Tp...> >::value
  346. >::type
  347. >
  348. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  349. __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
  350. typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
  351. : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
  352. typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
  353. {}
  354. template <class _Alloc, class _Tuple,
  355. class = typename enable_if
  356. <
  357. __tuple_constructible<_Tuple, tuple<_Tp...> >::value
  358. >::type
  359. >
  360. _LIBCPP_INLINE_VISIBILITY
  361. __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
  362. : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
  363. typename __make_tuple_types<_Tuple>::type>::type>(), __a,
  364. _VSTD::forward<typename tuple_element<_Indx,
  365. typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
  366. {}
  367. template <class _Tuple>
  368. _LIBCPP_INLINE_VISIBILITY
  369. typename enable_if
  370. <
  371. __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
  372. __tuple_impl&
  373. >::type
  374. operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
  375. typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
  376. {
  377. __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
  378. typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
  379. return *this;
  380. }
  381. __tuple_impl(const __tuple_impl&) = default;
  382. __tuple_impl(__tuple_impl&&) = default;
  383. _LIBCPP_INLINE_VISIBILITY
  384. __tuple_impl&
  385. operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
  386. {
  387. __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
  388. return *this;
  389. }
  390. _LIBCPP_INLINE_VISIBILITY
  391. __tuple_impl&
  392. operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
  393. {
  394. __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
  395. return *this;
  396. }
  397. _LIBCPP_INLINE_VISIBILITY
  398. void swap(__tuple_impl& __t)
  399. _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
  400. {
  401. __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
  402. }
  403. };
  404. template <class ..._Tp>
  405. class _LIBCPP_TEMPLATE_VIS tuple
  406. {
  407. typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
  408. _BaseT __base_;
  409. #if defined(_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION)
  410. static constexpr bool _EnableImplicitReducedArityExtension = true;
  411. #else
  412. static constexpr bool _EnableImplicitReducedArityExtension = false;
  413. #endif
  414. template <class ..._Args>
  415. struct _PackExpandsToThisTuple : false_type {};
  416. template <class _Arg>
  417. struct _PackExpandsToThisTuple<_Arg>
  418. : is_same<typename __uncvref<_Arg>::type, tuple> {};
  419. template <bool _MaybeEnable, class _Dummy = void>
  420. struct _CheckArgsConstructor : __check_tuple_constructor_fail {};
  421. template <class _Dummy>
  422. struct _CheckArgsConstructor<true, _Dummy>
  423. {
  424. template <class ..._Args>
  425. struct __enable_implicit_default
  426. // In C++03, there's no way to implement the resolution of LWG2510.
  427. #ifdef _LIBCPP_CXX03_LANG
  428. : true_type
  429. #else
  430. : __all<__is_implicitly_default_constructible<_Args>::value...>
  431. #endif
  432. { };
  433. template <class ..._Args>
  434. struct __enable_explicit_default
  435. : integral_constant<bool,
  436. __all<is_default_constructible<_Args>::value...>::value &&
  437. !__enable_implicit_default<_Args...>::value
  438. >
  439. { };
  440. template <class ..._Args>
  441. static constexpr bool __enable_explicit() {
  442. return
  443. __tuple_constructible<
  444. tuple<_Args...>,
  445. typename __make_tuple_types<tuple,
  446. sizeof...(_Args) < sizeof...(_Tp) ?
  447. sizeof...(_Args) :
  448. sizeof...(_Tp)>::type
  449. >::value &&
  450. !__tuple_convertible<
  451. tuple<_Args...>,
  452. typename __make_tuple_types<tuple,
  453. sizeof...(_Args) < sizeof...(_Tp) ?
  454. sizeof...(_Args) :
  455. sizeof...(_Tp)>::type
  456. >::value &&
  457. __all_default_constructible<
  458. typename __make_tuple_types<tuple, sizeof...(_Tp),
  459. sizeof...(_Args) < sizeof...(_Tp) ?
  460. sizeof...(_Args) :
  461. sizeof...(_Tp)>::type
  462. >::value;
  463. }
  464. template <class ..._Args>
  465. static constexpr bool __enable_implicit() {
  466. return
  467. __tuple_constructible<
  468. tuple<_Args...>,
  469. typename __make_tuple_types<tuple,
  470. sizeof...(_Args) < sizeof...(_Tp) ?
  471. sizeof...(_Args) :
  472. sizeof...(_Tp)>::type
  473. >::value &&
  474. __tuple_convertible<
  475. tuple<_Args...>,
  476. typename __make_tuple_types<tuple,
  477. sizeof...(_Args) < sizeof...(_Tp) ?
  478. sizeof...(_Args) :
  479. sizeof...(_Tp)>::type
  480. >::value &&
  481. __all_default_constructible<
  482. typename __make_tuple_types<tuple, sizeof...(_Tp),
  483. sizeof...(_Args) < sizeof...(_Tp) ?
  484. sizeof...(_Args) :
  485. sizeof...(_Tp)>::type
  486. >::value;
  487. }
  488. };
  489. template <bool _MaybeEnable,
  490. bool = sizeof...(_Tp) == 1,
  491. class _Dummy = void>
  492. struct _CheckTupleLikeConstructor : __check_tuple_constructor_fail {};
  493. template <class _Dummy>
  494. struct _CheckTupleLikeConstructor<true, false, _Dummy>
  495. {
  496. template <class _Tuple>
  497. static constexpr bool __enable_implicit() {
  498. return __tuple_constructible<_Tuple, tuple>::value
  499. && __tuple_convertible<_Tuple, tuple>::value;
  500. }
  501. template <class _Tuple>
  502. static constexpr bool __enable_explicit() {
  503. return __tuple_constructible<_Tuple, tuple>::value
  504. && !__tuple_convertible<_Tuple, tuple>::value;
  505. }
  506. };
  507. template <class _Dummy>
  508. struct _CheckTupleLikeConstructor<true, true, _Dummy>
  509. {
  510. // This trait is used to disable the tuple-like constructor when
  511. // the UTypes... constructor should be selected instead.
  512. // See LWG issue #2549.
  513. template <class _Tuple>
  514. using _PreferTupleLikeConstructor = _Or<
  515. // Don't attempt the two checks below if the tuple we are given
  516. // has the same type as this tuple.
  517. _IsSame<__uncvref_t<_Tuple>, tuple>,
  518. _Lazy<_And,
  519. _Not<is_constructible<_Tp..., _Tuple>>,
  520. _Not<is_convertible<_Tuple, _Tp...>>
  521. >
  522. >;
  523. template <class _Tuple>
  524. static constexpr bool __enable_implicit() {
  525. return _And<
  526. __tuple_constructible<_Tuple, tuple>,
  527. __tuple_convertible<_Tuple, tuple>,
  528. _PreferTupleLikeConstructor<_Tuple>
  529. >::value;
  530. }
  531. template <class _Tuple>
  532. static constexpr bool __enable_explicit() {
  533. return _And<
  534. __tuple_constructible<_Tuple, tuple>,
  535. _PreferTupleLikeConstructor<_Tuple>,
  536. _Not<__tuple_convertible<_Tuple, tuple>>
  537. >::value;
  538. }
  539. };
  540. template <class _Tuple, bool _DisableIfLValue>
  541. using _EnableImplicitTupleLikeConstructor = _EnableIf<
  542. _CheckTupleLikeConstructor<
  543. __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
  544. && !_PackExpandsToThisTuple<_Tuple>::value
  545. && (!is_lvalue_reference<_Tuple>::value || !_DisableIfLValue)
  546. >::template __enable_implicit<_Tuple>(),
  547. bool
  548. >;
  549. template <class _Tuple, bool _DisableIfLValue>
  550. using _EnableExplicitTupleLikeConstructor = _EnableIf<
  551. _CheckTupleLikeConstructor<
  552. __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
  553. && !_PackExpandsToThisTuple<_Tuple>::value
  554. && (!is_lvalue_reference<_Tuple>::value || !_DisableIfLValue)
  555. >::template __enable_explicit<_Tuple>(),
  556. bool
  557. >;
  558. template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
  559. typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
  560. template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
  561. const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
  562. template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
  563. typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
  564. template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
  565. const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
  566. public:
  567. template <bool _Dummy = true, _EnableIf<
  568. _CheckArgsConstructor<_Dummy>::template __enable_implicit_default<_Tp...>::value
  569. , void*> = nullptr>
  570. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
  571. tuple()
  572. _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
  573. template <bool _Dummy = true, _EnableIf<
  574. _CheckArgsConstructor<_Dummy>::template __enable_explicit_default<_Tp...>::value
  575. , void*> = nullptr>
  576. explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
  577. tuple()
  578. _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
  579. tuple(tuple const&) = default;
  580. tuple(tuple&&) = default;
  581. template <class _AllocArgT, class _Alloc, bool _Dummy = true, _EnableIf<
  582. _And<
  583. _IsSame<allocator_arg_t, _AllocArgT>,
  584. typename _CheckArgsConstructor<_Dummy>::template __enable_implicit_default<_Tp...>
  585. >::value
  586. , void*> = nullptr
  587. >
  588. _LIBCPP_INLINE_VISIBILITY
  589. tuple(_AllocArgT, _Alloc const& __a)
  590. : __base_(allocator_arg_t(), __a,
  591. __tuple_indices<>(), __tuple_types<>(),
  592. typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
  593. __tuple_types<_Tp...>()) {}
  594. template <class _AllocArgT, class _Alloc, bool _Dummy = true, _EnableIf<
  595. _And<
  596. _IsSame<allocator_arg_t, _AllocArgT>,
  597. typename _CheckArgsConstructor<_Dummy>::template __enable_explicit_default<_Tp...>
  598. >::value
  599. , void*> = nullptr
  600. >
  601. explicit _LIBCPP_INLINE_VISIBILITY
  602. tuple(_AllocArgT, _Alloc const& __a)
  603. : __base_(allocator_arg_t(), __a,
  604. __tuple_indices<>(), __tuple_types<>(),
  605. typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
  606. __tuple_types<_Tp...>()) {}
  607. template <bool _Dummy = true,
  608. typename enable_if
  609. <
  610. _CheckArgsConstructor<
  611. _Dummy
  612. >::template __enable_implicit<_Tp const&...>(),
  613. bool
  614. >::type = false
  615. >
  616. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  617. tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
  618. : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
  619. typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
  620. typename __make_tuple_indices<0>::type(),
  621. typename __make_tuple_types<tuple, 0>::type(),
  622. __t...
  623. ) {}
  624. template <bool _Dummy = true,
  625. typename enable_if
  626. <
  627. _CheckArgsConstructor<
  628. _Dummy
  629. >::template __enable_explicit<_Tp const&...>(),
  630. bool
  631. >::type = false
  632. >
  633. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  634. explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
  635. : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
  636. typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
  637. typename __make_tuple_indices<0>::type(),
  638. typename __make_tuple_types<tuple, 0>::type(),
  639. __t...
  640. ) {}
  641. template <class _Alloc, bool _Dummy = true,
  642. typename enable_if
  643. <
  644. _CheckArgsConstructor<
  645. _Dummy
  646. >::template __enable_implicit<_Tp const&...>(),
  647. bool
  648. >::type = false
  649. >
  650. _LIBCPP_INLINE_VISIBILITY
  651. tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
  652. : __base_(allocator_arg_t(), __a,
  653. typename __make_tuple_indices<sizeof...(_Tp)>::type(),
  654. typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
  655. typename __make_tuple_indices<0>::type(),
  656. typename __make_tuple_types<tuple, 0>::type(),
  657. __t...
  658. ) {}
  659. template <class _Alloc, bool _Dummy = true,
  660. typename enable_if
  661. <
  662. _CheckArgsConstructor<
  663. _Dummy
  664. >::template __enable_explicit<_Tp const&...>(),
  665. bool
  666. >::type = false
  667. >
  668. _LIBCPP_INLINE_VISIBILITY
  669. explicit
  670. tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
  671. : __base_(allocator_arg_t(), __a,
  672. typename __make_tuple_indices<sizeof...(_Tp)>::type(),
  673. typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
  674. typename __make_tuple_indices<0>::type(),
  675. typename __make_tuple_types<tuple, 0>::type(),
  676. __t...
  677. ) {}
  678. template <class ..._Up,
  679. bool _PackIsTuple = _PackExpandsToThisTuple<_Up...>::value,
  680. typename enable_if
  681. <
  682. _CheckArgsConstructor<
  683. sizeof...(_Up) == sizeof...(_Tp)
  684. && !_PackIsTuple
  685. >::template __enable_implicit<_Up...>() ||
  686. _CheckArgsConstructor<
  687. _EnableImplicitReducedArityExtension
  688. && sizeof...(_Up) < sizeof...(_Tp)
  689. && !_PackIsTuple
  690. >::template __enable_implicit<_Up...>(),
  691. bool
  692. >::type = false
  693. >
  694. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  695. tuple(_Up&&... __u)
  696. _NOEXCEPT_((
  697. is_nothrow_constructible<_BaseT,
  698. typename __make_tuple_indices<sizeof...(_Up)>::type,
  699. typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
  700. typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
  701. typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
  702. _Up...
  703. >::value
  704. ))
  705. : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
  706. typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
  707. typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
  708. typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
  709. _VSTD::forward<_Up>(__u)...) {}
  710. template <class ..._Up,
  711. typename enable_if
  712. <
  713. _CheckArgsConstructor<
  714. sizeof...(_Up) <= sizeof...(_Tp)
  715. && !_PackExpandsToThisTuple<_Up...>::value
  716. >::template __enable_explicit<_Up...>() ||
  717. _CheckArgsConstructor<
  718. !_EnableImplicitReducedArityExtension
  719. && sizeof...(_Up) < sizeof...(_Tp)
  720. && !_PackExpandsToThisTuple<_Up...>::value
  721. >::template __enable_implicit<_Up...>(),
  722. bool
  723. >::type = false
  724. >
  725. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  726. explicit
  727. tuple(_Up&&... __u)
  728. _NOEXCEPT_((
  729. is_nothrow_constructible<_BaseT,
  730. typename __make_tuple_indices<sizeof...(_Up)>::type,
  731. typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
  732. typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
  733. typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
  734. _Up...
  735. >::value
  736. ))
  737. : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
  738. typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
  739. typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
  740. typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
  741. _VSTD::forward<_Up>(__u)...) {}
  742. template <class _Alloc, class ..._Up,
  743. typename enable_if
  744. <
  745. _CheckArgsConstructor<
  746. sizeof...(_Up) == sizeof...(_Tp) &&
  747. !_PackExpandsToThisTuple<_Up...>::value
  748. >::template __enable_implicit<_Up...>(),
  749. bool
  750. >::type = false
  751. >
  752. _LIBCPP_INLINE_VISIBILITY
  753. tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
  754. : __base_(allocator_arg_t(), __a,
  755. typename __make_tuple_indices<sizeof...(_Up)>::type(),
  756. typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
  757. typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
  758. typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
  759. _VSTD::forward<_Up>(__u)...) {}
  760. template <class _Alloc, class ..._Up,
  761. typename enable_if
  762. <
  763. _CheckArgsConstructor<
  764. sizeof...(_Up) == sizeof...(_Tp) &&
  765. !_PackExpandsToThisTuple<_Up...>::value
  766. >::template __enable_explicit<_Up...>(),
  767. bool
  768. >::type = false
  769. >
  770. _LIBCPP_INLINE_VISIBILITY
  771. explicit
  772. tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
  773. : __base_(allocator_arg_t(), __a,
  774. typename __make_tuple_indices<sizeof...(_Up)>::type(),
  775. typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
  776. typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
  777. typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
  778. _VSTD::forward<_Up>(__u)...) {}
  779. template <class _Tuple, _EnableImplicitTupleLikeConstructor<_Tuple, true> = false>
  780. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  781. tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
  782. : __base_(_VSTD::forward<_Tuple>(__t)) {}
  783. template <class _Tuple, _EnableImplicitTupleLikeConstructor<const _Tuple&, false> = false>
  784. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  785. tuple(const _Tuple& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, const _Tuple&>::value))
  786. : __base_(__t) {}
  787. template <class _Tuple, _EnableExplicitTupleLikeConstructor<_Tuple, true> = false>
  788. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  789. explicit
  790. tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
  791. : __base_(_VSTD::forward<_Tuple>(__t)) {}
  792. template <class _Tuple, _EnableExplicitTupleLikeConstructor<const _Tuple&, false> = false>
  793. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  794. explicit
  795. tuple(const _Tuple& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, const _Tuple&>::value))
  796. : __base_(__t) {}
  797. template <class _Alloc, class _Tuple,
  798. typename enable_if
  799. <
  800. _CheckTupleLikeConstructor<
  801. __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
  802. >::template __enable_implicit<_Tuple>(),
  803. bool
  804. >::type = false
  805. >
  806. _LIBCPP_INLINE_VISIBILITY
  807. tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
  808. : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
  809. template <class _Alloc, class _Tuple,
  810. typename enable_if
  811. <
  812. _CheckTupleLikeConstructor<
  813. __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
  814. >::template __enable_explicit<_Tuple>(),
  815. bool
  816. >::type = false
  817. >
  818. _LIBCPP_INLINE_VISIBILITY
  819. explicit
  820. tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
  821. : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
  822. using _CanCopyAssign = __all<is_copy_assignable<_Tp>::value...>;
  823. using _CanMoveAssign = __all<is_move_assignable<_Tp>::value...>;
  824. _LIBCPP_INLINE_VISIBILITY
  825. tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, __nat>::type const& __t)
  826. _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
  827. {
  828. __base_.operator=(__t.__base_);
  829. return *this;
  830. }
  831. _LIBCPP_INLINE_VISIBILITY
  832. tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, __nat>::type&& __t)
  833. _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
  834. {
  835. __base_.operator=(static_cast<_BaseT&&>(__t.__base_));
  836. return *this;
  837. }
  838. template <class _Tuple,
  839. class = typename enable_if
  840. <
  841. __tuple_assignable<_Tuple, tuple>::value
  842. >::type
  843. >
  844. _LIBCPP_INLINE_VISIBILITY
  845. tuple&
  846. operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<_BaseT&, _Tuple>::value))
  847. {
  848. __base_.operator=(_VSTD::forward<_Tuple>(__t));
  849. return *this;
  850. }
  851. _LIBCPP_INLINE_VISIBILITY
  852. void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
  853. {__base_.swap(__t.__base_);}
  854. };
  855. template <>
  856. class _LIBCPP_TEMPLATE_VIS tuple<>
  857. {
  858. public:
  859. _LIBCPP_INLINE_VISIBILITY
  860. _LIBCPP_CONSTEXPR tuple() _NOEXCEPT = default;
  861. template <class _Alloc>
  862. _LIBCPP_INLINE_VISIBILITY
  863. tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
  864. template <class _Alloc>
  865. _LIBCPP_INLINE_VISIBILITY
  866. tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
  867. template <class _Up>
  868. _LIBCPP_INLINE_VISIBILITY
  869. tuple(array<_Up, 0>) _NOEXCEPT {}
  870. template <class _Alloc, class _Up>
  871. _LIBCPP_INLINE_VISIBILITY
  872. tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
  873. _LIBCPP_INLINE_VISIBILITY
  874. void swap(tuple&) _NOEXCEPT {}
  875. };
  876. #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
  877. template <class ..._Tp>
  878. tuple(_Tp...) -> tuple<_Tp...>;
  879. template <class _Tp1, class _Tp2>
  880. tuple(pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
  881. template <class _Alloc, class ..._Tp>
  882. tuple(allocator_arg_t, _Alloc, _Tp...) -> tuple<_Tp...>;
  883. template <class _Alloc, class _Tp1, class _Tp2>
  884. tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
  885. template <class _Alloc, class ..._Tp>
  886. tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
  887. #endif
  888. template <class ..._Tp>
  889. inline _LIBCPP_INLINE_VISIBILITY
  890. typename enable_if
  891. <
  892. __all<__is_swappable<_Tp>::value...>::value,
  893. void
  894. >::type
  895. swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
  896. _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
  897. {__t.swap(__u);}
  898. // get
  899. template <size_t _Ip, class ..._Tp>
  900. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  901. typename tuple_element<_Ip, tuple<_Tp...> >::type&
  902. get(tuple<_Tp...>& __t) _NOEXCEPT
  903. {
  904. typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, tuple<_Tp...> >::type type;
  905. return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
  906. }
  907. template <size_t _Ip, class ..._Tp>
  908. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  909. const typename tuple_element<_Ip, tuple<_Tp...> >::type&
  910. get(const tuple<_Tp...>& __t) _NOEXCEPT
  911. {
  912. typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, tuple<_Tp...> >::type type;
  913. return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
  914. }
  915. template <size_t _Ip, class ..._Tp>
  916. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  917. typename tuple_element<_Ip, tuple<_Tp...> >::type&&
  918. get(tuple<_Tp...>&& __t) _NOEXCEPT
  919. {
  920. typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, tuple<_Tp...> >::type type;
  921. return static_cast<type&&>(
  922. static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
  923. }
  924. template <size_t _Ip, class ..._Tp>
  925. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  926. const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
  927. get(const tuple<_Tp...>&& __t) _NOEXCEPT
  928. {
  929. typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, tuple<_Tp...> >::type type;
  930. return static_cast<const type&&>(
  931. static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
  932. }
  933. #if _LIBCPP_STD_VER > 11
  934. namespace __find_detail {
  935. static constexpr size_t __not_found = -1;
  936. static constexpr size_t __ambiguous = __not_found - 1;
  937. inline _LIBCPP_INLINE_VISIBILITY
  938. constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
  939. return !__matches ? __res :
  940. (__res == __not_found ? __curr_i : __ambiguous);
  941. }
  942. template <size_t _Nx>
  943. inline _LIBCPP_INLINE_VISIBILITY
  944. constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
  945. return __i == _Nx ? __not_found :
  946. __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]);
  947. }
  948. template <class _T1, class ..._Args>
  949. struct __find_exactly_one_checked {
  950. static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
  951. static constexpr size_t value = __find_detail::__find_idx(0, __matches);
  952. static_assert(value != __not_found, "type not found in type list" );
  953. static_assert(value != __ambiguous, "type occurs more than once in type list");
  954. };
  955. template <class _T1>
  956. struct __find_exactly_one_checked<_T1> {
  957. static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
  958. };
  959. } // namespace __find_detail;
  960. template <typename _T1, typename... _Args>
  961. struct __find_exactly_one_t
  962. : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
  963. };
  964. template <class _T1, class... _Args>
  965. inline _LIBCPP_INLINE_VISIBILITY
  966. constexpr _T1& get(tuple<_Args...>& __tup) noexcept
  967. {
  968. return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
  969. }
  970. template <class _T1, class... _Args>
  971. inline _LIBCPP_INLINE_VISIBILITY
  972. constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
  973. {
  974. return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
  975. }
  976. template <class _T1, class... _Args>
  977. inline _LIBCPP_INLINE_VISIBILITY
  978. constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
  979. {
  980. return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
  981. }
  982. template <class _T1, class... _Args>
  983. inline _LIBCPP_INLINE_VISIBILITY
  984. constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
  985. {
  986. return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
  987. }
  988. #endif
  989. // tie
  990. template <class ..._Tp>
  991. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  992. tuple<_Tp&...>
  993. tie(_Tp&... __t) _NOEXCEPT
  994. {
  995. return tuple<_Tp&...>(__t...);
  996. }
  997. template <class _Up>
  998. struct __ignore_t
  999. {
  1000. template <class _Tp>
  1001. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1002. const __ignore_t& operator=(_Tp&&) const {return *this;}
  1003. };
  1004. namespace {
  1005. _LIBCPP_INLINE_VAR constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
  1006. }
  1007. template <class... _Tp>
  1008. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1009. tuple<typename __unwrap_ref_decay<_Tp>::type...>
  1010. make_tuple(_Tp&&... __t)
  1011. {
  1012. return tuple<typename __unwrap_ref_decay<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
  1013. }
  1014. template <class... _Tp>
  1015. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1016. tuple<_Tp&&...>
  1017. forward_as_tuple(_Tp&&... __t) _NOEXCEPT
  1018. {
  1019. return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
  1020. }
  1021. template <size_t _Ip>
  1022. struct __tuple_equal
  1023. {
  1024. template <class _Tp, class _Up>
  1025. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1026. bool operator()(const _Tp& __x, const _Up& __y)
  1027. {
  1028. return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
  1029. }
  1030. };
  1031. template <>
  1032. struct __tuple_equal<0>
  1033. {
  1034. template <class _Tp, class _Up>
  1035. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1036. bool operator()(const _Tp&, const _Up&)
  1037. {
  1038. return true;
  1039. }
  1040. };
  1041. template <class ..._Tp, class ..._Up>
  1042. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1043. bool
  1044. operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
  1045. {
  1046. static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
  1047. return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
  1048. }
  1049. template <class ..._Tp, class ..._Up>
  1050. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1051. bool
  1052. operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
  1053. {
  1054. return !(__x == __y);
  1055. }
  1056. template <size_t _Ip>
  1057. struct __tuple_less
  1058. {
  1059. template <class _Tp, class _Up>
  1060. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1061. bool operator()(const _Tp& __x, const _Up& __y)
  1062. {
  1063. const size_t __idx = tuple_size<_Tp>::value - _Ip;
  1064. if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
  1065. return true;
  1066. if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
  1067. return false;
  1068. return __tuple_less<_Ip-1>()(__x, __y);
  1069. }
  1070. };
  1071. template <>
  1072. struct __tuple_less<0>
  1073. {
  1074. template <class _Tp, class _Up>
  1075. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1076. bool operator()(const _Tp&, const _Up&)
  1077. {
  1078. return false;
  1079. }
  1080. };
  1081. template <class ..._Tp, class ..._Up>
  1082. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1083. bool
  1084. operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
  1085. {
  1086. static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
  1087. return __tuple_less<sizeof...(_Tp)>()(__x, __y);
  1088. }
  1089. template <class ..._Tp, class ..._Up>
  1090. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1091. bool
  1092. operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
  1093. {
  1094. return __y < __x;
  1095. }
  1096. template <class ..._Tp, class ..._Up>
  1097. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1098. bool
  1099. operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
  1100. {
  1101. return !(__x < __y);
  1102. }
  1103. template <class ..._Tp, class ..._Up>
  1104. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1105. bool
  1106. operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
  1107. {
  1108. return !(__y < __x);
  1109. }
  1110. // tuple_cat
  1111. template <class _Tp, class _Up> struct __tuple_cat_type;
  1112. template <class ..._Ttypes, class ..._Utypes>
  1113. struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
  1114. {
  1115. typedef _LIBCPP_NODEBUG_TYPE tuple<_Ttypes..., _Utypes...> type;
  1116. };
  1117. template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
  1118. struct __tuple_cat_return_1
  1119. {
  1120. };
  1121. template <class ..._Types, class _Tuple0>
  1122. struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
  1123. {
  1124. typedef _LIBCPP_NODEBUG_TYPE typename __tuple_cat_type<tuple<_Types...>,
  1125. typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type>::type
  1126. type;
  1127. };
  1128. template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
  1129. struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
  1130. : public __tuple_cat_return_1<
  1131. typename __tuple_cat_type<
  1132. tuple<_Types...>,
  1133. typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type
  1134. >::type,
  1135. __tuple_like<typename remove_reference<_Tuple1>::type>::value,
  1136. _Tuple1, _Tuples...>
  1137. {
  1138. };
  1139. template <class ..._Tuples> struct __tuple_cat_return;
  1140. template <class _Tuple0, class ..._Tuples>
  1141. struct __tuple_cat_return<_Tuple0, _Tuples...>
  1142. : public __tuple_cat_return_1<tuple<>,
  1143. __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
  1144. _Tuples...>
  1145. {
  1146. };
  1147. template <>
  1148. struct __tuple_cat_return<>
  1149. {
  1150. typedef _LIBCPP_NODEBUG_TYPE tuple<> type;
  1151. };
  1152. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1153. tuple<>
  1154. tuple_cat()
  1155. {
  1156. return tuple<>();
  1157. }
  1158. template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
  1159. struct __tuple_cat_return_ref_imp;
  1160. template <class ..._Types, size_t ..._I0, class _Tuple0>
  1161. struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
  1162. {
  1163. typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple0>::type _T0;
  1164. typedef tuple<_Types..., typename __apply_cv<_Tuple0,
  1165. typename tuple_element<_I0, _T0>::type>::type&&...> type;
  1166. };
  1167. template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
  1168. struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
  1169. _Tuple0, _Tuple1, _Tuples...>
  1170. : public __tuple_cat_return_ref_imp<
  1171. tuple<_Types..., typename __apply_cv<_Tuple0,
  1172. typename tuple_element<_I0,
  1173. typename remove_reference<_Tuple0>::type>::type>::type&&...>,
  1174. typename __make_tuple_indices<tuple_size<typename
  1175. remove_reference<_Tuple1>::type>::value>::type,
  1176. _Tuple1, _Tuples...>
  1177. {
  1178. };
  1179. template <class _Tuple0, class ..._Tuples>
  1180. struct __tuple_cat_return_ref
  1181. : public __tuple_cat_return_ref_imp<tuple<>,
  1182. typename __make_tuple_indices<
  1183. tuple_size<typename remove_reference<_Tuple0>::type>::value
  1184. >::type, _Tuple0, _Tuples...>
  1185. {
  1186. };
  1187. template <class _Types, class _I0, class _J0>
  1188. struct __tuple_cat;
  1189. template <class ..._Types, size_t ..._I0, size_t ..._J0>
  1190. struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
  1191. {
  1192. template <class _Tuple0>
  1193. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1194. typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
  1195. operator()(tuple<_Types...> __t, _Tuple0&& __t0)
  1196. {
  1197. return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
  1198. _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
  1199. }
  1200. template <class _Tuple0, class _Tuple1, class ..._Tuples>
  1201. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1202. typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
  1203. operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
  1204. {
  1205. typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple0>::type _T0;
  1206. typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple1>::type _T1;
  1207. return __tuple_cat<
  1208. tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
  1209. typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
  1210. typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
  1211. (forward_as_tuple(
  1212. _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
  1213. _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
  1214. ),
  1215. _VSTD::forward<_Tuple1>(__t1),
  1216. _VSTD::forward<_Tuples>(__tpls)...);
  1217. }
  1218. };
  1219. template <class _Tuple0, class... _Tuples>
  1220. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1221. typename __tuple_cat_return<_Tuple0, _Tuples...>::type
  1222. tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
  1223. {
  1224. typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple0>::type _T0;
  1225. return __tuple_cat<tuple<>, __tuple_indices<>,
  1226. typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
  1227. (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
  1228. _VSTD::forward<_Tuples>(__tpls)...);
  1229. }
  1230. template <class ..._Tp, class _Alloc>
  1231. struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
  1232. : true_type {};
  1233. template <class _T1, class _T2>
  1234. template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
  1235. inline _LIBCPP_INLINE_VISIBILITY
  1236. pair<_T1, _T2>::pair(piecewise_construct_t,
  1237. tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
  1238. __tuple_indices<_I1...>, __tuple_indices<_I2...>)
  1239. : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
  1240. second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
  1241. {
  1242. }
  1243. #if _LIBCPP_STD_VER > 14
  1244. template <class _Tp>
  1245. _LIBCPP_INLINE_VAR constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
  1246. #define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
  1247. template <class _Fn, class _Tuple, size_t ..._Id>
  1248. inline _LIBCPP_INLINE_VISIBILITY
  1249. constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
  1250. __tuple_indices<_Id...>)
  1251. _LIBCPP_NOEXCEPT_RETURN(
  1252. _VSTD::__invoke_constexpr(
  1253. _VSTD::forward<_Fn>(__f),
  1254. _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
  1255. )
  1256. template <class _Fn, class _Tuple>
  1257. inline _LIBCPP_INLINE_VISIBILITY
  1258. constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
  1259. _LIBCPP_NOEXCEPT_RETURN(
  1260. _VSTD::__apply_tuple_impl(
  1261. _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
  1262. typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
  1263. )
  1264. template <class _Tp, class _Tuple, size_t... _Idx>
  1265. inline _LIBCPP_INLINE_VISIBILITY
  1266. constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
  1267. _LIBCPP_NOEXCEPT_RETURN(
  1268. _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...)
  1269. )
  1270. template <class _Tp, class _Tuple>
  1271. inline _LIBCPP_INLINE_VISIBILITY
  1272. constexpr _Tp make_from_tuple(_Tuple&& __t)
  1273. _LIBCPP_NOEXCEPT_RETURN(
  1274. _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
  1275. typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
  1276. )
  1277. #undef _LIBCPP_NOEXCEPT_RETURN
  1278. #endif // _LIBCPP_STD_VER > 14
  1279. #endif // !defined(_LIBCPP_CXX03_LANG)
  1280. _LIBCPP_END_NAMESPACE_STD
  1281. #endif // _LIBCPP_TUPLE