blob: 5fa6ef36b53a7bf5cfa2401ea0fd803b7889f584 [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
Howard Hinnanta5e01212011-05-27 19:08:18 +000076template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept;
77template <class... T> tuple<T&...> tie(T&...) noexcept;
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)
273 : value(_VSTD::move(__t.get()))
274 {}
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 Hinnant28484442012-02-15 20:13:52 +0000460 _LIBCPP_INLINE_VISIBILITY
461 __tuple_impl&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000462 operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
Howard Hinnant28484442012-02-15 20:13:52 +0000463 {
464 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
465 return *this;
466 }
467
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000468 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000469 void swap(__tuple_impl& __t)
Howard Hinnanta5e01212011-05-27 19:08:18 +0000470 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000471 {
472 __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
473 }
474};
475
476template <class ..._Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000477class _LIBCPP_TYPE_VIS_ONLY tuple
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000478{
479 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
480
481 base base_;
482
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000483 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000484 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000485 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000486 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000487 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000488 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000489public:
490
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000491 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000492 _LIBCPP_CONSTEXPR tuple()
493 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000494
Marshall Clowda0a0e82013-07-22 16:02:19 +0000495 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000496 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000497 : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
498 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
499 typename __make_tuple_indices<0>::type(),
500 typename __make_tuple_types<tuple, 0>::type(),
501 __t...
502 ) {}
503
504 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000505 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000506 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
507 : base_(allocator_arg_t(), __a,
508 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 ..._Up,
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000516 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000517 <
518 sizeof...(_Up) <= sizeof...(_Tp) &&
519 __tuple_convertible
520 <
521 tuple<_Up...>,
522 typename __make_tuple_types<tuple,
523 sizeof...(_Up) < sizeof...(_Tp) ?
524 sizeof...(_Up) :
525 sizeof...(_Tp)>::type
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000526 >::value,
527 bool
528 >::type = false
529 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000530 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000531 tuple(_Up&&... __u)
Howard Hinnant74f26f22012-07-06 21:53:48 +0000532 _NOEXCEPT_((
533 is_nothrow_constructible<
534 typename __make_tuple_indices<sizeof...(_Up)>::type,
535 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
536 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
537 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
538 _Up...
539 >::value
540 ))
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000541 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
542 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
543 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
544 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
545 _VSTD::forward<_Up>(__u)...) {}
546
547 template <class ..._Up,
548 typename enable_if
549 <
550 sizeof...(_Up) <= sizeof...(_Tp) &&
551 __tuple_constructible
552 <
553 tuple<_Up...>,
554 typename __make_tuple_types<tuple,
555 sizeof...(_Up) < sizeof...(_Tp) ?
556 sizeof...(_Up) :
557 sizeof...(_Tp)>::type
558 >::value &&
559 !__tuple_convertible
560 <
561 tuple<_Up...>,
562 typename __make_tuple_types<tuple,
563 sizeof...(_Up) < sizeof...(_Tp) ?
564 sizeof...(_Up) :
565 sizeof...(_Tp)>::type
566 >::value,
567 bool
568 >::type =false
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000569 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000570 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000571 explicit
572 tuple(_Up&&... __u)
Howard Hinnant74f26f22012-07-06 21:53:48 +0000573 _NOEXCEPT_((
574 is_nothrow_constructible<
575 typename __make_tuple_indices<sizeof...(_Up)>::type,
576 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
577 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
578 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
579 _Up...
580 >::value
581 ))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000582 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
583 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
584 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
585 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
Howard Hinnant0949eed2011-06-30 21:18:19 +0000586 _VSTD::forward<_Up>(__u)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000587
588 template <class _Alloc, class ..._Up,
589 class = typename enable_if
590 <
591 sizeof...(_Up) <= sizeof...(_Tp) &&
592 __tuple_convertible
593 <
594 tuple<_Up...>,
595 typename __make_tuple_types<tuple,
596 sizeof...(_Up) < sizeof...(_Tp) ?
597 sizeof...(_Up) :
598 sizeof...(_Tp)>::type
599 >::value
600 >::type
601 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000602 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000603 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
604 : base_(allocator_arg_t(), __a,
605 typename __make_tuple_indices<sizeof...(_Up)>::type(),
606 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
607 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
608 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
Howard Hinnant0949eed2011-06-30 21:18:19 +0000609 _VSTD::forward<_Up>(__u)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000610
611 template <class _Tuple,
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000612 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000613 <
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000614 __tuple_convertible<_Tuple, tuple>::value,
615 bool
616 >::type = false
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000617 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000618 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000619 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000620 : base_(_VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000621
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000622 template <class _Tuple,
623 typename enable_if
624 <
625 __tuple_constructible<_Tuple, tuple>::value &&
626 !__tuple_convertible<_Tuple, tuple>::value,
627 bool
628 >::type = false
629 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000630 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000631 explicit
Howard Hinnant74f26f22012-07-06 21:53:48 +0000632 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000633 : base_(_VSTD::forward<_Tuple>(__t)) {}
634
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000635 template <class _Alloc, class _Tuple,
636 class = typename enable_if
637 <
638 __tuple_convertible<_Tuple, tuple>::value
639 >::type
640 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000641 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000642 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000643 : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000644
645 template <class _Tuple,
646 class = typename enable_if
647 <
648 __tuple_assignable<_Tuple, tuple>::value
649 >::type
650 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000651 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000652 tuple&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000653 operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000654 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000655 base_.operator=(_VSTD::forward<_Tuple>(__t));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000656 return *this;
657 }
658
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000659 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000660 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
661 {base_.swap(__t.base_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000662};
663
664template <>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000665class _LIBCPP_TYPE_VIS_ONLY tuple<>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000666{
667public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000668 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000669 _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000670 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000671 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000672 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000673 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000674 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000675 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
Howard Hinnant99968442011-11-29 18:15:50 +0000676 template <class _Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000677 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000678 tuple(array<_Up, 0>) _NOEXCEPT {}
Howard Hinnant99968442011-11-29 18:15:50 +0000679 template <class _Alloc, class _Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000680 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000681 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000682 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000683 void swap(tuple&) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000684};
685
686template <class ..._Tp>
687inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantaabf2872011-06-01 19:59:32 +0000688typename enable_if
689<
690 __all<__is_swappable<_Tp>::value...>::value,
691 void
692>::type
Howard Hinnanta5e01212011-05-27 19:08:18 +0000693swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
694 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
695 {__t.swap(__u);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000696
697// get
698
699template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000700inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25 +0000701typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000702get(tuple<_Tp...>& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000703{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000704 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000705 return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get();
706}
707
708template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000709inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25 +0000710const typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000711get(const tuple<_Tp...>& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000712{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000713 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000714 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
715}
716
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000717template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000718inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25 +0000719typename tuple_element<_Ip, tuple<_Tp...> >::type&&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000720get(tuple<_Tp...>&& __t) _NOEXCEPT
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000721{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000722 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnant56a85ca2011-01-25 16:31:30 +0000723 return static_cast<type&&>(
Douglas Gregor6c669942011-01-25 16:14:21 +0000724 static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000725}
726
Marshall Clowe8029e52013-07-13 02:54:05 +0000727#if _LIBCPP_STD_VER > 11
728// get by type
729template <typename _T1, size_t _Idx, typename... _Args>
730struct __find_exactly_one_t_helper;
731
732// -- find exactly one
733template <typename _T1, size_t _Idx, typename... _Args>
734struct __find_exactly_one_t_checker {
735 static constexpr size_t value = _Idx;
736// Check the rest of the list to make sure there's only one
737 static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" );
738 };
739
740
741template <typename _T1, size_t _Idx>
742struct __find_exactly_one_t_helper <_T1, _Idx> {
743 static constexpr size_t value = -1;
744 };
745
746template <typename _T1, size_t _Idx, typename _Head, typename... _Args>
747struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> {
748 static constexpr size_t value =
749 std::conditional<
750 std::is_same<_T1, _Head>::value,
Marshall Clow19e78622013-10-01 13:28:20 +0000751 __find_exactly_one_t_checker<_T1, _Idx, _Args...>,
Marshall Clowe8029e52013-07-13 02:54:05 +0000752 __find_exactly_one_t_helper <_T1, _Idx+1, _Args...>
753 >::type::value;
754 };
755
756template <typename _T1, typename... _Args>
757struct __find_exactly_one_t {
758 static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value;
759 static_assert ( value != -1, "type not found in type list" );
760 };
761
762template <class _T1, class... _Args>
763inline _LIBCPP_INLINE_VISIBILITY
764constexpr _T1& get(tuple<_Args...>& __tup) noexcept
765{
766 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
767}
768
769template <class _T1, class... _Args>
770inline _LIBCPP_INLINE_VISIBILITY
771constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
772{
773 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
774}
775
776template <class _T1, class... _Args>
777inline _LIBCPP_INLINE_VISIBILITY
778constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
779{
Marshall Clow01a0e902013-07-15 20:46:11 +0000780 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
Marshall Clowe8029e52013-07-13 02:54:05 +0000781}
782
783#endif
784
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000785// tie
786
787template <class ..._Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000788inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000789tuple<_Tp&...>
Howard Hinnant74f26f22012-07-06 21:53:48 +0000790tie(_Tp&... __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000791{
792 return tuple<_Tp&...>(__t...);
793}
794
795template <class _Up>
796struct __ignore_t
797{
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000798 template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000799 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000800 const __ignore_t& operator=(_Tp&&) const {return *this;}
801};
802
803namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
804
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000805template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000806
807template <class _Tp>
808struct ___make_tuple_return
809{
810 typedef _Tp type;
811};
812
813template <class _Tp>
Howard Hinnantf83417b2011-01-24 16:07:25 +0000814struct ___make_tuple_return<reference_wrapper<_Tp> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000815{
816 typedef _Tp& type;
817};
818
819template <class _Tp>
820struct __make_tuple_return
821{
822 typedef typename ___make_tuple_return<typename decay<_Tp>::type>::type type;
823};
824
825template <class... _Tp>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000826inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000827tuple<typename __make_tuple_return<_Tp>::type...>
828make_tuple(_Tp&&... __t)
829{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000830 return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000831}
832
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000833template <class... _Tp>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000834inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
835tuple<_Tp&&...>
836__forward_as_tuple(_Tp&&... __t) _NOEXCEPT
837{
838 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
839}
840
841template <class... _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000842inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000843tuple<_Tp&&...>
Howard Hinnant74f26f22012-07-06 21:53:48 +0000844forward_as_tuple(_Tp&&... __t) _NOEXCEPT
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000845{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000846 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000847}
848
Howard Hinnant99968442011-11-29 18:15:50 +0000849template <size_t _Ip>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000850struct __tuple_equal
851{
852 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000853 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000854 bool operator()(const _Tp& __x, const _Up& __y)
855 {
Howard Hinnant99968442011-11-29 18:15:50 +0000856 return __tuple_equal<_Ip - 1>()(__x, __y) && get<_Ip-1>(__x) == get<_Ip-1>(__y);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000857 }
858};
859
860template <>
861struct __tuple_equal<0>
862{
863 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000864 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000865 bool operator()(const _Tp&, const _Up&)
866 {
867 return true;
868 }
869};
870
871template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000872inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000873bool
874operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
875{
876 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
877}
878
879template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000880inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000881bool
882operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
883{
884 return !(__x == __y);
885}
886
Howard Hinnant99968442011-11-29 18:15:50 +0000887template <size_t _Ip>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000888struct __tuple_less
889{
890 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000891 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000892 bool operator()(const _Tp& __x, const _Up& __y)
893 {
Howard Hinnant99968442011-11-29 18:15:50 +0000894 return __tuple_less<_Ip-1>()(__x, __y) ||
895 (!__tuple_less<_Ip-1>()(__y, __x) && get<_Ip-1>(__x) < get<_Ip-1>(__y));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000896 }
897};
898
899template <>
900struct __tuple_less<0>
901{
902 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000903 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000904 bool operator()(const _Tp&, const _Up&)
905 {
906 return false;
907 }
908};
909
910template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000911inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000912bool
913operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
914{
915 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
916}
917
918template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000919inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000920bool
921operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
922{
923 return __y < __x;
924}
925
926template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000927inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000928bool
929operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
930{
931 return !(__x < __y);
932}
933
934template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000935inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000936bool
937operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
938{
939 return !(__y < __x);
940}
941
942// tuple_cat
943
Howard Hinnant0e1493e2010-12-11 20:47:50 +0000944template <class _Tp, class _Up> struct __tuple_cat_type;
945
946template <class ..._Ttypes, class ..._Utypes>
Howard Hinnantf83417b2011-01-24 16:07:25 +0000947struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000948{
Howard Hinnant0e1493e2010-12-11 20:47:50 +0000949 typedef tuple<_Ttypes..., _Utypes...> type;
950};
951
952template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
953struct __tuple_cat_return_1
954{
955};
956
957template <class ..._Types, class _Tuple0>
958struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
959{
960 typedef typename __tuple_cat_type<tuple<_Types...>,
961 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
962 type;
963};
964
965template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
966struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
967 : public __tuple_cat_return_1<
968 typename __tuple_cat_type<
969 tuple<_Types...>,
970 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
971 >::type,
972 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
973 _Tuple1, _Tuples...>
974{
975};
976
977template <class ..._Tuples> struct __tuple_cat_return;
978
979template <class _Tuple0, class ..._Tuples>
980struct __tuple_cat_return<_Tuple0, _Tuples...>
981 : public __tuple_cat_return_1<tuple<>,
982 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
983 _Tuples...>
984{
985};
986
987template <>
988struct __tuple_cat_return<>
989{
990 typedef tuple<> type;
991};
992
Marshall Clowda0a0e82013-07-22 16:02:19 +0000993inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant0e1493e2010-12-11 20:47:50 +0000994tuple<>
995tuple_cat()
996{
997 return tuple<>();
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000998}
999
Howard Hinnant99968442011-11-29 18:15:50 +00001000template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
Howard Hinnante48e3662010-12-12 23:04:37 +00001001struct __tuple_cat_return_ref_imp;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001002
Howard Hinnante48e3662010-12-12 23:04:37 +00001003template <class ..._Types, size_t ..._I0, class _Tuple0>
1004struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001005{
Howard Hinnant0e1493e2010-12-11 20:47:50 +00001006 typedef typename remove_reference<_Tuple0>::type _T0;
Howard Hinnante48e3662010-12-12 23:04:37 +00001007 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1008 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1009};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001010
Howard Hinnante48e3662010-12-12 23:04:37 +00001011template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1012struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1013 _Tuple0, _Tuple1, _Tuples...>
1014 : public __tuple_cat_return_ref_imp<
1015 tuple<_Types..., typename __apply_cv<_Tuple0,
1016 typename tuple_element<_I0,
1017 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1018 typename __make_tuple_indices<tuple_size<typename
1019 remove_reference<_Tuple1>::type>::value>::type,
1020 _Tuple1, _Tuples...>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001021{
Howard Hinnante48e3662010-12-12 23:04:37 +00001022};
1023
1024template <class _Tuple0, class ..._Tuples>
1025struct __tuple_cat_return_ref
1026 : public __tuple_cat_return_ref_imp<tuple<>,
1027 typename __make_tuple_indices<
1028 tuple_size<typename remove_reference<_Tuple0>::type>::value
1029 >::type, _Tuple0, _Tuples...>
1030{
1031};
1032
1033template <class _Types, class _I0, class _J0>
1034struct __tuple_cat;
1035
1036template <class ..._Types, size_t ..._I0, size_t ..._J0>
Howard Hinnantf83417b2011-01-24 16:07:25 +00001037struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
Howard Hinnante48e3662010-12-12 23:04:37 +00001038{
1039 template <class _Tuple0>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001040 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001041 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1042 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1043 {
Marshall Clowda0a0e82013-07-22 16:02:19 +00001044 return __forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))...,
Howard Hinnant0949eed2011-06-30 21:18:19 +00001045 get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
Howard Hinnante48e3662010-12-12 23:04:37 +00001046 }
1047
1048 template <class _Tuple0, class _Tuple1, class ..._Tuples>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001049 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001050 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1051 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1052 {
1053 typedef typename remove_reference<_Tuple0>::type _T0;
1054 typedef typename remove_reference<_Tuple1>::type _T1;
1055 return __tuple_cat<
1056 tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1057 typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1058 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
Marshall Clowda0a0e82013-07-22 16:02:19 +00001059 (__forward_as_tuple(
Howard Hinnant0949eed2011-06-30 21:18:19 +00001060 _VSTD::forward<_Types>(get<_I0>(__t))...,
1061 get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
Howard Hinnante48e3662010-12-12 23:04:37 +00001062 ),
Howard Hinnant0949eed2011-06-30 21:18:19 +00001063 _VSTD::forward<_Tuple1>(__t1),
1064 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnante48e3662010-12-12 23:04:37 +00001065 }
1066};
1067
1068template <class _Tuple0, class... _Tuples>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001069inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001070typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1071tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1072{
1073 typedef typename remove_reference<_Tuple0>::type _T0;
1074 return __tuple_cat<tuple<>, __tuple_indices<>,
1075 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
Howard Hinnant0949eed2011-06-30 21:18:19 +00001076 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1077 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001078}
1079
1080template <class ..._Tp, class _Alloc>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001081struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001082 : true_type {};
1083
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001084template <class _T1, class _T2>
1085template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1086inline _LIBCPP_INLINE_VISIBILITY
1087pair<_T1, _T2>::pair(piecewise_construct_t,
1088 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1089 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
Howard Hinnant0949eed2011-06-30 21:18:19 +00001090 : first(_VSTD::forward<_Args1>(get<_I1>( __first_args))...),
1091 second(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001092{
1093}
1094
Howard Hinnant324bb032010-08-22 00:02:43 +00001095#endif // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001096
1097_LIBCPP_END_NAMESPACE_STD
1098
1099#endif // _LIBCPP_TUPLE