blob: 30a958abcd3c23d699b2e2af4d62b9ac4721fb11 [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
Howard Hinnant0e1493e2010-12-11 20:47:50 +000079
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000080// 20.4.1.4, tuple helper classes:
81template <class T> class tuple_size; // undefined
82template <class... T> class tuple_size<tuple<T...>>;
83template <intsize_t I, class T> class tuple_element; // undefined
84template <intsize_t I, class... T> class tuple_element<I, tuple<T...>>;
85
86// 20.4.1.5, element access:
Howard Hinnanta5e01212011-05-27 19:08:18 +000087template <intsize_t I, class... T>
88 typename tuple_element<I, tuple<T...>>::type&
Marshall Clow8fc4f5a2013-07-17 18:25:36 +000089 get(tuple<T...>&) noexcept; // constexpr in C++14
Howard Hinnanta5e01212011-05-27 19:08:18 +000090template <intsize_t I, class... T>
91 typename tuple_element<I, tuple<T...>>::type const&
Marshall Clow8fc4f5a2013-07-17 18:25:36 +000092 get(const tuple<T...>&) noexcept; // constexpr in C++14
Howard Hinnanta5e01212011-05-27 19:08:18 +000093template <intsize_t I, class... T>
94 typename tuple_element<I, tuple<T...>>::type&&
Marshall Clow8fc4f5a2013-07-17 18:25:36 +000095 get(tuple<T...>&&) noexcept; // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000096
Marshall Clowe8029e52013-07-13 02:54:05 +000097template <class T1, class... T>
98 constexpr T1& get(tuple<T...>&) noexcept; // C++14
99template <class T1, class... T>
100 constexpr T1 const& get(const tuple<T...>&) noexcept; // C++14
101template <class T1, class... T>
102 constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
103
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000104// 20.4.1.6, relational operators:
Marshall Clowda0a0e82013-07-22 16:02:19 +0000105template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
106template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
107template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
108template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
109template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
110template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000111
112template <class... Types, class Alloc>
113 struct uses_allocator<tuple<Types...>, Alloc>;
114
115template <class... Types>
Howard Hinnanta5e01212011-05-27 19:08:18 +0000116 void
117 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000118
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000119} // std
120
121*/
122
123#include <__config>
124#include <__tuple>
125#include <cstddef>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000126#include <type_traits>
Howard Hinnant6cc99fa2011-12-19 17:58:44 +0000127#include <__functional_base>
128#include <utility>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000129
Howard Hinnant08e17472011-10-17 20:05:10 +0000130#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000131#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000132#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000133
134_LIBCPP_BEGIN_NAMESPACE_STD
135
136#ifndef _LIBCPP_HAS_NO_VARIADICS
137
138// tuple_size
139
140template <class ..._Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000141class _LIBCPP_TYPE_VIS_ONLY tuple_size<tuple<_Tp...> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000142 : public integral_constant<size_t, sizeof...(_Tp)>
143{
144};
145
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000146// tuple_element
147
148template <size_t _Ip, class ..._Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000149class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000150{
151public:
Howard Hinnantf83417b2011-01-24 16:07:25 +0000152 typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000153};
154
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000155// __tuple_leaf
156
Howard Hinnantd4cf2152011-12-11 20:31:33 +0000157template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
158#if __has_feature(is_final)
159 && !__is_final(_Hp)
160#endif
161 >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000162class __tuple_leaf;
163
164template <size_t _Ip, class _Hp, bool _Ep>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000165inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000166void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
Howard Hinnanta5e01212011-05-27 19:08:18 +0000167 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000168{
169 swap(__x.get(), __y.get());
170}
171
172template <size_t _Ip, class _Hp, bool>
173class __tuple_leaf
174{
175 _Hp value;
176
177 __tuple_leaf& operator=(const __tuple_leaf&);
178public:
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000179 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
180 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value()
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000181 {static_assert(!is_reference<_Hp>::value,
182 "Attempted to default construct a reference element in a tuple");}
183
184 template <class _Alloc>
185 _LIBCPP_INLINE_VISIBILITY
186 __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
187 : value()
188 {static_assert(!is_reference<_Hp>::value,
189 "Attempted to default construct a reference element in a tuple");}
190
191 template <class _Alloc>
192 _LIBCPP_INLINE_VISIBILITY
193 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
194 : value(allocator_arg_t(), __a)
195 {static_assert(!is_reference<_Hp>::value,
196 "Attempted to default construct a reference element in a tuple");}
197
198 template <class _Alloc>
199 _LIBCPP_INLINE_VISIBILITY
200 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
201 : value(__a)
202 {static_assert(!is_reference<_Hp>::value,
203 "Attempted to default construct a reference element in a tuple");}
204
Howard Hinnante049cc52010-09-27 17:54:17 +0000205 template <class _Tp,
206 class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000207 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000208 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000209 : value(_VSTD::forward<_Tp>(__t))
Howard Hinnante049cc52010-09-27 17:54:17 +0000210 {static_assert(!is_reference<_Hp>::value ||
Howard Hinnantec3773c2011-12-01 20:21:04 +0000211 (is_lvalue_reference<_Hp>::value &&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000212 (is_lvalue_reference<_Tp>::value ||
213 is_same<typename remove_reference<_Tp>::type,
214 reference_wrapper<
215 typename remove_reference<_Hp>::type
216 >
Howard Hinnantec3773c2011-12-01 20:21:04 +0000217 >::value)) ||
Howard Hinnante049cc52010-09-27 17:54:17 +0000218 (is_rvalue_reference<_Hp>::value &&
219 !is_lvalue_reference<_Tp>::value),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000220 "Attempted to construct a reference element in a tuple with an rvalue");}
221
222 template <class _Tp, class _Alloc>
223 _LIBCPP_INLINE_VISIBILITY
224 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000225 : value(_VSTD::forward<_Tp>(__t))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000226 {static_assert(!is_lvalue_reference<_Hp>::value ||
Howard Hinnantec3773c2011-12-01 20:21:04 +0000227 (is_lvalue_reference<_Hp>::value &&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000228 (is_lvalue_reference<_Tp>::value ||
229 is_same<typename remove_reference<_Tp>::type,
230 reference_wrapper<
231 typename remove_reference<_Hp>::type
232 >
Howard Hinnantec3773c2011-12-01 20:21:04 +0000233 >::value)),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000234 "Attempted to construct a reference element in a tuple with an rvalue");}
235
236 template <class _Tp, class _Alloc>
237 _LIBCPP_INLINE_VISIBILITY
238 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000239 : value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000240 {static_assert(!is_lvalue_reference<_Hp>::value ||
Howard Hinnantec3773c2011-12-01 20:21:04 +0000241 (is_lvalue_reference<_Hp>::value &&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000242 (is_lvalue_reference<_Tp>::value ||
243 is_same<typename remove_reference<_Tp>::type,
244 reference_wrapper<
245 typename remove_reference<_Hp>::type
246 >
Howard Hinnantec3773c2011-12-01 20:21:04 +0000247 >::value)),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000248 "Attempted to construct a reference element in a tuple with an rvalue");}
249
250 template <class _Tp, class _Alloc>
251 _LIBCPP_INLINE_VISIBILITY
252 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000253 : value(_VSTD::forward<_Tp>(__t), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000254 {static_assert(!is_lvalue_reference<_Hp>::value ||
Howard Hinnantec3773c2011-12-01 20:21:04 +0000255 (is_lvalue_reference<_Hp>::value &&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000256 (is_lvalue_reference<_Tp>::value ||
257 is_same<typename remove_reference<_Tp>::type,
258 reference_wrapper<
259 typename remove_reference<_Hp>::type
260 >
Howard Hinnantec3773c2011-12-01 20:21:04 +0000261 >::value)),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000262 "Attempted to construct a reference element in a tuple with an rvalue");}
263
Marshall Clowda0a0e82013-07-22 16:02:19 +0000264 _LIBCPP_INLINE_VISIBILITY
265 _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000266 __tuple_leaf(const __tuple_leaf& __t) _NOEXCEPT_(is_nothrow_copy_constructible<_Hp>::value)
Howard Hinnante049cc52010-09-27 17:54:17 +0000267 : value(__t.get())
268 {static_assert(!is_rvalue_reference<_Hp>::value, "Can not copy a tuple with rvalue reference member");}
269
Marshall Clowda0a0e82013-07-22 16:02:19 +0000270 _LIBCPP_INLINE_VISIBILITY
271 _LIBCPP_CONSTEXPR_AFTER_CXX11
272 __tuple_leaf(__tuple_leaf&& __t) _NOEXCEPT_(is_nothrow_move_constructible<_Hp>::value)
Howard Hinnant3de50862013-11-06 17:45:43 +0000273 : value(_VSTD::forward<_Hp>(__t.get()))
Marshall Clowda0a0e82013-07-22 16:02:19 +0000274 {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000275
276 template <class _Tp>
277 _LIBCPP_INLINE_VISIBILITY
278 __tuple_leaf&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000279 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000280 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000281 value = _VSTD::forward<_Tp>(__t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000282 return *this;
283 }
284
285 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000286 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000287 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000288 _VSTD::swap(*this, __t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000289 return 0;
290 }
291
Marshall Clowda0a0e82013-07-22 16:02:19 +0000292 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return value;}
293 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return value;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000294};
295
296template <size_t _Ip, class _Hp>
297class __tuple_leaf<_Ip, _Hp, true>
298 : private _Hp
299{
300
301 __tuple_leaf& operator=(const __tuple_leaf&);
302public:
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000303 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
304 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000305
306 template <class _Alloc>
307 _LIBCPP_INLINE_VISIBILITY
308 __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
309
310 template <class _Alloc>
311 _LIBCPP_INLINE_VISIBILITY
312 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
313 : _Hp(allocator_arg_t(), __a) {}
314
315 template <class _Alloc>
316 _LIBCPP_INLINE_VISIBILITY
317 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
318 : _Hp(__a) {}
319
Howard Hinnante049cc52010-09-27 17:54:17 +0000320 template <class _Tp,
321 class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000322 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000323 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000324 : _Hp(_VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000325
326 template <class _Tp, class _Alloc>
327 _LIBCPP_INLINE_VISIBILITY
328 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000329 : _Hp(_VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000330
331 template <class _Tp, class _Alloc>
332 _LIBCPP_INLINE_VISIBILITY
333 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000334 : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000335
336 template <class _Tp, class _Alloc>
337 _LIBCPP_INLINE_VISIBILITY
338 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000339 : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000340
341 template <class _Tp>
342 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000343 __tuple_leaf&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000344 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000345 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000346 _Hp::operator=(_VSTD::forward<_Tp>(__t));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000347 return *this;
348 }
349
Howard Hinnanta5e01212011-05-27 19:08:18 +0000350 _LIBCPP_INLINE_VISIBILITY
351 int
352 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000353 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000354 _VSTD::swap(*this, __t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000355 return 0;
356 }
357
Marshall Clowda0a0e82013-07-22 16:02:19 +0000358 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
359 _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 +0000360};
361
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000362template <class ..._Tp>
363_LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000364void __swallow(_Tp&&...) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000365
Howard Hinnanta5e01212011-05-27 19:08:18 +0000366template <bool ...> struct __all;
367
368template <>
369struct __all<>
370{
371 static const bool value = true;
372};
373
Howard Hinnant99968442011-11-29 18:15:50 +0000374template <bool _B0, bool ... _Bp>
375struct __all<_B0, _Bp...>
Howard Hinnanta5e01212011-05-27 19:08:18 +0000376{
Howard Hinnant99968442011-11-29 18:15:50 +0000377 static const bool value = _B0 && __all<_Bp...>::value;
Howard Hinnanta5e01212011-05-27 19:08:18 +0000378};
379
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000380// __tuple_impl
381
382template<class _Indx, class ..._Tp> struct __tuple_impl;
383
384template<size_t ..._Indx, class ..._Tp>
385struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
386 : public __tuple_leaf<_Indx, _Tp>...
387{
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000388 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000389 _LIBCPP_CONSTEXPR __tuple_impl()
390 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000391
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000392 template <size_t ..._Uf, class ..._Tf,
393 size_t ..._Ul, class ..._Tl, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000394 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000395 explicit
396 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
397 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
Howard Hinnant74f26f22012-07-06 21:53:48 +0000398 _Up&&... __u)
399 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
400 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
Howard Hinnant0949eed2011-06-30 21:18:19 +0000401 __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000402 __tuple_leaf<_Ul, _Tl>()...
403 {}
404
405 template <class _Alloc, size_t ..._Uf, class ..._Tf,
406 size_t ..._Ul, class ..._Tl, class ..._Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000407 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000408 explicit
409 __tuple_impl(allocator_arg_t, const _Alloc& __a,
410 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
411 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
412 _Up&&... __u) :
413 __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
Howard Hinnant0949eed2011-06-30 21:18:19 +0000414 _VSTD::forward<_Up>(__u))...,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000415 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
416 {}
417
418 template <class _Tuple,
419 class = typename enable_if
420 <
Howard Hinnant99324892013-04-14 00:01:13 +0000421 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000422 >::type
423 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000424 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000425 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
426 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000427 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
428 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000429 {}
430
431 template <class _Alloc, class _Tuple,
432 class = typename enable_if
433 <
Howard Hinnantf83417b2011-01-24 16:07:25 +0000434 __tuple_convertible<_Tuple, tuple<_Tp...> >::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000435 >::type
436 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000437 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000438 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
439 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
Howard Hinnant324bb032010-08-22 00:02:43 +0000440 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
Howard Hinnant0949eed2011-06-30 21:18:19 +0000441 _VSTD::forward<typename tuple_element<_Indx,
442 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000443 {}
444
445 template <class _Tuple>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000446 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000447 typename enable_if
448 <
Howard Hinnantf83417b2011-01-24 16:07:25 +0000449 __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000450 __tuple_impl&
451 >::type
Howard Hinnant74f26f22012-07-06 21:53:48 +0000452 operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
453 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000454 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000455 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
456 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000457 return *this;
458 }
459
Howard Hinnant3de50862013-11-06 17:45:43 +0000460 __tuple_impl(const __tuple_impl&) = default;
461 __tuple_impl(__tuple_impl&&) = default;
462
463 _LIBCPP_INLINE_VISIBILITY
464 __tuple_impl&
465 operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
466 {
467 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
468 return *this;
469 }
470
471 _LIBCPP_INLINE_VISIBILITY
472 __tuple_impl&
473 operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
474 {
475 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
476 return *this;
477 }
Howard Hinnant28484442012-02-15 20:13:52 +0000478
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000479 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000480 void swap(__tuple_impl& __t)
Howard Hinnanta5e01212011-05-27 19:08:18 +0000481 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000482 {
483 __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
484 }
485};
486
487template <class ..._Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000488class _LIBCPP_TYPE_VIS_ONLY tuple
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000489{
490 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
491
492 base base_;
493
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000494 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000495 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000496 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000497 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000498 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000499 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000500public:
501
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000502 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000503 _LIBCPP_CONSTEXPR tuple()
504 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000505
Marshall Clowda0a0e82013-07-22 16:02:19 +0000506 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000507 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000508 : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
509 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
510 typename __make_tuple_indices<0>::type(),
511 typename __make_tuple_types<tuple, 0>::type(),
512 __t...
513 ) {}
514
515 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000516 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000517 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
518 : base_(allocator_arg_t(), __a,
519 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
520 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
521 typename __make_tuple_indices<0>::type(),
522 typename __make_tuple_types<tuple, 0>::type(),
523 __t...
524 ) {}
525
526 template <class ..._Up,
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000527 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000528 <
529 sizeof...(_Up) <= sizeof...(_Tp) &&
530 __tuple_convertible
531 <
532 tuple<_Up...>,
533 typename __make_tuple_types<tuple,
534 sizeof...(_Up) < sizeof...(_Tp) ?
535 sizeof...(_Up) :
536 sizeof...(_Tp)>::type
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000537 >::value,
538 bool
539 >::type = false
540 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000541 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000542 tuple(_Up&&... __u)
Howard Hinnant74f26f22012-07-06 21:53:48 +0000543 _NOEXCEPT_((
544 is_nothrow_constructible<
545 typename __make_tuple_indices<sizeof...(_Up)>::type,
546 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
547 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
548 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
549 _Up...
550 >::value
551 ))
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000552 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
553 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
554 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
555 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
556 _VSTD::forward<_Up>(__u)...) {}
557
558 template <class ..._Up,
559 typename enable_if
560 <
561 sizeof...(_Up) <= sizeof...(_Tp) &&
562 __tuple_constructible
563 <
564 tuple<_Up...>,
565 typename __make_tuple_types<tuple,
566 sizeof...(_Up) < sizeof...(_Tp) ?
567 sizeof...(_Up) :
568 sizeof...(_Tp)>::type
569 >::value &&
570 !__tuple_convertible
571 <
572 tuple<_Up...>,
573 typename __make_tuple_types<tuple,
574 sizeof...(_Up) < sizeof...(_Tp) ?
575 sizeof...(_Up) :
576 sizeof...(_Tp)>::type
577 >::value,
578 bool
579 >::type =false
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000580 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000581 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000582 explicit
583 tuple(_Up&&... __u)
Howard Hinnant74f26f22012-07-06 21:53:48 +0000584 _NOEXCEPT_((
585 is_nothrow_constructible<
586 typename __make_tuple_indices<sizeof...(_Up)>::type,
587 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
588 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
589 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
590 _Up...
591 >::value
592 ))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000593 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
594 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
595 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
596 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
Howard Hinnant0949eed2011-06-30 21:18:19 +0000597 _VSTD::forward<_Up>(__u)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000598
599 template <class _Alloc, class ..._Up,
600 class = typename enable_if
601 <
602 sizeof...(_Up) <= sizeof...(_Tp) &&
603 __tuple_convertible
604 <
605 tuple<_Up...>,
606 typename __make_tuple_types<tuple,
607 sizeof...(_Up) < sizeof...(_Tp) ?
608 sizeof...(_Up) :
609 sizeof...(_Tp)>::type
610 >::value
611 >::type
612 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000613 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000614 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
615 : base_(allocator_arg_t(), __a,
616 typename __make_tuple_indices<sizeof...(_Up)>::type(),
617 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
618 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
619 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
Howard Hinnant0949eed2011-06-30 21:18:19 +0000620 _VSTD::forward<_Up>(__u)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000621
622 template <class _Tuple,
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000623 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000624 <
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000625 __tuple_convertible<_Tuple, tuple>::value,
626 bool
627 >::type = false
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000628 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000629 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000630 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000631 : base_(_VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000632
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000633 template <class _Tuple,
634 typename enable_if
635 <
636 __tuple_constructible<_Tuple, tuple>::value &&
637 !__tuple_convertible<_Tuple, tuple>::value,
638 bool
639 >::type = false
640 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000641 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000642 explicit
Howard Hinnant74f26f22012-07-06 21:53:48 +0000643 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000644 : base_(_VSTD::forward<_Tuple>(__t)) {}
645
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000646 template <class _Alloc, class _Tuple,
647 class = typename enable_if
648 <
649 __tuple_convertible<_Tuple, tuple>::value
650 >::type
651 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000652 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000653 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000654 : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000655
656 template <class _Tuple,
657 class = typename enable_if
658 <
659 __tuple_assignable<_Tuple, tuple>::value
660 >::type
661 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000662 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000663 tuple&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000664 operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000665 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000666 base_.operator=(_VSTD::forward<_Tuple>(__t));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000667 return *this;
668 }
669
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000670 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000671 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
672 {base_.swap(__t.base_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000673};
674
675template <>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000676class _LIBCPP_TYPE_VIS_ONLY tuple<>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000677{
678public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000679 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000680 _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000681 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000682 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000683 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000684 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000685 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000686 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
Howard Hinnant99968442011-11-29 18:15:50 +0000687 template <class _Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000688 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000689 tuple(array<_Up, 0>) _NOEXCEPT {}
Howard Hinnant99968442011-11-29 18:15:50 +0000690 template <class _Alloc, class _Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000691 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000692 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000693 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000694 void swap(tuple&) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000695};
696
697template <class ..._Tp>
698inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantaabf2872011-06-01 19:59:32 +0000699typename enable_if
700<
701 __all<__is_swappable<_Tp>::value...>::value,
702 void
703>::type
Howard Hinnanta5e01212011-05-27 19:08:18 +0000704swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
705 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
706 {__t.swap(__u);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000707
708// get
709
710template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000711inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25 +0000712typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000713get(tuple<_Tp...>& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000714{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000715 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000716 return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get();
717}
718
719template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000720inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25 +0000721const typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000722get(const tuple<_Tp...>& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000723{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000724 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000725 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
726}
727
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000728template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000729inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25 +0000730typename tuple_element<_Ip, tuple<_Tp...> >::type&&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000731get(tuple<_Tp...>&& __t) _NOEXCEPT
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000732{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000733 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnant56a85ca2011-01-25 16:31:30 +0000734 return static_cast<type&&>(
Douglas Gregor6c669942011-01-25 16:14:21 +0000735 static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000736}
737
Marshall Clowe8029e52013-07-13 02:54:05 +0000738#if _LIBCPP_STD_VER > 11
739// get by type
740template <typename _T1, size_t _Idx, typename... _Args>
741struct __find_exactly_one_t_helper;
742
743// -- find exactly one
744template <typename _T1, size_t _Idx, typename... _Args>
745struct __find_exactly_one_t_checker {
746 static constexpr size_t value = _Idx;
747// Check the rest of the list to make sure there's only one
748 static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" );
749 };
750
751
752template <typename _T1, size_t _Idx>
753struct __find_exactly_one_t_helper <_T1, _Idx> {
754 static constexpr size_t value = -1;
755 };
756
757template <typename _T1, size_t _Idx, typename _Head, typename... _Args>
758struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> {
759 static constexpr size_t value =
760 std::conditional<
761 std::is_same<_T1, _Head>::value,
Marshall Clow19e78622013-10-01 13:28:20 +0000762 __find_exactly_one_t_checker<_T1, _Idx, _Args...>,
Marshall Clowe8029e52013-07-13 02:54:05 +0000763 __find_exactly_one_t_helper <_T1, _Idx+1, _Args...>
764 >::type::value;
765 };
766
767template <typename _T1, typename... _Args>
768struct __find_exactly_one_t {
769 static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value;
770 static_assert ( value != -1, "type not found in type list" );
771 };
772
773template <class _T1, class... _Args>
774inline _LIBCPP_INLINE_VISIBILITY
775constexpr _T1& get(tuple<_Args...>& __tup) noexcept
776{
777 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
778}
779
780template <class _T1, class... _Args>
781inline _LIBCPP_INLINE_VISIBILITY
782constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
783{
784 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
785}
786
787template <class _T1, class... _Args>
788inline _LIBCPP_INLINE_VISIBILITY
789constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
790{
Marshall Clow01a0e902013-07-15 20:46:11 +0000791 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
Marshall Clowe8029e52013-07-13 02:54:05 +0000792}
793
794#endif
795
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000796// tie
797
798template <class ..._Tp>
Marshall Clow8e554d92014-02-25 16:11:46 +0000799inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000800tuple<_Tp&...>
Howard Hinnant74f26f22012-07-06 21:53:48 +0000801tie(_Tp&... __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000802{
803 return tuple<_Tp&...>(__t...);
804}
805
806template <class _Up>
807struct __ignore_t
808{
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000809 template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000810 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000811 const __ignore_t& operator=(_Tp&&) const {return *this;}
812};
813
814namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
815
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000816template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000817
818template <class _Tp>
Marshall Clowa71f9562014-01-03 22:55:49 +0000819struct __make_tuple_return_impl
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000820{
821 typedef _Tp type;
822};
823
824template <class _Tp>
Marshall Clowa71f9562014-01-03 22:55:49 +0000825struct __make_tuple_return_impl<reference_wrapper<_Tp> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000826{
827 typedef _Tp& type;
828};
829
830template <class _Tp>
831struct __make_tuple_return
832{
Marshall Clowa71f9562014-01-03 22:55:49 +0000833 typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000834};
835
836template <class... _Tp>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000837inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000838tuple<typename __make_tuple_return<_Tp>::type...>
839make_tuple(_Tp&&... __t)
840{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000841 return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000842}
843
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000844template <class... _Tp>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000845inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
846tuple<_Tp&&...>
Howard Hinnant74f26f22012-07-06 21:53:48 +0000847forward_as_tuple(_Tp&&... __t) _NOEXCEPT
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000848{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000849 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000850}
851
Howard Hinnant99968442011-11-29 18:15:50 +0000852template <size_t _Ip>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000853struct __tuple_equal
854{
855 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000856 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000857 bool operator()(const _Tp& __x, const _Up& __y)
858 {
Howard Hinnant99968442011-11-29 18:15:50 +0000859 return __tuple_equal<_Ip - 1>()(__x, __y) && get<_Ip-1>(__x) == get<_Ip-1>(__y);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000860 }
861};
862
863template <>
864struct __tuple_equal<0>
865{
866 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000867 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000868 bool operator()(const _Tp&, const _Up&)
869 {
870 return true;
871 }
872};
873
874template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000875inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000876bool
877operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
878{
879 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
880}
881
882template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000883inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000884bool
885operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
886{
887 return !(__x == __y);
888}
889
Howard Hinnant99968442011-11-29 18:15:50 +0000890template <size_t _Ip>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000891struct __tuple_less
892{
893 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000894 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000895 bool operator()(const _Tp& __x, const _Up& __y)
896 {
Howard Hinnant99968442011-11-29 18:15:50 +0000897 return __tuple_less<_Ip-1>()(__x, __y) ||
898 (!__tuple_less<_Ip-1>()(__y, __x) && get<_Ip-1>(__x) < get<_Ip-1>(__y));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000899 }
900};
901
902template <>
903struct __tuple_less<0>
904{
905 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000906 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000907 bool operator()(const _Tp&, const _Up&)
908 {
909 return false;
910 }
911};
912
913template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000914inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000915bool
916operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
917{
918 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
919}
920
921template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000922inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000923bool
924operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
925{
926 return __y < __x;
927}
928
929template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000930inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000931bool
932operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
933{
934 return !(__x < __y);
935}
936
937template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000938inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000939bool
940operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
941{
942 return !(__y < __x);
943}
944
945// tuple_cat
946
Howard Hinnant0e1493e2010-12-11 20:47:50 +0000947template <class _Tp, class _Up> struct __tuple_cat_type;
948
949template <class ..._Ttypes, class ..._Utypes>
Howard Hinnantf83417b2011-01-24 16:07:25 +0000950struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000951{
Howard Hinnant0e1493e2010-12-11 20:47:50 +0000952 typedef tuple<_Ttypes..., _Utypes...> type;
953};
954
955template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
956struct __tuple_cat_return_1
957{
958};
959
960template <class ..._Types, class _Tuple0>
961struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
962{
963 typedef typename __tuple_cat_type<tuple<_Types...>,
964 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
965 type;
966};
967
968template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
969struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
970 : public __tuple_cat_return_1<
971 typename __tuple_cat_type<
972 tuple<_Types...>,
973 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
974 >::type,
975 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
976 _Tuple1, _Tuples...>
977{
978};
979
980template <class ..._Tuples> struct __tuple_cat_return;
981
982template <class _Tuple0, class ..._Tuples>
983struct __tuple_cat_return<_Tuple0, _Tuples...>
984 : public __tuple_cat_return_1<tuple<>,
985 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
986 _Tuples...>
987{
988};
989
990template <>
991struct __tuple_cat_return<>
992{
993 typedef tuple<> type;
994};
995
Marshall Clowda0a0e82013-07-22 16:02:19 +0000996inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant0e1493e2010-12-11 20:47:50 +0000997tuple<>
998tuple_cat()
999{
1000 return tuple<>();
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001001}
1002
Howard Hinnant99968442011-11-29 18:15:50 +00001003template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
Howard Hinnante48e3662010-12-12 23:04:37 +00001004struct __tuple_cat_return_ref_imp;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001005
Howard Hinnante48e3662010-12-12 23:04:37 +00001006template <class ..._Types, size_t ..._I0, class _Tuple0>
1007struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001008{
Howard Hinnant0e1493e2010-12-11 20:47:50 +00001009 typedef typename remove_reference<_Tuple0>::type _T0;
Howard Hinnante48e3662010-12-12 23:04:37 +00001010 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1011 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1012};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001013
Howard Hinnante48e3662010-12-12 23:04:37 +00001014template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1015struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1016 _Tuple0, _Tuple1, _Tuples...>
1017 : public __tuple_cat_return_ref_imp<
1018 tuple<_Types..., typename __apply_cv<_Tuple0,
1019 typename tuple_element<_I0,
1020 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1021 typename __make_tuple_indices<tuple_size<typename
1022 remove_reference<_Tuple1>::type>::value>::type,
1023 _Tuple1, _Tuples...>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001024{
Howard Hinnante48e3662010-12-12 23:04:37 +00001025};
1026
1027template <class _Tuple0, class ..._Tuples>
1028struct __tuple_cat_return_ref
1029 : public __tuple_cat_return_ref_imp<tuple<>,
1030 typename __make_tuple_indices<
1031 tuple_size<typename remove_reference<_Tuple0>::type>::value
1032 >::type, _Tuple0, _Tuples...>
1033{
1034};
1035
1036template <class _Types, class _I0, class _J0>
1037struct __tuple_cat;
1038
1039template <class ..._Types, size_t ..._I0, size_t ..._J0>
Howard Hinnantf83417b2011-01-24 16:07:25 +00001040struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
Howard Hinnante48e3662010-12-12 23:04:37 +00001041{
1042 template <class _Tuple0>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001043 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001044 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1045 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1046 {
Marshall Clow1d927e32013-10-05 18:46:37 +00001047 return forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))...,
Howard Hinnant0949eed2011-06-30 21:18:19 +00001048 get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
Howard Hinnante48e3662010-12-12 23:04:37 +00001049 }
1050
1051 template <class _Tuple0, class _Tuple1, class ..._Tuples>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001052 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001053 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1054 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1055 {
1056 typedef typename remove_reference<_Tuple0>::type _T0;
1057 typedef typename remove_reference<_Tuple1>::type _T1;
1058 return __tuple_cat<
1059 tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1060 typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1061 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
Marshall Clow1d927e32013-10-05 18:46:37 +00001062 (forward_as_tuple(
Howard Hinnant0949eed2011-06-30 21:18:19 +00001063 _VSTD::forward<_Types>(get<_I0>(__t))...,
1064 get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
Howard Hinnante48e3662010-12-12 23:04:37 +00001065 ),
Howard Hinnant0949eed2011-06-30 21:18:19 +00001066 _VSTD::forward<_Tuple1>(__t1),
1067 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnante48e3662010-12-12 23:04:37 +00001068 }
1069};
1070
1071template <class _Tuple0, class... _Tuples>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001072inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001073typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1074tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1075{
1076 typedef typename remove_reference<_Tuple0>::type _T0;
1077 return __tuple_cat<tuple<>, __tuple_indices<>,
1078 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
Howard Hinnant0949eed2011-06-30 21:18:19 +00001079 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1080 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001081}
1082
1083template <class ..._Tp, class _Alloc>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001084struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001085 : true_type {};
1086
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001087template <class _T1, class _T2>
1088template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1089inline _LIBCPP_INLINE_VISIBILITY
1090pair<_T1, _T2>::pair(piecewise_construct_t,
1091 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1092 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
Howard Hinnant0949eed2011-06-30 21:18:19 +00001093 : first(_VSTD::forward<_Args1>(get<_I1>( __first_args))...),
1094 second(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001095{
1096}
1097
Howard Hinnant324bb032010-08-22 00:02:43 +00001098#endif // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001099
1100_LIBCPP_END_NAMESPACE_STD
1101
1102#endif // _LIBCPP_TUPLE