blob: 788fd750b31ac96c7b78de81b68e1df769a6a13e [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- tuple ------------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
6// This file is distributed under the University of Illinois Open Source
7// License. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_TUPLE
12#define _LIBCPP_TUPLE
13
14/*
15 tuple synopsis
16
17namespace std
18{
19
20template <class... T>
21class tuple {
22public:
23 constexpr tuple();
Marshall Clowda0a0e82013-07-22 16:02:19 +000024 explicit tuple(const T&...); // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000025 template <class... U>
Marshall Clowda0a0e82013-07-22 16:02:19 +000026 explicit tuple(U&&...); // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000027 tuple(const tuple&) = default;
Howard Hinnanta5e01212011-05-27 19:08:18 +000028 tuple(tuple&&) = default;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000029 template <class... U>
Marshall Clowda0a0e82013-07-22 16:02:19 +000030 tuple(const tuple<U...>&); // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000031 template <class... U>
Marshall Clowda0a0e82013-07-22 16:02:19 +000032 tuple(tuple<U...>&&); // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000033 template <class U1, class U2>
Marshall Clowda0a0e82013-07-22 16:02:19 +000034 tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000035 template <class U1, class U2>
Marshall Clowda0a0e82013-07-22 16:02:19 +000036 tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000037
38 // allocator-extended constructors
39 template <class Alloc>
40 tuple(allocator_arg_t, const Alloc& a);
41 template <class Alloc>
42 tuple(allocator_arg_t, const Alloc& a, const T&...);
43 template <class Alloc, class... U>
44 tuple(allocator_arg_t, const Alloc& a, U&&...);
45 template <class Alloc>
46 tuple(allocator_arg_t, const Alloc& a, const tuple&);
47 template <class Alloc>
48 tuple(allocator_arg_t, const Alloc& a, tuple&&);
49 template <class Alloc, class... U>
50 tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
51 template <class Alloc, class... U>
52 tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
53 template <class Alloc, class U1, class U2>
54 tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
55 template <class Alloc, class U1, class U2>
56 tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
57
58 tuple& operator=(const tuple&);
Howard Hinnanta5e01212011-05-27 19:08:18 +000059 tuple&
60 operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000061 template <class... U>
62 tuple& operator=(const tuple<U...>&);
63 template <class... U>
64 tuple& operator=(tuple<U...>&&);
65 template <class U1, class U2>
66 tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
67 template <class U1, class U2>
68 tuple& operator=(pair<U1, U2>&&); //iffsizeof...(T) == 2
69
Howard Hinnanta5e01212011-05-27 19:08:18 +000070 void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000071};
72
73const unspecified ignore;
74
Marshall Clowda0a0e82013-07-22 16:02:19 +000075template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
Marshall Clow1d927e32013-10-05 18:46:37 +000076template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
Marshall Clow8e554d92014-02-25 16:11:46 +000077template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
Marshall Clowda0a0e82013-07-22 16:02:19 +000078template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
Eric Fiselier5839fed2016-07-18 00:35:56 +000079
80// [tuple.apply], calling a function with a tuple of arguments:
81template <class F, class Tuple>
82 constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17
83template <class T, class Tuple>
84 constexpr T make_from_tuple(Tuple&& t); // C++17
85
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000086// 20.4.1.4, tuple helper classes:
Eric Fiselier40843842017-01-02 23:54:13 +000087template <class T> class tuple_size; // undefined
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000088template <class... T> class tuple_size<tuple<T...>>;
Eric Fiselier5839fed2016-07-18 00:35:56 +000089template <class T>
90 constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
Marshall Clowa6607572015-11-19 19:45:29 +000091template <size_t I, class T> class tuple_element; // undefined
92template <size_t I, class... T> class tuple_element<I, tuple<T...>>;
93template <size_t I, class T>
94 using tuple_element_t = typename tuple_element <I, T>::type; // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000095
96// 20.4.1.5, element access:
Marshall Clowa6607572015-11-19 19:45:29 +000097template <size_t I, class... T>
Howard Hinnanta5e01212011-05-27 19:08:18 +000098 typename tuple_element<I, tuple<T...>>::type&
Marshall Clow8fc4f5a2013-07-17 18:25:36 +000099 get(tuple<T...>&) noexcept; // constexpr in C++14
Marshall Clowa6607572015-11-19 19:45:29 +0000100template <size_t I, class... T>
101 const typename tuple_element<I, tuple<T...>>::type&
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000102 get(const tuple<T...>&) noexcept; // constexpr in C++14
Marshall Clowa6607572015-11-19 19:45:29 +0000103template <size_t I, class... T>
Howard Hinnanta5e01212011-05-27 19:08:18 +0000104 typename tuple_element<I, tuple<T...>>::type&&
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000105 get(tuple<T...>&&) noexcept; // constexpr in C++14
Eric Fiselier199bee02015-12-18 00:36:55 +0000106template <size_t I, class... T>
107 const typename tuple_element<I, tuple<T...>>::type&&
108 get(const tuple<T...>&&) noexcept; // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000109
Marshall Clowe8029e52013-07-13 02:54:05 +0000110template <class T1, class... T>
111 constexpr T1& get(tuple<T...>&) noexcept; // C++14
112template <class T1, class... T>
Marshall Clowa6607572015-11-19 19:45:29 +0000113 constexpr const T1& get(const tuple<T...>&) noexcept; // C++14
Marshall Clowe8029e52013-07-13 02:54:05 +0000114template <class T1, class... T>
115 constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
Eric Fiselier199bee02015-12-18 00:36:55 +0000116template <class T1, class... T>
117 constexpr const T1&& get(const tuple<T...>&&) noexcept; // C++14
Marshall Clowe8029e52013-07-13 02:54:05 +0000118
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000119// 20.4.1.6, relational operators:
Marshall Clowda0a0e82013-07-22 16:02:19 +0000120template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
121template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
122template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
123template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
124template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
125template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000126
127template <class... Types, class Alloc>
128 struct uses_allocator<tuple<Types...>, Alloc>;
129
130template <class... Types>
Howard Hinnanta5e01212011-05-27 19:08:18 +0000131 void
132 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000133
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000134} // std
135
136*/
137
138#include <__config>
139#include <__tuple>
140#include <cstddef>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000141#include <type_traits>
Howard Hinnant6cc99fa2011-12-19 17:58:44 +0000142#include <__functional_base>
143#include <utility>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000144
Howard Hinnant08e17472011-10-17 20:05:10 +0000145#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000146#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000147#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000148
149_LIBCPP_BEGIN_NAMESPACE_STD
150
Eric Fiselier191f0752017-04-19 01:23:39 +0000151#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000152
Marshall Clow50fe0c72014-03-03 06:18:11 +0000153
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000154// __tuple_leaf
155
Eric Fiselier3a0e4302015-06-13 07:08:02 +0000156template <size_t _Ip, class _Hp,
157 bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
Howard Hinnantd4cf2152011-12-11 20:31:33 +0000158 >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000159class __tuple_leaf;
160
161template <size_t _Ip, class _Hp, bool _Ep>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000162inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000163void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
Howard Hinnanta5e01212011-05-27 19:08:18 +0000164 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000165{
166 swap(__x.get(), __y.get());
167}
168
169template <size_t _Ip, class _Hp, bool>
170class __tuple_leaf
171{
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000172 _Hp __value_;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000173
Eric Fiselier9c747b92016-07-20 02:57:39 +0000174 template <class _Tp>
175 static constexpr bool __can_bind_reference() {
176 using _RawTp = typename remove_reference<_Tp>::type;
177 using _RawHp = typename remove_reference<_Hp>::type;
178 using _CheckLValueArg = integral_constant<bool,
179 is_lvalue_reference<_Tp>::value
180 || is_same<_RawTp, reference_wrapper<_RawHp>>::value
181 || is_same<_RawTp, reference_wrapper<typename remove_const<_RawHp>::type>>::value
182 >;
183 return !is_reference<_Hp>::value
184 || (is_lvalue_reference<_Hp>::value && _CheckLValueArg::value)
185 || (is_rvalue_reference<_Hp>::value && !is_lvalue_reference<_Tp>::value);
186 }
187
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000188 __tuple_leaf& operator=(const __tuple_leaf&);
189public:
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000190 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000191 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_()
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000192 {static_assert(!is_reference<_Hp>::value,
193 "Attempted to default construct a reference element in a tuple");}
194
195 template <class _Alloc>
196 _LIBCPP_INLINE_VISIBILITY
197 __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000198 : __value_()
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000199 {static_assert(!is_reference<_Hp>::value,
200 "Attempted to default construct a reference element in a tuple");}
201
202 template <class _Alloc>
203 _LIBCPP_INLINE_VISIBILITY
204 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000205 : __value_(allocator_arg_t(), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000206 {static_assert(!is_reference<_Hp>::value,
207 "Attempted to default construct a reference element in a tuple");}
208
209 template <class _Alloc>
210 _LIBCPP_INLINE_VISIBILITY
211 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000212 : __value_(__a)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000213 {static_assert(!is_reference<_Hp>::value,
214 "Attempted to default construct a reference element in a tuple");}
215
Howard Hinnante049cc52010-09-27 17:54:17 +0000216 template <class _Tp,
Eric Fiselier9020c082014-07-24 18:48:34 +0000217 class = typename enable_if<
218 __lazy_and<
219 __lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
220 , is_constructible<_Hp, _Tp>
221 >::value
222 >::type
223 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000224 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000225 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000226 : __value_(_VSTD::forward<_Tp>(__t))
Eric Fiselier9c747b92016-07-20 02:57:39 +0000227 {static_assert(__can_bind_reference<_Tp>(),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000228 "Attempted to construct a reference element in a tuple with an rvalue");}
229
230 template <class _Tp, class _Alloc>
231 _LIBCPP_INLINE_VISIBILITY
232 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000233 : __value_(_VSTD::forward<_Tp>(__t))
Eric Fiselier9c747b92016-07-20 02:57:39 +0000234 {static_assert(__can_bind_reference<_Tp>(),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000235 "Attempted to construct a reference element in a tuple with an rvalue");}
236
237 template <class _Tp, class _Alloc>
238 _LIBCPP_INLINE_VISIBILITY
239 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000240 : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
Eric Fiselier9c747b92016-07-20 02:57:39 +0000241 {static_assert(!is_reference<_Hp>::value,
242 "Attempted to uses-allocator construct a reference element in a tuple");}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000243
244 template <class _Tp, class _Alloc>
245 _LIBCPP_INLINE_VISIBILITY
246 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000247 : __value_(_VSTD::forward<_Tp>(__t), __a)
Eric Fiselier9c747b92016-07-20 02:57:39 +0000248 {static_assert(!is_reference<_Hp>::value,
249 "Attempted to uses-allocator construct a reference element in a tuple");}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000250
Marshall Clow398c9d82014-04-21 23:48:09 +0000251 __tuple_leaf(const __tuple_leaf& __t) = default;
252 __tuple_leaf(__tuple_leaf&& __t) = default;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000253
254 template <class _Tp>
255 _LIBCPP_INLINE_VISIBILITY
256 __tuple_leaf&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000257 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000258 {
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000259 __value_ = _VSTD::forward<_Tp>(__t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000260 return *this;
261 }
262
263 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000264 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000265 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000266 _VSTD::swap(*this, __t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000267 return 0;
268 }
269
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000270 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;}
271 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000272};
273
274template <size_t _Ip, class _Hp>
275class __tuple_leaf<_Ip, _Hp, true>
276 : private _Hp
277{
278
279 __tuple_leaf& operator=(const __tuple_leaf&);
280public:
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000281 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
282 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000283
284 template <class _Alloc>
285 _LIBCPP_INLINE_VISIBILITY
286 __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
287
288 template <class _Alloc>
289 _LIBCPP_INLINE_VISIBILITY
290 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
291 : _Hp(allocator_arg_t(), __a) {}
292
293 template <class _Alloc>
294 _LIBCPP_INLINE_VISIBILITY
295 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
296 : _Hp(__a) {}
297
Howard Hinnante049cc52010-09-27 17:54:17 +0000298 template <class _Tp,
Eric Fiselier9020c082014-07-24 18:48:34 +0000299 class = typename enable_if<
300 __lazy_and<
301 __lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
302 , is_constructible<_Hp, _Tp>
303 >::value
304 >::type
305 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000306 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000307 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000308 : _Hp(_VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000309
310 template <class _Tp, class _Alloc>
311 _LIBCPP_INLINE_VISIBILITY
312 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000313 : _Hp(_VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000314
315 template <class _Tp, class _Alloc>
316 _LIBCPP_INLINE_VISIBILITY
317 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000318 : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000319
320 template <class _Tp, class _Alloc>
321 _LIBCPP_INLINE_VISIBILITY
322 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000323 : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000324
Eric Fiselier9020c082014-07-24 18:48:34 +0000325 __tuple_leaf(__tuple_leaf const &) = default;
326 __tuple_leaf(__tuple_leaf &&) = default;
327
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000328 template <class _Tp>
329 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000330 __tuple_leaf&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000331 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000332 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000333 _Hp::operator=(_VSTD::forward<_Tp>(__t));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000334 return *this;
335 }
336
Howard Hinnanta5e01212011-05-27 19:08:18 +0000337 _LIBCPP_INLINE_VISIBILITY
338 int
339 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000340 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000341 _VSTD::swap(*this, __t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000342 return 0;
343 }
344
Marshall Clowda0a0e82013-07-22 16:02:19 +0000345 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
346 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000347};
348
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000349template <class ..._Tp>
350_LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000351void __swallow(_Tp&&...) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000352
Eric Fiselier55ad3ac2016-04-15 03:29:40 +0000353template <class ..._Tp>
354struct __lazy_all : __all<_Tp::value...> {};
355
Marshall Clowbbc7c742014-10-15 10:33:02 +0000356template <class _Tp>
357struct __all_default_constructible;
Howard Hinnanta5e01212011-05-27 19:08:18 +0000358
Marshall Clowbbc7c742014-10-15 10:33:02 +0000359template <class ..._Tp>
360struct __all_default_constructible<__tuple_types<_Tp...>>
361 : __all<is_default_constructible<_Tp>::value...>
362{ };
Howard Hinnanta5e01212011-05-27 19:08:18 +0000363
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000364// __tuple_impl
365
366template<class _Indx, class ..._Tp> struct __tuple_impl;
367
368template<size_t ..._Indx, class ..._Tp>
Eric Fiselier7d24e912017-01-16 21:15:08 +0000369struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000370 : public __tuple_leaf<_Indx, _Tp>...
371{
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000372 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000373 _LIBCPP_CONSTEXPR __tuple_impl()
374 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000375
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000376 template <size_t ..._Uf, class ..._Tf,
377 size_t ..._Ul, class ..._Tl, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000378 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000379 explicit
380 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
381 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
Howard Hinnant74f26f22012-07-06 21:53:48 +0000382 _Up&&... __u)
383 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
384 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
Howard Hinnant0949eed2011-06-30 21:18:19 +0000385 __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000386 __tuple_leaf<_Ul, _Tl>()...
387 {}
388
389 template <class _Alloc, size_t ..._Uf, class ..._Tf,
390 size_t ..._Ul, class ..._Tl, class ..._Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000391 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000392 explicit
393 __tuple_impl(allocator_arg_t, const _Alloc& __a,
394 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
395 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
396 _Up&&... __u) :
397 __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
Howard Hinnant0949eed2011-06-30 21:18:19 +0000398 _VSTD::forward<_Up>(__u))...,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000399 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
400 {}
401
402 template <class _Tuple,
403 class = typename enable_if
404 <
Howard Hinnant99324892013-04-14 00:01:13 +0000405 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000406 >::type
407 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000408 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000409 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
410 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000411 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
412 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000413 {}
414
415 template <class _Alloc, class _Tuple,
416 class = typename enable_if
417 <
Eric Fiselier95526d32016-04-19 01:19:25 +0000418 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000419 >::type
420 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000421 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000422 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
423 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
Howard Hinnant324bb032010-08-22 00:02:43 +0000424 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
Howard Hinnant0949eed2011-06-30 21:18:19 +0000425 _VSTD::forward<typename tuple_element<_Indx,
426 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000427 {}
428
429 template <class _Tuple>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000430 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000431 typename enable_if
432 <
Howard Hinnantf83417b2011-01-24 16:07:25 +0000433 __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000434 __tuple_impl&
435 >::type
Howard Hinnant74f26f22012-07-06 21:53:48 +0000436 operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
437 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000438 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000439 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
440 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000441 return *this;
442 }
443
Howard Hinnant3de50862013-11-06 17:45:43 +0000444 __tuple_impl(const __tuple_impl&) = default;
445 __tuple_impl(__tuple_impl&&) = default;
446
447 _LIBCPP_INLINE_VISIBILITY
448 __tuple_impl&
449 operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
450 {
451 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
452 return *this;
453 }
454
455 _LIBCPP_INLINE_VISIBILITY
456 __tuple_impl&
457 operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
458 {
459 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
460 return *this;
461 }
Howard Hinnant28484442012-02-15 20:13:52 +0000462
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000463 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000464 void swap(__tuple_impl& __t)
Howard Hinnanta5e01212011-05-27 19:08:18 +0000465 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000466 {
467 __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
468 }
469};
470
Eric Fiselierd5019332016-04-15 18:05:59 +0000471
Eric Fiselierd5019332016-04-15 18:05:59 +0000472
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000473template <class ..._Tp>
Eric Fiselierc3589a82017-01-04 23:56:00 +0000474class _LIBCPP_TEMPLATE_VIS tuple
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000475{
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000476 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000477
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000478 _BaseT __base_;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000479
Eric Fiselierf2f36372016-12-08 23:57:08 +0000480#if defined(_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION)
481 static constexpr bool _EnableImplicitReducedArityExtension = true;
482#else
483 static constexpr bool _EnableImplicitReducedArityExtension = false;
484#endif
485
Eric Fiselierd5019332016-04-15 18:05:59 +0000486 template <class ..._Args>
487 struct _PackExpandsToThisTuple : false_type {};
488
489 template <class _Arg>
490 struct _PackExpandsToThisTuple<_Arg>
491 : is_same<typename __uncvref<_Arg>::type, tuple> {};
492
493 template <bool _MaybeEnable, class _Dummy = void>
494 struct _CheckArgsConstructor : __check_tuple_constructor_fail {};
495
496 template <class _Dummy>
497 struct _CheckArgsConstructor<true, _Dummy>
498 {
499 template <class ..._Args>
Eric Fiseliere1445fd2016-07-25 04:32:07 +0000500 static constexpr bool __enable_default() {
501 return __all<is_default_constructible<_Args>::value...>::value;
502 }
503
504 template <class ..._Args>
Eric Fiselierd5019332016-04-15 18:05:59 +0000505 static constexpr bool __enable_explicit() {
506 return
507 __tuple_constructible<
508 tuple<_Args...>,
509 typename __make_tuple_types<tuple,
510 sizeof...(_Args) < sizeof...(_Tp) ?
511 sizeof...(_Args) :
512 sizeof...(_Tp)>::type
513 >::value &&
514 !__tuple_convertible<
515 tuple<_Args...>,
516 typename __make_tuple_types<tuple,
517 sizeof...(_Args) < sizeof...(_Tp) ?
518 sizeof...(_Args) :
519 sizeof...(_Tp)>::type
520 >::value &&
521 __all_default_constructible<
522 typename __make_tuple_types<tuple, sizeof...(_Tp),
523 sizeof...(_Args) < sizeof...(_Tp) ?
524 sizeof...(_Args) :
525 sizeof...(_Tp)>::type
526 >::value;
527 }
528
529 template <class ..._Args>
530 static constexpr bool __enable_implicit() {
531 return
532 __tuple_convertible<
533 tuple<_Args...>,
534 typename __make_tuple_types<tuple,
535 sizeof...(_Args) < sizeof...(_Tp) ?
536 sizeof...(_Args) :
537 sizeof...(_Tp)>::type
538 >::value &&
539 __all_default_constructible<
540 typename __make_tuple_types<tuple, sizeof...(_Tp),
541 sizeof...(_Args) < sizeof...(_Tp) ?
542 sizeof...(_Args) :
543 sizeof...(_Tp)>::type
544 >::value;
545 }
546 };
547
548 template <bool _MaybeEnable,
549 bool = sizeof...(_Tp) == 1,
550 class _Dummy = void>
551 struct _CheckTupleLikeConstructor : __check_tuple_constructor_fail {};
552
553 template <class _Dummy>
554 struct _CheckTupleLikeConstructor<true, false, _Dummy>
555 {
556 template <class _Tuple>
557 static constexpr bool __enable_implicit() {
Eric Fiselier9663ee42016-12-15 06:34:54 +0000558 return __tuple_convertible<_Tuple, tuple>::value;
Eric Fiselierd5019332016-04-15 18:05:59 +0000559 }
560
561 template <class _Tuple>
562 static constexpr bool __enable_explicit() {
Eric Fiselier9663ee42016-12-15 06:34:54 +0000563 return __tuple_constructible<_Tuple, tuple>::value
564 && !__tuple_convertible<_Tuple, tuple>::value;
Eric Fiselierd5019332016-04-15 18:05:59 +0000565 }
566 };
567
568 template <class _Dummy>
569 struct _CheckTupleLikeConstructor<true, true, _Dummy>
570 {
571 // This trait is used to disable the tuple-like constructor when
572 // the UTypes... constructor should be selected instead.
573 // See LWG issue #2549.
574 template <class _Tuple>
575 using _PreferTupleLikeConstructor = __lazy_or<
576 // Don't attempt the two checks below if the tuple we are given
577 // has the same type as this tuple.
578 is_same<typename __uncvref<_Tuple>::type, tuple>,
579 __lazy_and<
580 __lazy_not<is_constructible<_Tp..., _Tuple>>,
581 __lazy_not<is_convertible<_Tuple, _Tp...>>
582 >
583 >;
584
585 template <class _Tuple>
586 static constexpr bool __enable_implicit() {
587 return __lazy_and<
588 __tuple_convertible<_Tuple, tuple>,
589 _PreferTupleLikeConstructor<_Tuple>
590 >::value;
591 }
592
593 template <class _Tuple>
594 static constexpr bool __enable_explicit() {
595 return __lazy_and<
596 __tuple_constructible<_Tuple, tuple>,
597 _PreferTupleLikeConstructor<_Tuple>,
598 __lazy_not<__tuple_convertible<_Tuple, tuple>>
599 >::value;
600 }
601 };
602
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000603 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000604 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000605 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000606 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000607 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000608 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
Eric Fiselier199bee02015-12-18 00:36:55 +0000609 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
610 const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000611public:
612
Eric Fiselierda1818a2015-02-21 02:30:41 +0000613 template <bool _Dummy = true, class = typename enable_if<
Eric Fiseliere1445fd2016-07-25 04:32:07 +0000614 _CheckArgsConstructor<_Dummy>::template __enable_default<_Tp...>()
Marshall Clowbbc7c742014-10-15 10:33:02 +0000615 >::type>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000616 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000617 _LIBCPP_CONSTEXPR tuple()
618 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000619
Eric Fiselier4be71c62016-07-25 02:36:42 +0000620 tuple(tuple const&) = default;
621 tuple(tuple&&) = default;
622
Eric Fiselier55ad3ac2016-04-15 03:29:40 +0000623 template <class _AllocArgT, class _Alloc, bool _Dummy = true, class = typename enable_if<
624 __lazy_and<
Eric Fiselierfa5a1052016-06-21 23:19:13 +0000625 is_same<allocator_arg_t, _AllocArgT>,
Eric Fiselier55ad3ac2016-04-15 03:29:40 +0000626 __lazy_all<__dependent_type<is_default_constructible<_Tp>, _Dummy>...>
627 >::value
628 >::type>
629 _LIBCPP_INLINE_VISIBILITY
630 tuple(_AllocArgT, _Alloc const& __a)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000631 : __base_(allocator_arg_t(), __a,
Eric Fiselier55ad3ac2016-04-15 03:29:40 +0000632 __tuple_indices<>(), __tuple_types<>(),
633 typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
634 __tuple_types<_Tp...>()) {}
635
Eric Fiselier95526d32016-04-19 01:19:25 +0000636 template <bool _Dummy = true,
637 typename enable_if
638 <
639 _CheckArgsConstructor<
640 _Dummy
Eric Fiselierfc044a12016-11-13 19:54:31 +0000641 >::template __enable_implicit<_Tp const&...>(),
Eric Fiselier95526d32016-04-19 01:19:25 +0000642 bool
643 >::type = false
644 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000645 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Eric Fiselier95526d32016-04-19 01:19:25 +0000646 tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000647 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000648 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
649 typename __make_tuple_indices<0>::type(),
650 typename __make_tuple_types<tuple, 0>::type(),
651 __t...
652 ) {}
653
Eric Fiselier95526d32016-04-19 01:19:25 +0000654 template <bool _Dummy = true,
655 typename enable_if
656 <
657 _CheckArgsConstructor<
658 _Dummy
Eric Fiselierfc044a12016-11-13 19:54:31 +0000659 >::template __enable_explicit<_Tp const&...>(),
Eric Fiselier95526d32016-04-19 01:19:25 +0000660 bool
661 >::type = false
662 >
663 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
664 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000665 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
Eric Fiselier95526d32016-04-19 01:19:25 +0000666 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
667 typename __make_tuple_indices<0>::type(),
668 typename __make_tuple_types<tuple, 0>::type(),
669 __t...
670 ) {}
671
672 template <class _Alloc, bool _Dummy = true,
673 typename enable_if
674 <
675 _CheckArgsConstructor<
676 _Dummy
Eric Fiselierfc044a12016-11-13 19:54:31 +0000677 >::template __enable_implicit<_Tp const&...>(),
Eric Fiselier95526d32016-04-19 01:19:25 +0000678 bool
679 >::type = false
680 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000681 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000682 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000683 : __base_(allocator_arg_t(), __a,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000684 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
685 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
686 typename __make_tuple_indices<0>::type(),
687 typename __make_tuple_types<tuple, 0>::type(),
688 __t...
689 ) {}
690
Eric Fiselier95526d32016-04-19 01:19:25 +0000691 template <class _Alloc, bool _Dummy = true,
692 typename enable_if
693 <
694 _CheckArgsConstructor<
695 _Dummy
Eric Fiselierfc044a12016-11-13 19:54:31 +0000696 >::template __enable_explicit<_Tp const&...>(),
Eric Fiselier95526d32016-04-19 01:19:25 +0000697 bool
698 >::type = false
699 >
700 _LIBCPP_INLINE_VISIBILITY
701 explicit
702 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000703 : __base_(allocator_arg_t(), __a,
Eric Fiselier95526d32016-04-19 01:19:25 +0000704 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
705 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
706 typename __make_tuple_indices<0>::type(),
707 typename __make_tuple_types<tuple, 0>::type(),
708 __t...
709 ) {}
710
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000711 template <class ..._Up,
Eric Fiselierf2f36372016-12-08 23:57:08 +0000712 bool _PackIsTuple = _PackExpandsToThisTuple<_Up...>::value,
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000713 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000714 <
Eric Fiselierd5019332016-04-15 18:05:59 +0000715 _CheckArgsConstructor<
Eric Fiselierf2f36372016-12-08 23:57:08 +0000716 sizeof...(_Up) == sizeof...(_Tp)
717 && !_PackIsTuple
718 >::template __enable_implicit<_Up...>() ||
719 _CheckArgsConstructor<
720 _EnableImplicitReducedArityExtension
721 && sizeof...(_Up) < sizeof...(_Tp)
722 && !_PackIsTuple
Eric Fiselierd5019332016-04-15 18:05:59 +0000723 >::template __enable_implicit<_Up...>(),
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000724 bool
725 >::type = false
726 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000727 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000728 tuple(_Up&&... __u)
Howard Hinnant74f26f22012-07-06 21:53:48 +0000729 _NOEXCEPT_((
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000730 is_nothrow_constructible<_BaseT,
Howard Hinnant74f26f22012-07-06 21:53:48 +0000731 typename __make_tuple_indices<sizeof...(_Up)>::type,
732 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
733 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
734 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
Marshall Clow86d311c2014-09-16 17:08:21 +0000735 _Up...
Howard Hinnant74f26f22012-07-06 21:53:48 +0000736 >::value
737 ))
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000738 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000739 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
740 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
741 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
742 _VSTD::forward<_Up>(__u)...) {}
743
744 template <class ..._Up,
745 typename enable_if
746 <
Eric Fiselierd5019332016-04-15 18:05:59 +0000747 _CheckArgsConstructor<
748 sizeof...(_Up) <= sizeof...(_Tp)
749 && !_PackExpandsToThisTuple<_Up...>::value
Eric Fiselierf2f36372016-12-08 23:57:08 +0000750 >::template __enable_explicit<_Up...>() ||
751 _CheckArgsConstructor<
752 !_EnableImplicitReducedArityExtension
753 && sizeof...(_Up) < sizeof...(_Tp)
Eric Fiselier236b7522017-02-04 22:57:01 +0000754 && !_PackExpandsToThisTuple<_Up...>::value
Eric Fiselierf2f36372016-12-08 23:57:08 +0000755 >::template __enable_implicit<_Up...>(),
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000756 bool
Eric Fiselierd5019332016-04-15 18:05:59 +0000757 >::type = false
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000758 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000759 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000760 explicit
761 tuple(_Up&&... __u)
Howard Hinnant74f26f22012-07-06 21:53:48 +0000762 _NOEXCEPT_((
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000763 is_nothrow_constructible<_BaseT,
Howard Hinnant74f26f22012-07-06 21:53:48 +0000764 typename __make_tuple_indices<sizeof...(_Up)>::type,
765 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
766 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
767 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
768 _Up...
769 >::value
770 ))
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000771 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000772 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
773 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
774 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
Howard Hinnant0949eed2011-06-30 21:18:19 +0000775 _VSTD::forward<_Up>(__u)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000776
777 template <class _Alloc, class ..._Up,
Eric Fiselier95526d32016-04-19 01:19:25 +0000778 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000779 <
Eric Fiselierd5019332016-04-15 18:05:59 +0000780 _CheckArgsConstructor<
781 sizeof...(_Up) == sizeof...(_Tp) &&
782 !_PackExpandsToThisTuple<_Up...>::value
Eric Fiselier95526d32016-04-19 01:19:25 +0000783 >::template __enable_implicit<_Up...>(),
784 bool
785 >::type = false
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000786 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000787 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000788 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000789 : __base_(allocator_arg_t(), __a,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000790 typename __make_tuple_indices<sizeof...(_Up)>::type(),
791 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
792 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
793 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
Howard Hinnant0949eed2011-06-30 21:18:19 +0000794 _VSTD::forward<_Up>(__u)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000795
Eric Fiselier95526d32016-04-19 01:19:25 +0000796 template <class _Alloc, class ..._Up,
797 typename enable_if
798 <
799 _CheckArgsConstructor<
800 sizeof...(_Up) == sizeof...(_Tp) &&
801 !_PackExpandsToThisTuple<_Up...>::value
802 >::template __enable_explicit<_Up...>(),
803 bool
804 >::type = false
805 >
806 _LIBCPP_INLINE_VISIBILITY
807 explicit
808 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000809 : __base_(allocator_arg_t(), __a,
Eric Fiselier95526d32016-04-19 01:19:25 +0000810 typename __make_tuple_indices<sizeof...(_Up)>::type(),
811 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
812 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
813 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
814 _VSTD::forward<_Up>(__u)...) {}
815
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000816 template <class _Tuple,
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000817 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000818 <
Eric Fiselierd5019332016-04-15 18:05:59 +0000819 _CheckTupleLikeConstructor<
Eric Fiselier9663ee42016-12-15 06:34:54 +0000820 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
821 && !_PackExpandsToThisTuple<_Tuple>::value
822 >::template __enable_implicit<_Tuple>(),
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000823 bool
824 >::type = false
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000825 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000826 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000827 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
828 : __base_(_VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000829
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000830 template <class _Tuple,
831 typename enable_if
832 <
Eric Fiselierd5019332016-04-15 18:05:59 +0000833 _CheckTupleLikeConstructor<
Eric Fiselier9663ee42016-12-15 06:34:54 +0000834 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
835 && !_PackExpandsToThisTuple<_Tuple>::value
836 >::template __enable_explicit<_Tuple>(),
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000837 bool
838 >::type = false
839 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000840 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000841 explicit
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000842 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
843 : __base_(_VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000844
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000845 template <class _Alloc, class _Tuple,
Eric Fiselier95526d32016-04-19 01:19:25 +0000846 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000847 <
Eric Fiselierd5019332016-04-15 18:05:59 +0000848 _CheckTupleLikeConstructor<
Eric Fiselier9663ee42016-12-15 06:34:54 +0000849 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
850 >::template __enable_implicit<_Tuple>(),
Eric Fiselier95526d32016-04-19 01:19:25 +0000851 bool
852 >::type = false
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000853 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000854 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000855 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000856 : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000857
Eric Fiselier95526d32016-04-19 01:19:25 +0000858 template <class _Alloc, class _Tuple,
859 typename enable_if
860 <
861 _CheckTupleLikeConstructor<
Eric Fiselier9663ee42016-12-15 06:34:54 +0000862 __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
863 >::template __enable_explicit<_Tuple>(),
Eric Fiselier95526d32016-04-19 01:19:25 +0000864 bool
865 >::type = false
866 >
867 _LIBCPP_INLINE_VISIBILITY
868 explicit
869 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000870 : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
Eric Fiselier95526d32016-04-19 01:19:25 +0000871
Eric Fiselier4be71c62016-07-25 02:36:42 +0000872 using _CanCopyAssign = __all<is_copy_assignable<_Tp>::value...>;
873 using _CanMoveAssign = __all<is_move_assignable<_Tp>::value...>;
874
875 _LIBCPP_INLINE_VISIBILITY
Eric Fiselier9663ee42016-12-15 06:34:54 +0000876 tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, __nat>::type const& __t)
Eric Fiselier4be71c62016-07-25 02:36:42 +0000877 _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
878 {
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000879 __base_.operator=(__t.__base_);
Eric Fiselier4be71c62016-07-25 02:36:42 +0000880 return *this;
881 }
882
883 _LIBCPP_INLINE_VISIBILITY
884 tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, __nat>::type&& __t)
885 _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
886 {
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000887 __base_.operator=(static_cast<_BaseT&&>(__t.__base_));
Eric Fiselier4be71c62016-07-25 02:36:42 +0000888 return *this;
889 }
890
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000891 template <class _Tuple,
892 class = typename enable_if
893 <
Eric Fiselier9663ee42016-12-15 06:34:54 +0000894 __tuple_assignable<_Tuple, tuple>::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000895 >::type
896 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000897 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000898 tuple&
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000899 operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<_BaseT&, _Tuple>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000900 {
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000901 __base_.operator=(_VSTD::forward<_Tuple>(__t));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000902 return *this;
903 }
904
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000905 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000906 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000907 {__base_.swap(__t.__base_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000908};
909
910template <>
Eric Fiselierc3589a82017-01-04 23:56:00 +0000911class _LIBCPP_TEMPLATE_VIS tuple<>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000912{
913public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000914 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000915 _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000916 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000917 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000918 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000919 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000920 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000921 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
Howard Hinnant99968442011-11-29 18:15:50 +0000922 template <class _Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000923 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000924 tuple(array<_Up, 0>) _NOEXCEPT {}
Howard Hinnant99968442011-11-29 18:15:50 +0000925 template <class _Alloc, class _Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000926 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000927 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000928 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000929 void swap(tuple&) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000930};
931
Eric Fiselier8a29c9d2017-10-04 00:04:26 +0000932#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
Eric Fiselier3113ac62017-06-08 07:18:17 +0000933// NOTE: These are not yet standardized, but are required to simulate the
934// implicit deduction guide that should be generated had libc++ declared the
935// tuple-like constructors "correctly"
936template <class _Alloc, class ..._Args>
937tuple(allocator_arg_t, const _Alloc&, tuple<_Args...> const&) -> tuple<_Args...>;
938template <class _Alloc, class ..._Args>
939tuple(allocator_arg_t, const _Alloc&, tuple<_Args...>&&) -> tuple<_Args...>;
940#endif
941
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000942template <class ..._Tp>
943inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantaabf2872011-06-01 19:59:32 +0000944typename enable_if
945<
946 __all<__is_swappable<_Tp>::value...>::value,
947 void
948>::type
Howard Hinnanta5e01212011-05-27 19:08:18 +0000949swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
950 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
951 {__t.swap(__u);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000952
953// get
954
955template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000956inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25 +0000957typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000958get(tuple<_Tp...>& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000959{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000960 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000961 return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000962}
963
964template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000965inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25 +0000966const typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000967get(const tuple<_Tp...>& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000968{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000969 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000970 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000971}
972
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000973template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000974inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25 +0000975typename tuple_element<_Ip, tuple<_Tp...> >::type&&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000976get(tuple<_Tp...>&& __t) _NOEXCEPT
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000977{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000978 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnant56a85ca2011-01-25 16:31:30 +0000979 return static_cast<type&&>(
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000980 static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000981}
982
Eric Fiselier199bee02015-12-18 00:36:55 +0000983template <size_t _Ip, class ..._Tp>
984inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
985const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
986get(const tuple<_Tp...>&& __t) _NOEXCEPT
987{
988 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
989 return static_cast<const type&&>(
Eric Fiselierbf86c8f2017-06-01 02:14:21 +0000990 static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
Eric Fiselier199bee02015-12-18 00:36:55 +0000991}
992
Marshall Clowe8029e52013-07-13 02:54:05 +0000993#if _LIBCPP_STD_VER > 11
Marshall Clowe8029e52013-07-13 02:54:05 +0000994
Eric Fiselier22c3e762016-07-02 03:18:30 +0000995namespace __find_detail {
Marshall Clowe8029e52013-07-13 02:54:05 +0000996
Eric Fiselier22c3e762016-07-02 03:18:30 +0000997static constexpr size_t __not_found = -1;
998static constexpr size_t __ambiguous = __not_found - 1;
Marshall Clowe8029e52013-07-13 02:54:05 +0000999
Eric Fiselier22c3e762016-07-02 03:18:30 +00001000inline _LIBCPP_INLINE_VISIBILITY
1001constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
1002 return !__matches ? __res :
1003 (__res == __not_found ? __curr_i : __ambiguous);
1004}
Marshall Clowe8029e52013-07-13 02:54:05 +00001005
Eric Fiselier22c3e762016-07-02 03:18:30 +00001006template <size_t _Nx>
1007inline _LIBCPP_INLINE_VISIBILITY
1008constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
1009 return __i == _Nx ? __not_found :
1010 __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]);
1011}
1012
1013template <class _T1, class ..._Args>
1014struct __find_exactly_one_checked {
1015 static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
1016 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
1017 static_assert (value != __not_found, "type not found in type list" );
1018 static_assert(value != __ambiguous,"type occurs more than once in type list");
1019};
1020
Eric Fiselier990090f2016-07-02 03:46:08 +00001021template <class _T1>
1022struct __find_exactly_one_checked<_T1> {
1023 static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
1024};
1025
Eric Fiselier22c3e762016-07-02 03:18:30 +00001026} // namespace __find_detail;
Marshall Clowe8029e52013-07-13 02:54:05 +00001027
1028template <typename _T1, typename... _Args>
Eric Fiselier22c3e762016-07-02 03:18:30 +00001029struct __find_exactly_one_t
1030 : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
1031};
Marshall Clowe8029e52013-07-13 02:54:05 +00001032
1033template <class _T1, class... _Args>
1034inline _LIBCPP_INLINE_VISIBILITY
1035constexpr _T1& get(tuple<_Args...>& __tup) noexcept
1036{
1037 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1038}
1039
1040template <class _T1, class... _Args>
1041inline _LIBCPP_INLINE_VISIBILITY
1042constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
1043{
1044 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1045}
1046
1047template <class _T1, class... _Args>
1048inline _LIBCPP_INLINE_VISIBILITY
1049constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
1050{
Marshall Clow01a0e902013-07-15 20:46:11 +00001051 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
Marshall Clowe8029e52013-07-13 02:54:05 +00001052}
1053
Eric Fiselier199bee02015-12-18 00:36:55 +00001054template <class _T1, class... _Args>
1055inline _LIBCPP_INLINE_VISIBILITY
1056constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
1057{
1058 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1059}
1060
Marshall Clowe8029e52013-07-13 02:54:05 +00001061#endif
1062
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001063// tie
1064
1065template <class ..._Tp>
Marshall Clow8e554d92014-02-25 16:11:46 +00001066inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001067tuple<_Tp&...>
Howard Hinnant74f26f22012-07-06 21:53:48 +00001068tie(_Tp&... __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001069{
1070 return tuple<_Tp&...>(__t...);
1071}
1072
1073template <class _Up>
1074struct __ignore_t
1075{
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001076 template <class _Tp>
Eric Fiselier07d23d52017-02-06 01:25:31 +00001077 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1078 const __ignore_t& operator=(_Tp&&) const {return *this;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001079};
1080
Eric Fiselier07d23d52017-02-06 01:25:31 +00001081namespace {
1082 constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
1083}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001084
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001085template <class _Tp>
Marshall Clowa71f9562014-01-03 22:55:49 +00001086struct __make_tuple_return_impl
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001087{
1088 typedef _Tp type;
1089};
1090
1091template <class _Tp>
Marshall Clowa71f9562014-01-03 22:55:49 +00001092struct __make_tuple_return_impl<reference_wrapper<_Tp> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001093{
1094 typedef _Tp& type;
1095};
1096
1097template <class _Tp>
1098struct __make_tuple_return
1099{
Marshall Clowa71f9562014-01-03 22:55:49 +00001100 typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001101};
1102
1103template <class... _Tp>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001104inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001105tuple<typename __make_tuple_return<_Tp>::type...>
1106make_tuple(_Tp&&... __t)
1107{
Howard Hinnant0949eed2011-06-30 21:18:19 +00001108 return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001109}
1110
Howard Hinnant3c1ffba2010-08-19 18:59:38 +00001111template <class... _Tp>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001112inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1113tuple<_Tp&&...>
Howard Hinnant74f26f22012-07-06 21:53:48 +00001114forward_as_tuple(_Tp&&... __t) _NOEXCEPT
Howard Hinnant3c1ffba2010-08-19 18:59:38 +00001115{
Howard Hinnant0949eed2011-06-30 21:18:19 +00001116 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnant3c1ffba2010-08-19 18:59:38 +00001117}
1118
Howard Hinnant99968442011-11-29 18:15:50 +00001119template <size_t _Ip>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001120struct __tuple_equal
1121{
1122 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001123 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001124 bool operator()(const _Tp& __x, const _Up& __y)
1125 {
Marshall Clowba6dbf42014-06-24 00:46:19 +00001126 return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001127 }
1128};
1129
1130template <>
1131struct __tuple_equal<0>
1132{
1133 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001134 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001135 bool operator()(const _Tp&, const _Up&)
1136 {
1137 return true;
1138 }
1139};
1140
1141template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001142inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001143bool
1144operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1145{
1146 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
1147}
1148
1149template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001150inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001151bool
1152operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1153{
1154 return !(__x == __y);
1155}
1156
Howard Hinnant99968442011-11-29 18:15:50 +00001157template <size_t _Ip>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001158struct __tuple_less
1159{
1160 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001161 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001162 bool operator()(const _Tp& __x, const _Up& __y)
1163 {
Duncan P. N. Exon Smith07b133f2015-01-21 02:51:17 +00001164 const size_t __idx = tuple_size<_Tp>::value - _Ip;
1165 if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
1166 return true;
1167 if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
1168 return false;
1169 return __tuple_less<_Ip-1>()(__x, __y);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001170 }
1171};
1172
1173template <>
1174struct __tuple_less<0>
1175{
1176 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001177 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001178 bool operator()(const _Tp&, const _Up&)
1179 {
1180 return false;
1181 }
1182};
1183
1184template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001185inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001186bool
1187operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1188{
1189 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
1190}
1191
1192template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001193inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001194bool
1195operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1196{
1197 return __y < __x;
1198}
1199
1200template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001201inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001202bool
1203operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1204{
1205 return !(__x < __y);
1206}
1207
1208template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001209inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001210bool
1211operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1212{
1213 return !(__y < __x);
1214}
1215
1216// tuple_cat
1217
Howard Hinnant0e1493e2010-12-11 20:47:50 +00001218template <class _Tp, class _Up> struct __tuple_cat_type;
1219
1220template <class ..._Ttypes, class ..._Utypes>
Howard Hinnantf83417b2011-01-24 16:07:25 +00001221struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001222{
Howard Hinnant0e1493e2010-12-11 20:47:50 +00001223 typedef tuple<_Ttypes..., _Utypes...> type;
1224};
1225
1226template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
1227struct __tuple_cat_return_1
1228{
1229};
1230
1231template <class ..._Types, class _Tuple0>
1232struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
1233{
1234 typedef typename __tuple_cat_type<tuple<_Types...>,
1235 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
1236 type;
1237};
1238
1239template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
1240struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
1241 : public __tuple_cat_return_1<
1242 typename __tuple_cat_type<
1243 tuple<_Types...>,
1244 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
1245 >::type,
1246 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
1247 _Tuple1, _Tuples...>
1248{
1249};
1250
1251template <class ..._Tuples> struct __tuple_cat_return;
1252
1253template <class _Tuple0, class ..._Tuples>
1254struct __tuple_cat_return<_Tuple0, _Tuples...>
1255 : public __tuple_cat_return_1<tuple<>,
1256 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
1257 _Tuples...>
1258{
1259};
1260
1261template <>
1262struct __tuple_cat_return<>
1263{
1264 typedef tuple<> type;
1265};
1266
Marshall Clowda0a0e82013-07-22 16:02:19 +00001267inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant0e1493e2010-12-11 20:47:50 +00001268tuple<>
1269tuple_cat()
1270{
1271 return tuple<>();
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001272}
1273
Howard Hinnant99968442011-11-29 18:15:50 +00001274template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
Howard Hinnante48e3662010-12-12 23:04:37 +00001275struct __tuple_cat_return_ref_imp;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001276
Howard Hinnante48e3662010-12-12 23:04:37 +00001277template <class ..._Types, size_t ..._I0, class _Tuple0>
1278struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001279{
Howard Hinnant0e1493e2010-12-11 20:47:50 +00001280 typedef typename remove_reference<_Tuple0>::type _T0;
Howard Hinnante48e3662010-12-12 23:04:37 +00001281 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1282 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1283};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001284
Howard Hinnante48e3662010-12-12 23:04:37 +00001285template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1286struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1287 _Tuple0, _Tuple1, _Tuples...>
1288 : public __tuple_cat_return_ref_imp<
1289 tuple<_Types..., typename __apply_cv<_Tuple0,
1290 typename tuple_element<_I0,
1291 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1292 typename __make_tuple_indices<tuple_size<typename
1293 remove_reference<_Tuple1>::type>::value>::type,
1294 _Tuple1, _Tuples...>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001295{
Howard Hinnante48e3662010-12-12 23:04:37 +00001296};
1297
1298template <class _Tuple0, class ..._Tuples>
1299struct __tuple_cat_return_ref
1300 : public __tuple_cat_return_ref_imp<tuple<>,
1301 typename __make_tuple_indices<
1302 tuple_size<typename remove_reference<_Tuple0>::type>::value
1303 >::type, _Tuple0, _Tuples...>
1304{
1305};
1306
1307template <class _Types, class _I0, class _J0>
1308struct __tuple_cat;
1309
1310template <class ..._Types, size_t ..._I0, size_t ..._J0>
Howard Hinnantf83417b2011-01-24 16:07:25 +00001311struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
Howard Hinnante48e3662010-12-12 23:04:37 +00001312{
1313 template <class _Tuple0>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001314 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001315 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1316 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1317 {
Marshall Clowba6dbf42014-06-24 00:46:19 +00001318 return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1319 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
Howard Hinnante48e3662010-12-12 23:04:37 +00001320 }
1321
1322 template <class _Tuple0, class _Tuple1, class ..._Tuples>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001323 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001324 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1325 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1326 {
1327 typedef typename remove_reference<_Tuple0>::type _T0;
1328 typedef typename remove_reference<_Tuple1>::type _T1;
1329 return __tuple_cat<
1330 tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1331 typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1332 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
Marshall Clow1d927e32013-10-05 18:46:37 +00001333 (forward_as_tuple(
Marshall Clowba6dbf42014-06-24 00:46:19 +00001334 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1335 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
Howard Hinnante48e3662010-12-12 23:04:37 +00001336 ),
Howard Hinnant0949eed2011-06-30 21:18:19 +00001337 _VSTD::forward<_Tuple1>(__t1),
1338 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnante48e3662010-12-12 23:04:37 +00001339 }
1340};
1341
1342template <class _Tuple0, class... _Tuples>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001343inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001344typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1345tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1346{
1347 typedef typename remove_reference<_Tuple0>::type _T0;
1348 return __tuple_cat<tuple<>, __tuple_indices<>,
1349 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
Howard Hinnant0949eed2011-06-30 21:18:19 +00001350 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1351 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001352}
1353
1354template <class ..._Tp, class _Alloc>
Eric Fiselierc3589a82017-01-04 23:56:00 +00001355struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001356 : true_type {};
1357
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001358template <class _T1, class _T2>
1359template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1360inline _LIBCPP_INLINE_VISIBILITY
1361pair<_T1, _T2>::pair(piecewise_construct_t,
1362 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1363 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
Marshall Clowba6dbf42014-06-24 00:46:19 +00001364 : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
1365 second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001366{
1367}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001368
Eric Fiselier5839fed2016-07-18 00:35:56 +00001369#if _LIBCPP_STD_VER > 14
1370template <class _Tp>
1371constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
1372
1373#define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
1374
1375template <class _Fn, class _Tuple, size_t ..._Id>
1376inline _LIBCPP_INLINE_VISIBILITY
1377constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
1378 __tuple_indices<_Id...>)
1379_LIBCPP_NOEXCEPT_RETURN(
1380 _VSTD::__invoke_constexpr(
1381 _VSTD::forward<_Fn>(__f),
1382 _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
1383)
1384
1385template <class _Fn, class _Tuple>
1386inline _LIBCPP_INLINE_VISIBILITY
1387constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
1388_LIBCPP_NOEXCEPT_RETURN(
1389 _VSTD::__apply_tuple_impl(
1390 _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
1391 typename __make_tuple_indices<tuple_size_v<decay_t<_Tuple>>>::type{})
1392)
1393
1394template <class _Tp, class _Tuple, size_t... _Idx>
1395inline _LIBCPP_INLINE_VISIBILITY
1396constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
1397_LIBCPP_NOEXCEPT_RETURN(
1398 _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...)
1399)
1400
1401template <class _Tp, class _Tuple>
1402inline _LIBCPP_INLINE_VISIBILITY
1403constexpr _Tp make_from_tuple(_Tuple&& __t)
1404_LIBCPP_NOEXCEPT_RETURN(
1405 _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
1406 typename __make_tuple_indices<tuple_size_v<decay_t<_Tuple>>>::type{})
1407)
1408
1409#undef _LIBCPP_NOEXCEPT_RETURN
1410
1411#endif // _LIBCPP_STD_VER > 14
1412
Eric Fiselier191f0752017-04-19 01:23:39 +00001413#endif // !defined(_LIBCPP_CXX03_LANG)
1414
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001415_LIBCPP_END_NAMESPACE_STD
1416
1417#endif // _LIBCPP_TUPLE