tuple 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451
  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 <int&...>
  425. static constexpr bool __enable_implicit_default() {
  426. return __all<__is_implicitly_default_constructible<_Tp>::value... >::value;
  427. }
  428. template <int&...>
  429. static constexpr bool __enable_explicit_default() {
  430. return
  431. __all<is_default_constructible<_Tp>::value...>::value &&
  432. !__enable_implicit_default< >();
  433. }
  434. template <class ..._Args>
  435. static constexpr bool __enable_explicit() {
  436. return
  437. __tuple_constructible<
  438. tuple<_Args...>,
  439. typename __make_tuple_types<tuple,
  440. sizeof...(_Args) < sizeof...(_Tp) ?
  441. sizeof...(_Args) :
  442. sizeof...(_Tp)>::type
  443. >::value &&
  444. !__tuple_convertible<
  445. tuple<_Args...>,
  446. typename __make_tuple_types<tuple,
  447. sizeof...(_Args) < sizeof...(_Tp) ?
  448. sizeof...(_Args) :
  449. sizeof...(_Tp)>::type
  450. >::value &&
  451. __all_default_constructible<
  452. typename __make_tuple_types<tuple, sizeof...(_Tp),
  453. sizeof...(_Args) < sizeof...(_Tp) ?
  454. sizeof...(_Args) :
  455. sizeof...(_Tp)>::type
  456. >::value;
  457. }
  458. template <class ..._Args>
  459. static constexpr bool __enable_implicit() {
  460. return
  461. __tuple_constructible<
  462. tuple<_Args...>,
  463. typename __make_tuple_types<tuple,
  464. sizeof...(_Args) < sizeof...(_Tp) ?
  465. sizeof...(_Args) :
  466. sizeof...(_Tp)>::type
  467. >::value &&
  468. __tuple_convertible<
  469. tuple<_Args...>,
  470. typename __make_tuple_types<tuple,
  471. sizeof...(_Args) < sizeof...(_Tp) ?
  472. sizeof...(_Args) :
  473. sizeof...(_Tp)>::type
  474. >::value &&
  475. __all_default_constructible<
  476. typename __make_tuple_types<tuple, sizeof...(_Tp),
  477. sizeof...(_Args) < sizeof...(_Tp) ?
  478. sizeof...(_Args) :
  479. sizeof...(_Tp)>::type
  480. >::value;
  481. }
  482. };
  483. template <bool _MaybeEnable,
  484. bool = sizeof...(_Tp) == 1,
  485. class _Dummy = void>
  486. struct _CheckTupleLikeConstructor : __check_tuple_constructor_fail {};
  487. template <class _Dummy>
  488. struct _CheckTupleLikeConstructor<true, false, _Dummy>
  489. {
  490. template <class _Tuple>
  491. static constexpr bool __enable_implicit() {
  492. return __tuple_constructible<_Tuple, tuple>::value
  493. && __tuple_convertible<_Tuple, tuple>::value;
  494. }
  495. template <class _Tuple>
  496. static constexpr bool __enable_explicit() {
  497. return __tuple_constructible<_Tuple, tuple>::value
  498. && !__tuple_convertible<_Tuple, tuple>::value;
  499. }
  500. };
  501. template <class _Dummy>
  502. struct _CheckTupleLikeConstructor<true, true, _Dummy>
  503. {
  504. // This trait is used to disable the tuple-like constructor when
  505. // the UTypes... constructor should be selected instead.
  506. // See LWG issue #2549.
  507. template <class _Tuple>
  508. using _PreferTupleLikeConstructor = _Or<
  509. // Don't attempt the two checks below if the tuple we are given
  510. // has the same type as this tuple.
  511. _IsSame<__uncvref_t<_Tuple>, tuple>,
  512. _Lazy<_And,
  513. _Not<is_constructible<_Tp..., _Tuple>>,
  514. _Not<is_convertible<_Tuple, _Tp...>>
  515. >
  516. >;
  517. template <class _Tuple>
  518. static constexpr bool __enable_implicit() {
  519. return _And<
  520. __tuple_constructible<_Tuple, tuple>,
  521. __tuple_convertible<_Tuple, tuple>,
  522. _PreferTupleLikeConstructor<_Tuple>
  523. >::value;
  524. }
  525. template <class _Tuple>
  526. static constexpr bool __enable_explicit() {
  527. return _And<
  528. __tuple_constructible<_Tuple, tuple>,
  529. _PreferTupleLikeConstructor<_Tuple>,
  530. _Not<__tuple_convertible<_Tuple, tuple>>
  531. >::value;
  532. }
  533. };
  534. template <class _Tuple, bool _DisableIfLValue>
  535. using _EnableImplicitTupleLikeConstructor = _EnableIf<
  536. _CheckTupleLikeConstructor<
  537. __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
  538. && !_PackExpandsToThisTuple<_Tuple>::value
  539. && (!is_lvalue_reference<_Tuple>::value || !_DisableIfLValue)
  540. >::template __enable_implicit<_Tuple>(),
  541. bool
  542. >;
  543. template <class _Tuple, bool _DisableIfLValue>
  544. using _EnableExplicitTupleLikeConstructor = _EnableIf<
  545. _CheckTupleLikeConstructor<
  546. __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
  547. && !_PackExpandsToThisTuple<_Tuple>::value
  548. && (!is_lvalue_reference<_Tuple>::value || !_DisableIfLValue)
  549. >::template __enable_explicit<_Tuple>(),
  550. bool
  551. >;
  552. template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
  553. typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
  554. template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
  555. const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
  556. template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
  557. typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
  558. template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
  559. const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
  560. public:
  561. template <bool _Dummy = true, _EnableIf<
  562. _CheckArgsConstructor<_Dummy>::__enable_implicit_default()
  563. , void*> = nullptr>
  564. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
  565. tuple()
  566. _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
  567. template <bool _Dummy = true, _EnableIf<
  568. _CheckArgsConstructor<_Dummy>::__enable_explicit_default()
  569. , void*> = nullptr>
  570. explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
  571. tuple()
  572. _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
  573. tuple(tuple const&) = default;
  574. tuple(tuple&&) = default;
  575. template <class _AllocArgT, class _Alloc, _EnableIf<
  576. _CheckArgsConstructor<_IsSame<allocator_arg_t, _AllocArgT>::value >::__enable_implicit_default()
  577. , void*> = nullptr
  578. >
  579. _LIBCPP_INLINE_VISIBILITY
  580. tuple(_AllocArgT, _Alloc const& __a)
  581. : __base_(allocator_arg_t(), __a,
  582. __tuple_indices<>(), __tuple_types<>(),
  583. typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
  584. __tuple_types<_Tp...>()) {}
  585. template <class _AllocArgT, class _Alloc, _EnableIf<
  586. _CheckArgsConstructor<_IsSame<allocator_arg_t, _AllocArgT>::value>::__enable_explicit_default()
  587. , void*> = nullptr
  588. >
  589. explicit _LIBCPP_INLINE_VISIBILITY
  590. tuple(_AllocArgT, _Alloc const& __a)
  591. : __base_(allocator_arg_t(), __a,
  592. __tuple_indices<>(), __tuple_types<>(),
  593. typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
  594. __tuple_types<_Tp...>()) {}
  595. template <bool _Dummy = true,
  596. typename enable_if
  597. <
  598. _CheckArgsConstructor<
  599. _Dummy
  600. >::template __enable_implicit<_Tp const&...>(),
  601. bool
  602. >::type = false
  603. >
  604. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  605. tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
  606. : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
  607. typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
  608. typename __make_tuple_indices<0>::type(),
  609. typename __make_tuple_types<tuple, 0>::type(),
  610. __t...
  611. ) {}
  612. template <bool _Dummy = true,
  613. typename enable_if
  614. <
  615. _CheckArgsConstructor<
  616. _Dummy
  617. >::template __enable_explicit<_Tp const&...>(),
  618. bool
  619. >::type = false
  620. >
  621. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  622. explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
  623. : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
  624. typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
  625. typename __make_tuple_indices<0>::type(),
  626. typename __make_tuple_types<tuple, 0>::type(),
  627. __t...
  628. ) {}
  629. template <class _Alloc, bool _Dummy = true,
  630. typename enable_if
  631. <
  632. _CheckArgsConstructor<
  633. _Dummy
  634. >::template __enable_implicit<_Tp const&...>(),
  635. bool
  636. >::type = false
  637. >
  638. _LIBCPP_INLINE_VISIBILITY
  639. tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
  640. : __base_(allocator_arg_t(), __a,
  641. typename __make_tuple_indices<sizeof...(_Tp)>::type(),
  642. typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
  643. typename __make_tuple_indices<0>::type(),
  644. typename __make_tuple_types<tuple, 0>::type(),
  645. __t...
  646. ) {}
  647. template <class _Alloc, bool _Dummy = true,
  648. typename enable_if
  649. <
  650. _CheckArgsConstructor<
  651. _Dummy
  652. >::template __enable_explicit<_Tp const&...>(),
  653. bool
  654. >::type = false
  655. >
  656. _LIBCPP_INLINE_VISIBILITY
  657. explicit
  658. tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
  659. : __base_(allocator_arg_t(), __a,
  660. typename __make_tuple_indices<sizeof...(_Tp)>::type(),
  661. typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
  662. typename __make_tuple_indices<0>::type(),
  663. typename __make_tuple_types<tuple, 0>::type(),
  664. __t...
  665. ) {}
  666. template <class ..._Up,
  667. bool _PackIsTuple = _PackExpandsToThisTuple<_Up...>::value,
  668. typename enable_if
  669. <
  670. _CheckArgsConstructor<
  671. sizeof...(_Up) == sizeof...(_Tp)
  672. && !_PackIsTuple
  673. >::template __enable_implicit<_Up...>() ||
  674. _CheckArgsConstructor<
  675. _EnableImplicitReducedArityExtension
  676. && sizeof...(_Up) < sizeof...(_Tp)
  677. && !_PackIsTuple
  678. >::template __enable_implicit<_Up...>(),
  679. bool
  680. >::type = false
  681. >
  682. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  683. tuple(_Up&&... __u)
  684. _NOEXCEPT_((
  685. is_nothrow_constructible<_BaseT,
  686. typename __make_tuple_indices<sizeof...(_Up)>::type,
  687. typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
  688. typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
  689. typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
  690. _Up...
  691. >::value
  692. ))
  693. : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
  694. typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
  695. typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
  696. typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
  697. _VSTD::forward<_Up>(__u)...) {}
  698. template <class ..._Up,
  699. typename enable_if
  700. <
  701. _CheckArgsConstructor<
  702. sizeof...(_Up) <= sizeof...(_Tp)
  703. && !_PackExpandsToThisTuple<_Up...>::value
  704. >::template __enable_explicit<_Up...>() ||
  705. _CheckArgsConstructor<
  706. !_EnableImplicitReducedArityExtension
  707. && sizeof...(_Up) < sizeof...(_Tp)
  708. && !_PackExpandsToThisTuple<_Up...>::value
  709. >::template __enable_implicit<_Up...>(),
  710. bool
  711. >::type = false
  712. >
  713. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  714. explicit
  715. tuple(_Up&&... __u)
  716. _NOEXCEPT_((
  717. is_nothrow_constructible<_BaseT,
  718. typename __make_tuple_indices<sizeof...(_Up)>::type,
  719. typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
  720. typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
  721. typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
  722. _Up...
  723. >::value
  724. ))
  725. : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
  726. typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
  727. typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
  728. typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
  729. _VSTD::forward<_Up>(__u)...) {}
  730. template <class _Alloc, class ..._Up,
  731. typename enable_if
  732. <
  733. _CheckArgsConstructor<
  734. sizeof...(_Up) == sizeof...(_Tp) &&
  735. !_PackExpandsToThisTuple<_Up...>::value
  736. >::template __enable_implicit<_Up...>(),
  737. bool
  738. >::type = false
  739. >
  740. _LIBCPP_INLINE_VISIBILITY
  741. tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
  742. : __base_(allocator_arg_t(), __a,
  743. typename __make_tuple_indices<sizeof...(_Up)>::type(),
  744. typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
  745. typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
  746. typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
  747. _VSTD::forward<_Up>(__u)...) {}
  748. template <class _Alloc, class ..._Up,
  749. typename enable_if
  750. <
  751. _CheckArgsConstructor<
  752. sizeof...(_Up) == sizeof...(_Tp) &&
  753. !_PackExpandsToThisTuple<_Up...>::value
  754. >::template __enable_explicit<_Up...>(),
  755. bool
  756. >::type = false
  757. >
  758. _LIBCPP_INLINE_VISIBILITY
  759. explicit
  760. tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
  761. : __base_(allocator_arg_t(), __a,
  762. typename __make_tuple_indices<sizeof...(_Up)>::type(),
  763. typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
  764. typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
  765. typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
  766. _VSTD::forward<_Up>(__u)...) {}
  767. template <class _Tuple, _EnableImplicitTupleLikeConstructor<_Tuple, true> = false>
  768. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  769. tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
  770. : __base_(_VSTD::forward<_Tuple>(__t)) {}
  771. template <class _Tuple, _EnableImplicitTupleLikeConstructor<const _Tuple&, false> = false>
  772. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  773. tuple(const _Tuple& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, const _Tuple&>::value))
  774. : __base_(__t) {}
  775. template <class _Tuple, _EnableExplicitTupleLikeConstructor<_Tuple, true> = false>
  776. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  777. explicit
  778. tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
  779. : __base_(_VSTD::forward<_Tuple>(__t)) {}
  780. template <class _Tuple, _EnableExplicitTupleLikeConstructor<const _Tuple&, false> = false>
  781. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  782. explicit
  783. tuple(const _Tuple& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, const _Tuple&>::value))
  784. : __base_(__t) {}
  785. template <class _Alloc, class _Tuple,
  786. typename enable_if
  787. <
  788. _CheckTupleLikeConstructor<
  789. __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
  790. >::template __enable_implicit<_Tuple>(),
  791. bool
  792. >::type = false
  793. >
  794. _LIBCPP_INLINE_VISIBILITY
  795. tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
  796. : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__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_explicit<_Tuple>(),
  803. bool
  804. >::type = false
  805. >
  806. _LIBCPP_INLINE_VISIBILITY
  807. explicit
  808. tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
  809. : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
  810. using _CanCopyAssign = __all<is_copy_assignable<_Tp>::value...>;
  811. using _CanMoveAssign = __all<is_move_assignable<_Tp>::value...>;
  812. _LIBCPP_INLINE_VISIBILITY
  813. tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, __nat>::type const& __t)
  814. _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
  815. {
  816. __base_.operator=(__t.__base_);
  817. return *this;
  818. }
  819. _LIBCPP_INLINE_VISIBILITY
  820. tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, __nat>::type&& __t)
  821. _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
  822. {
  823. __base_.operator=(static_cast<_BaseT&&>(__t.__base_));
  824. return *this;
  825. }
  826. template <class _Tuple,
  827. class = typename enable_if
  828. <
  829. __tuple_assignable<_Tuple, tuple>::value
  830. >::type
  831. >
  832. _LIBCPP_INLINE_VISIBILITY
  833. tuple&
  834. operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<_BaseT&, _Tuple>::value))
  835. {
  836. __base_.operator=(_VSTD::forward<_Tuple>(__t));
  837. return *this;
  838. }
  839. _LIBCPP_INLINE_VISIBILITY
  840. void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
  841. {__base_.swap(__t.__base_);}
  842. };
  843. template <>
  844. class _LIBCPP_TEMPLATE_VIS tuple<>
  845. {
  846. public:
  847. _LIBCPP_INLINE_VISIBILITY
  848. _LIBCPP_CONSTEXPR tuple() _NOEXCEPT = default;
  849. template <class _Alloc>
  850. _LIBCPP_INLINE_VISIBILITY
  851. tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
  852. template <class _Alloc>
  853. _LIBCPP_INLINE_VISIBILITY
  854. tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
  855. template <class _Up>
  856. _LIBCPP_INLINE_VISIBILITY
  857. tuple(array<_Up, 0>) _NOEXCEPT {}
  858. template <class _Alloc, class _Up>
  859. _LIBCPP_INLINE_VISIBILITY
  860. tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
  861. _LIBCPP_INLINE_VISIBILITY
  862. void swap(tuple&) _NOEXCEPT {}
  863. };
  864. #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
  865. template <class ..._Tp>
  866. tuple(_Tp...) -> tuple<_Tp...>;
  867. template <class _Tp1, class _Tp2>
  868. tuple(pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
  869. template <class _Alloc, class ..._Tp>
  870. tuple(allocator_arg_t, _Alloc, _Tp...) -> tuple<_Tp...>;
  871. template <class _Alloc, class _Tp1, class _Tp2>
  872. tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
  873. template <class _Alloc, class ..._Tp>
  874. tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
  875. #endif
  876. template <class ..._Tp>
  877. inline _LIBCPP_INLINE_VISIBILITY
  878. typename enable_if
  879. <
  880. __all<__is_swappable<_Tp>::value...>::value,
  881. void
  882. >::type
  883. swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
  884. _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
  885. {__t.swap(__u);}
  886. // get
  887. template <size_t _Ip, class ..._Tp>
  888. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  889. typename tuple_element<_Ip, tuple<_Tp...> >::type&
  890. get(tuple<_Tp...>& __t) _NOEXCEPT
  891. {
  892. typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, tuple<_Tp...> >::type type;
  893. return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
  894. }
  895. template <size_t _Ip, class ..._Tp>
  896. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  897. const typename tuple_element<_Ip, tuple<_Tp...> >::type&
  898. get(const tuple<_Tp...>& __t) _NOEXCEPT
  899. {
  900. typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, tuple<_Tp...> >::type type;
  901. return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
  902. }
  903. template <size_t _Ip, class ..._Tp>
  904. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  905. typename tuple_element<_Ip, tuple<_Tp...> >::type&&
  906. get(tuple<_Tp...>&& __t) _NOEXCEPT
  907. {
  908. typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, tuple<_Tp...> >::type type;
  909. return static_cast<type&&>(
  910. static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
  911. }
  912. template <size_t _Ip, class ..._Tp>
  913. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  914. const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
  915. get(const tuple<_Tp...>&& __t) _NOEXCEPT
  916. {
  917. typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, tuple<_Tp...> >::type type;
  918. return static_cast<const type&&>(
  919. static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
  920. }
  921. #if _LIBCPP_STD_VER > 11
  922. namespace __find_detail {
  923. static constexpr size_t __not_found = -1;
  924. static constexpr size_t __ambiguous = __not_found - 1;
  925. inline _LIBCPP_INLINE_VISIBILITY
  926. constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
  927. return !__matches ? __res :
  928. (__res == __not_found ? __curr_i : __ambiguous);
  929. }
  930. template <size_t _Nx>
  931. inline _LIBCPP_INLINE_VISIBILITY
  932. constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
  933. return __i == _Nx ? __not_found :
  934. __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]);
  935. }
  936. template <class _T1, class ..._Args>
  937. struct __find_exactly_one_checked {
  938. static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
  939. static constexpr size_t value = __find_detail::__find_idx(0, __matches);
  940. static_assert(value != __not_found, "type not found in type list" );
  941. static_assert(value != __ambiguous, "type occurs more than once in type list");
  942. };
  943. template <class _T1>
  944. struct __find_exactly_one_checked<_T1> {
  945. static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
  946. };
  947. } // namespace __find_detail;
  948. template <typename _T1, typename... _Args>
  949. struct __find_exactly_one_t
  950. : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
  951. };
  952. template <class _T1, class... _Args>
  953. inline _LIBCPP_INLINE_VISIBILITY
  954. constexpr _T1& get(tuple<_Args...>& __tup) noexcept
  955. {
  956. return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
  957. }
  958. template <class _T1, class... _Args>
  959. inline _LIBCPP_INLINE_VISIBILITY
  960. constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
  961. {
  962. return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
  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>(_VSTD::move(__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>(_VSTD::move(__tup));
  975. }
  976. #endif
  977. // tie
  978. template <class ..._Tp>
  979. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  980. tuple<_Tp&...>
  981. tie(_Tp&... __t) _NOEXCEPT
  982. {
  983. return tuple<_Tp&...>(__t...);
  984. }
  985. template <class _Up>
  986. struct __ignore_t
  987. {
  988. template <class _Tp>
  989. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  990. const __ignore_t& operator=(_Tp&&) const {return *this;}
  991. };
  992. namespace {
  993. _LIBCPP_INLINE_VAR constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
  994. }
  995. template <class... _Tp>
  996. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  997. tuple<typename __unwrap_ref_decay<_Tp>::type...>
  998. make_tuple(_Tp&&... __t)
  999. {
  1000. return tuple<typename __unwrap_ref_decay<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
  1001. }
  1002. template <class... _Tp>
  1003. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1004. tuple<_Tp&&...>
  1005. forward_as_tuple(_Tp&&... __t) _NOEXCEPT
  1006. {
  1007. return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
  1008. }
  1009. template <size_t _Ip>
  1010. struct __tuple_equal
  1011. {
  1012. template <class _Tp, class _Up>
  1013. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1014. bool operator()(const _Tp& __x, const _Up& __y)
  1015. {
  1016. return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
  1017. }
  1018. };
  1019. template <>
  1020. struct __tuple_equal<0>
  1021. {
  1022. template <class _Tp, class _Up>
  1023. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1024. bool operator()(const _Tp&, const _Up&)
  1025. {
  1026. return true;
  1027. }
  1028. };
  1029. template <class ..._Tp, class ..._Up>
  1030. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1031. bool
  1032. operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
  1033. {
  1034. static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
  1035. return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
  1036. }
  1037. template <class ..._Tp, class ..._Up>
  1038. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1039. bool
  1040. operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
  1041. {
  1042. return !(__x == __y);
  1043. }
  1044. template <size_t _Ip>
  1045. struct __tuple_less
  1046. {
  1047. template <class _Tp, class _Up>
  1048. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1049. bool operator()(const _Tp& __x, const _Up& __y)
  1050. {
  1051. const size_t __idx = tuple_size<_Tp>::value - _Ip;
  1052. if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
  1053. return true;
  1054. if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
  1055. return false;
  1056. return __tuple_less<_Ip-1>()(__x, __y);
  1057. }
  1058. };
  1059. template <>
  1060. struct __tuple_less<0>
  1061. {
  1062. template <class _Tp, class _Up>
  1063. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1064. bool operator()(const _Tp&, const _Up&)
  1065. {
  1066. return false;
  1067. }
  1068. };
  1069. template <class ..._Tp, class ..._Up>
  1070. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1071. bool
  1072. operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
  1073. {
  1074. static_assert (sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
  1075. return __tuple_less<sizeof...(_Tp)>()(__x, __y);
  1076. }
  1077. template <class ..._Tp, class ..._Up>
  1078. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1079. bool
  1080. operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
  1081. {
  1082. return __y < __x;
  1083. }
  1084. template <class ..._Tp, class ..._Up>
  1085. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1086. bool
  1087. operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
  1088. {
  1089. return !(__x < __y);
  1090. }
  1091. template <class ..._Tp, class ..._Up>
  1092. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1093. bool
  1094. operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
  1095. {
  1096. return !(__y < __x);
  1097. }
  1098. // tuple_cat
  1099. template <class _Tp, class _Up> struct __tuple_cat_type;
  1100. template <class ..._Ttypes, class ..._Utypes>
  1101. struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
  1102. {
  1103. typedef _LIBCPP_NODEBUG_TYPE tuple<_Ttypes..., _Utypes...> type;
  1104. };
  1105. template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
  1106. struct __tuple_cat_return_1
  1107. {
  1108. };
  1109. template <class ..._Types, class _Tuple0>
  1110. struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
  1111. {
  1112. typedef _LIBCPP_NODEBUG_TYPE typename __tuple_cat_type<tuple<_Types...>,
  1113. typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type>::type
  1114. type;
  1115. };
  1116. template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
  1117. struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
  1118. : public __tuple_cat_return_1<
  1119. typename __tuple_cat_type<
  1120. tuple<_Types...>,
  1121. typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type
  1122. >::type,
  1123. __tuple_like<typename remove_reference<_Tuple1>::type>::value,
  1124. _Tuple1, _Tuples...>
  1125. {
  1126. };
  1127. template <class ..._Tuples> struct __tuple_cat_return;
  1128. template <class _Tuple0, class ..._Tuples>
  1129. struct __tuple_cat_return<_Tuple0, _Tuples...>
  1130. : public __tuple_cat_return_1<tuple<>,
  1131. __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
  1132. _Tuples...>
  1133. {
  1134. };
  1135. template <>
  1136. struct __tuple_cat_return<>
  1137. {
  1138. typedef _LIBCPP_NODEBUG_TYPE tuple<> type;
  1139. };
  1140. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1141. tuple<>
  1142. tuple_cat()
  1143. {
  1144. return tuple<>();
  1145. }
  1146. template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
  1147. struct __tuple_cat_return_ref_imp;
  1148. template <class ..._Types, size_t ..._I0, class _Tuple0>
  1149. struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
  1150. {
  1151. typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple0>::type _T0;
  1152. typedef tuple<_Types..., typename __apply_cv<_Tuple0,
  1153. typename tuple_element<_I0, _T0>::type>::type&&...> type;
  1154. };
  1155. template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
  1156. struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
  1157. _Tuple0, _Tuple1, _Tuples...>
  1158. : public __tuple_cat_return_ref_imp<
  1159. tuple<_Types..., typename __apply_cv<_Tuple0,
  1160. typename tuple_element<_I0,
  1161. typename remove_reference<_Tuple0>::type>::type>::type&&...>,
  1162. typename __make_tuple_indices<tuple_size<typename
  1163. remove_reference<_Tuple1>::type>::value>::type,
  1164. _Tuple1, _Tuples...>
  1165. {
  1166. };
  1167. template <class _Tuple0, class ..._Tuples>
  1168. struct __tuple_cat_return_ref
  1169. : public __tuple_cat_return_ref_imp<tuple<>,
  1170. typename __make_tuple_indices<
  1171. tuple_size<typename remove_reference<_Tuple0>::type>::value
  1172. >::type, _Tuple0, _Tuples...>
  1173. {
  1174. };
  1175. template <class _Types, class _I0, class _J0>
  1176. struct __tuple_cat;
  1177. template <class ..._Types, size_t ..._I0, size_t ..._J0>
  1178. struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
  1179. {
  1180. template <class _Tuple0>
  1181. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1182. typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
  1183. operator()(tuple<_Types...> __t, _Tuple0&& __t0)
  1184. {
  1185. return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
  1186. _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
  1187. }
  1188. template <class _Tuple0, class _Tuple1, class ..._Tuples>
  1189. _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1190. typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
  1191. operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
  1192. {
  1193. typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple0>::type _T0;
  1194. typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple1>::type _T1;
  1195. return __tuple_cat<
  1196. tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
  1197. typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
  1198. typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
  1199. (forward_as_tuple(
  1200. _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
  1201. _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
  1202. ),
  1203. _VSTD::forward<_Tuple1>(__t1),
  1204. _VSTD::forward<_Tuples>(__tpls)...);
  1205. }
  1206. };
  1207. template <class _Tuple0, class... _Tuples>
  1208. inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
  1209. typename __tuple_cat_return<_Tuple0, _Tuples...>::type
  1210. tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
  1211. {
  1212. typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple0>::type _T0;
  1213. return __tuple_cat<tuple<>, __tuple_indices<>,
  1214. typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
  1215. (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
  1216. _VSTD::forward<_Tuples>(__tpls)...);
  1217. }
  1218. template <class ..._Tp, class _Alloc>
  1219. struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
  1220. : true_type {};
  1221. template <class _T1, class _T2>
  1222. template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
  1223. inline _LIBCPP_INLINE_VISIBILITY
  1224. pair<_T1, _T2>::pair(piecewise_construct_t,
  1225. tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
  1226. __tuple_indices<_I1...>, __tuple_indices<_I2...>)
  1227. : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
  1228. second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
  1229. {
  1230. }
  1231. #if _LIBCPP_STD_VER > 14
  1232. template <class _Tp>
  1233. _LIBCPP_INLINE_VAR constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
  1234. #define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
  1235. template <class _Fn, class _Tuple, size_t ..._Id>
  1236. inline _LIBCPP_INLINE_VISIBILITY
  1237. constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
  1238. __tuple_indices<_Id...>)
  1239. _LIBCPP_NOEXCEPT_RETURN(
  1240. _VSTD::__invoke_constexpr(
  1241. _VSTD::forward<_Fn>(__f),
  1242. _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
  1243. )
  1244. template <class _Fn, class _Tuple>
  1245. inline _LIBCPP_INLINE_VISIBILITY
  1246. constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
  1247. _LIBCPP_NOEXCEPT_RETURN(
  1248. _VSTD::__apply_tuple_impl(
  1249. _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
  1250. typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
  1251. )
  1252. template <class _Tp, class _Tuple, size_t... _Idx>
  1253. inline _LIBCPP_INLINE_VISIBILITY
  1254. constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
  1255. _LIBCPP_NOEXCEPT_RETURN(
  1256. _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...)
  1257. )
  1258. template <class _Tp, class _Tuple>
  1259. inline _LIBCPP_INLINE_VISIBILITY
  1260. constexpr _Tp make_from_tuple(_Tuple&& __t)
  1261. _LIBCPP_NOEXCEPT_RETURN(
  1262. _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
  1263. typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
  1264. )
  1265. #undef _LIBCPP_NOEXCEPT_RETURN
  1266. #endif // _LIBCPP_STD_VER > 14
  1267. #endif // !defined(_LIBCPP_CXX03_LANG)
  1268. _LIBCPP_END_NAMESPACE_STD
  1269. #endif // _LIBCPP_TUPLE