blob: 3a1752ee19c5b5fcf24dc2e157f60cfcda277159 [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...>>;
Marshall Clow50fe0c72014-03-03 06:18:11 +000085template <size_t _Ip, class ..._Tp>
86 using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000087
88// 20.4.1.5, element access:
Howard Hinnanta5e01212011-05-27 19:08:18 +000089template <intsize_t I, class... T>
90 typename tuple_element<I, tuple<T...>>::type&
Marshall Clow8fc4f5a2013-07-17 18:25:36 +000091 get(tuple<T...>&) noexcept; // constexpr in C++14
Howard Hinnanta5e01212011-05-27 19:08:18 +000092template <intsize_t I, class... T>
Marshall Clow50fe0c72014-03-03 06:18:11 +000093 typename const tuple_element<I, tuple<T...>>::type &
Marshall Clow8fc4f5a2013-07-17 18:25:36 +000094 get(const tuple<T...>&) noexcept; // constexpr in C++14
Howard Hinnanta5e01212011-05-27 19:08:18 +000095template <intsize_t I, class... T>
96 typename tuple_element<I, tuple<T...>>::type&&
Marshall Clow8fc4f5a2013-07-17 18:25:36 +000097 get(tuple<T...>&&) noexcept; // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000098
Marshall Clowe8029e52013-07-13 02:54:05 +000099template <class T1, class... T>
100 constexpr T1& get(tuple<T...>&) noexcept; // C++14
101template <class T1, class... T>
102 constexpr T1 const& get(const tuple<T...>&) noexcept; // C++14
103template <class T1, class... T>
104 constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
105
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000106// 20.4.1.6, relational operators:
Marshall Clowda0a0e82013-07-22 16:02:19 +0000107template<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
111template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
112template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000113
114template <class... Types, class Alloc>
115 struct uses_allocator<tuple<Types...>, Alloc>;
116
117template <class... Types>
Howard Hinnanta5e01212011-05-27 19:08:18 +0000118 void
119 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000120
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000121} // std
122
123*/
124
125#include <__config>
126#include <__tuple>
127#include <cstddef>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000128#include <type_traits>
Howard Hinnant6cc99fa2011-12-19 17:58:44 +0000129#include <__functional_base>
130#include <utility>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000131
Howard Hinnant08e17472011-10-17 20:05:10 +0000132#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000133#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000134#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000135
136_LIBCPP_BEGIN_NAMESPACE_STD
137
138#ifndef _LIBCPP_HAS_NO_VARIADICS
139
140// tuple_size
141
142template <class ..._Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000143class _LIBCPP_TYPE_VIS_ONLY tuple_size<tuple<_Tp...> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000144 : public integral_constant<size_t, sizeof...(_Tp)>
145{
146};
147
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000148// tuple_element
149
150template <size_t _Ip, class ..._Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000151class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000152{
153public:
Howard Hinnantf83417b2011-01-24 16:07:25 +0000154 typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000155};
156
Marshall Clow50fe0c72014-03-03 06:18:11 +0000157#if _LIBCPP_STD_VER > 11
158template <size_t _Ip, class ..._Tp>
159using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
160#endif
161
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000162// __tuple_leaf
163
Howard Hinnantd4cf2152011-12-11 20:31:33 +0000164template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
165#if __has_feature(is_final)
166 && !__is_final(_Hp)
167#endif
168 >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000169class __tuple_leaf;
170
171template <size_t _Ip, class _Hp, bool _Ep>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000172inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000173void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
Howard Hinnanta5e01212011-05-27 19:08:18 +0000174 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000175{
176 swap(__x.get(), __y.get());
177}
178
179template <size_t _Ip, class _Hp, bool>
180class __tuple_leaf
181{
182 _Hp value;
183
184 __tuple_leaf& operator=(const __tuple_leaf&);
185public:
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000186 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
187 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value()
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000188 {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, 0>, const _Alloc&)
194 : value()
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, 1>, const _Alloc& __a)
201 : value(allocator_arg_t(), __a)
202 {static_assert(!is_reference<_Hp>::value,
203 "Attempted to default construct a reference element in a tuple");}
204
205 template <class _Alloc>
206 _LIBCPP_INLINE_VISIBILITY
207 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
208 : value(__a)
209 {static_assert(!is_reference<_Hp>::value,
210 "Attempted to default construct a reference element in a tuple");}
211
Howard Hinnante049cc52010-09-27 17:54:17 +0000212 template <class _Tp,
213 class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000214 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000215 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000216 : value(_VSTD::forward<_Tp>(__t))
Howard Hinnante049cc52010-09-27 17:54:17 +0000217 {static_assert(!is_reference<_Hp>::value ||
Howard Hinnantec3773c2011-12-01 20:21:04 +0000218 (is_lvalue_reference<_Hp>::value &&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000219 (is_lvalue_reference<_Tp>::value ||
220 is_same<typename remove_reference<_Tp>::type,
221 reference_wrapper<
222 typename remove_reference<_Hp>::type
223 >
Howard Hinnantec3773c2011-12-01 20:21:04 +0000224 >::value)) ||
Howard Hinnante049cc52010-09-27 17:54:17 +0000225 (is_rvalue_reference<_Hp>::value &&
226 !is_lvalue_reference<_Tp>::value),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000227 "Attempted to construct a reference element in a tuple with an rvalue");}
228
229 template <class _Tp, class _Alloc>
230 _LIBCPP_INLINE_VISIBILITY
231 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000232 : value(_VSTD::forward<_Tp>(__t))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000233 {static_assert(!is_lvalue_reference<_Hp>::value ||
Howard Hinnantec3773c2011-12-01 20:21:04 +0000234 (is_lvalue_reference<_Hp>::value &&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000235 (is_lvalue_reference<_Tp>::value ||
236 is_same<typename remove_reference<_Tp>::type,
237 reference_wrapper<
238 typename remove_reference<_Hp>::type
239 >
Howard Hinnantec3773c2011-12-01 20:21:04 +0000240 >::value)),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000241 "Attempted to construct a reference element in a tuple with an rvalue");}
242
243 template <class _Tp, class _Alloc>
244 _LIBCPP_INLINE_VISIBILITY
245 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000246 : value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000247 {static_assert(!is_lvalue_reference<_Hp>::value ||
Howard Hinnantec3773c2011-12-01 20:21:04 +0000248 (is_lvalue_reference<_Hp>::value &&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000249 (is_lvalue_reference<_Tp>::value ||
250 is_same<typename remove_reference<_Tp>::type,
251 reference_wrapper<
252 typename remove_reference<_Hp>::type
253 >
Howard Hinnantec3773c2011-12-01 20:21:04 +0000254 >::value)),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000255 "Attempted to construct a reference element in a tuple with an rvalue");}
256
257 template <class _Tp, class _Alloc>
258 _LIBCPP_INLINE_VISIBILITY
259 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000260 : value(_VSTD::forward<_Tp>(__t), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000261 {static_assert(!is_lvalue_reference<_Hp>::value ||
Howard Hinnantec3773c2011-12-01 20:21:04 +0000262 (is_lvalue_reference<_Hp>::value &&
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000263 (is_lvalue_reference<_Tp>::value ||
264 is_same<typename remove_reference<_Tp>::type,
265 reference_wrapper<
266 typename remove_reference<_Hp>::type
267 >
Howard Hinnantec3773c2011-12-01 20:21:04 +0000268 >::value)),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000269 "Attempted to construct a reference element in a tuple with an rvalue");}
270
Marshall Clowda0a0e82013-07-22 16:02:19 +0000271 _LIBCPP_INLINE_VISIBILITY
272 _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000273 __tuple_leaf(const __tuple_leaf& __t) _NOEXCEPT_(is_nothrow_copy_constructible<_Hp>::value)
Howard Hinnante049cc52010-09-27 17:54:17 +0000274 : value(__t.get())
275 {static_assert(!is_rvalue_reference<_Hp>::value, "Can not copy a tuple with rvalue reference member");}
276
Marshall Clowda0a0e82013-07-22 16:02:19 +0000277 _LIBCPP_INLINE_VISIBILITY
278 _LIBCPP_CONSTEXPR_AFTER_CXX11
279 __tuple_leaf(__tuple_leaf&& __t) _NOEXCEPT_(is_nothrow_move_constructible<_Hp>::value)
Howard Hinnant3de50862013-11-06 17:45:43 +0000280 : value(_VSTD::forward<_Hp>(__t.get()))
Marshall Clowda0a0e82013-07-22 16:02:19 +0000281 {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000282
283 template <class _Tp>
284 _LIBCPP_INLINE_VISIBILITY
285 __tuple_leaf&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000286 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000287 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000288 value = _VSTD::forward<_Tp>(__t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000289 return *this;
290 }
291
292 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000293 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000294 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000295 _VSTD::swap(*this, __t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000296 return 0;
297 }
298
Marshall Clowda0a0e82013-07-22 16:02:19 +0000299 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return value;}
300 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return value;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000301};
302
303template <size_t _Ip, class _Hp>
304class __tuple_leaf<_Ip, _Hp, true>
305 : private _Hp
306{
307
308 __tuple_leaf& operator=(const __tuple_leaf&);
309public:
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000310 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
311 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000312
313 template <class _Alloc>
314 _LIBCPP_INLINE_VISIBILITY
315 __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
316
317 template <class _Alloc>
318 _LIBCPP_INLINE_VISIBILITY
319 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
320 : _Hp(allocator_arg_t(), __a) {}
321
322 template <class _Alloc>
323 _LIBCPP_INLINE_VISIBILITY
324 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
325 : _Hp(__a) {}
326
Howard Hinnante049cc52010-09-27 17:54:17 +0000327 template <class _Tp,
328 class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000329 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000330 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000331 : _Hp(_VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000332
333 template <class _Tp, class _Alloc>
334 _LIBCPP_INLINE_VISIBILITY
335 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000336 : _Hp(_VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000337
338 template <class _Tp, class _Alloc>
339 _LIBCPP_INLINE_VISIBILITY
340 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000341 : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000342
343 template <class _Tp, class _Alloc>
344 _LIBCPP_INLINE_VISIBILITY
345 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000346 : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000347
348 template <class _Tp>
349 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000350 __tuple_leaf&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000351 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000352 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000353 _Hp::operator=(_VSTD::forward<_Tp>(__t));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000354 return *this;
355 }
356
Howard Hinnanta5e01212011-05-27 19:08:18 +0000357 _LIBCPP_INLINE_VISIBILITY
358 int
359 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000360 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000361 _VSTD::swap(*this, __t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000362 return 0;
363 }
364
Marshall Clowda0a0e82013-07-22 16:02:19 +0000365 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
366 _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 +0000367};
368
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000369template <class ..._Tp>
370_LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000371void __swallow(_Tp&&...) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000372
Howard Hinnanta5e01212011-05-27 19:08:18 +0000373template <bool ...> struct __all;
374
375template <>
376struct __all<>
377{
378 static const bool value = true;
379};
380
Howard Hinnant99968442011-11-29 18:15:50 +0000381template <bool _B0, bool ... _Bp>
382struct __all<_B0, _Bp...>
Howard Hinnanta5e01212011-05-27 19:08:18 +0000383{
Howard Hinnant99968442011-11-29 18:15:50 +0000384 static const bool value = _B0 && __all<_Bp...>::value;
Howard Hinnanta5e01212011-05-27 19:08:18 +0000385};
386
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000387// __tuple_impl
388
389template<class _Indx, class ..._Tp> struct __tuple_impl;
390
391template<size_t ..._Indx, class ..._Tp>
392struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
393 : public __tuple_leaf<_Indx, _Tp>...
394{
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000395 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000396 _LIBCPP_CONSTEXPR __tuple_impl()
397 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000398
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000399 template <size_t ..._Uf, class ..._Tf,
400 size_t ..._Ul, class ..._Tl, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000401 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000402 explicit
403 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
404 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
Howard Hinnant74f26f22012-07-06 21:53:48 +0000405 _Up&&... __u)
406 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
407 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
Howard Hinnant0949eed2011-06-30 21:18:19 +0000408 __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000409 __tuple_leaf<_Ul, _Tl>()...
410 {}
411
412 template <class _Alloc, size_t ..._Uf, class ..._Tf,
413 size_t ..._Ul, class ..._Tl, class ..._Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000414 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000415 explicit
416 __tuple_impl(allocator_arg_t, const _Alloc& __a,
417 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
418 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
419 _Up&&... __u) :
420 __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
Howard Hinnant0949eed2011-06-30 21:18:19 +0000421 _VSTD::forward<_Up>(__u))...,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000422 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
423 {}
424
425 template <class _Tuple,
426 class = typename enable_if
427 <
Howard Hinnant99324892013-04-14 00:01:13 +0000428 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000429 >::type
430 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000431 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000432 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
433 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000434 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
435 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000436 {}
437
438 template <class _Alloc, class _Tuple,
439 class = typename enable_if
440 <
Howard Hinnantf83417b2011-01-24 16:07:25 +0000441 __tuple_convertible<_Tuple, tuple<_Tp...> >::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000442 >::type
443 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000444 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000445 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
446 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
Howard Hinnant324bb032010-08-22 00:02:43 +0000447 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
Howard Hinnant0949eed2011-06-30 21:18:19 +0000448 _VSTD::forward<typename tuple_element<_Indx,
449 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000450 {}
451
452 template <class _Tuple>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000453 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000454 typename enable_if
455 <
Howard Hinnantf83417b2011-01-24 16:07:25 +0000456 __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000457 __tuple_impl&
458 >::type
Howard Hinnant74f26f22012-07-06 21:53:48 +0000459 operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
460 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000461 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000462 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
463 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000464 return *this;
465 }
466
Howard Hinnant3de50862013-11-06 17:45:43 +0000467 __tuple_impl(const __tuple_impl&) = default;
468 __tuple_impl(__tuple_impl&&) = default;
469
470 _LIBCPP_INLINE_VISIBILITY
471 __tuple_impl&
472 operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
473 {
474 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
475 return *this;
476 }
477
478 _LIBCPP_INLINE_VISIBILITY
479 __tuple_impl&
480 operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
481 {
482 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
483 return *this;
484 }
Howard Hinnant28484442012-02-15 20:13:52 +0000485
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000486 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000487 void swap(__tuple_impl& __t)
Howard Hinnanta5e01212011-05-27 19:08:18 +0000488 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000489 {
490 __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
491 }
492};
493
494template <class ..._Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000495class _LIBCPP_TYPE_VIS_ONLY tuple
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000496{
497 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
498
499 base base_;
500
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000501 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000502 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000503 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000504 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000505 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000506 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000507public:
508
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000509 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000510 _LIBCPP_CONSTEXPR tuple()
511 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000512
Marshall Clowda0a0e82013-07-22 16:02:19 +0000513 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000514 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000515 : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
516 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
517 typename __make_tuple_indices<0>::type(),
518 typename __make_tuple_types<tuple, 0>::type(),
519 __t...
520 ) {}
521
522 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000523 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000524 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
525 : base_(allocator_arg_t(), __a,
526 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
527 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
528 typename __make_tuple_indices<0>::type(),
529 typename __make_tuple_types<tuple, 0>::type(),
530 __t...
531 ) {}
532
533 template <class ..._Up,
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000534 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000535 <
536 sizeof...(_Up) <= sizeof...(_Tp) &&
537 __tuple_convertible
538 <
539 tuple<_Up...>,
540 typename __make_tuple_types<tuple,
541 sizeof...(_Up) < sizeof...(_Tp) ?
542 sizeof...(_Up) :
543 sizeof...(_Tp)>::type
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000544 >::value,
545 bool
546 >::type = false
547 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000548 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000549 tuple(_Up&&... __u)
Howard Hinnant74f26f22012-07-06 21:53:48 +0000550 _NOEXCEPT_((
551 is_nothrow_constructible<
552 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 _Up...
557 >::value
558 ))
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000559 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
560 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
561 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
562 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
563 _VSTD::forward<_Up>(__u)...) {}
564
565 template <class ..._Up,
566 typename enable_if
567 <
568 sizeof...(_Up) <= sizeof...(_Tp) &&
569 __tuple_constructible
570 <
571 tuple<_Up...>,
572 typename __make_tuple_types<tuple,
573 sizeof...(_Up) < sizeof...(_Tp) ?
574 sizeof...(_Up) :
575 sizeof...(_Tp)>::type
576 >::value &&
577 !__tuple_convertible
578 <
579 tuple<_Up...>,
580 typename __make_tuple_types<tuple,
581 sizeof...(_Up) < sizeof...(_Tp) ?
582 sizeof...(_Up) :
583 sizeof...(_Tp)>::type
584 >::value,
585 bool
586 >::type =false
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000587 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000588 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000589 explicit
590 tuple(_Up&&... __u)
Howard Hinnant74f26f22012-07-06 21:53:48 +0000591 _NOEXCEPT_((
592 is_nothrow_constructible<
593 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,
597 _Up...
598 >::value
599 ))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000600 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
601 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
602 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
603 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
Howard Hinnant0949eed2011-06-30 21:18:19 +0000604 _VSTD::forward<_Up>(__u)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000605
606 template <class _Alloc, class ..._Up,
607 class = typename enable_if
608 <
609 sizeof...(_Up) <= sizeof...(_Tp) &&
610 __tuple_convertible
611 <
612 tuple<_Up...>,
613 typename __make_tuple_types<tuple,
614 sizeof...(_Up) < sizeof...(_Tp) ?
615 sizeof...(_Up) :
616 sizeof...(_Tp)>::type
617 >::value
618 >::type
619 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000620 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000621 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
622 : base_(allocator_arg_t(), __a,
623 typename __make_tuple_indices<sizeof...(_Up)>::type(),
624 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
625 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
626 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
Howard Hinnant0949eed2011-06-30 21:18:19 +0000627 _VSTD::forward<_Up>(__u)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000628
629 template <class _Tuple,
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000630 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000631 <
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000632 __tuple_convertible<_Tuple, tuple>::value,
633 bool
634 >::type = false
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000635 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000636 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000637 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000638 : base_(_VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000639
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000640 template <class _Tuple,
641 typename enable_if
642 <
643 __tuple_constructible<_Tuple, tuple>::value &&
644 !__tuple_convertible<_Tuple, tuple>::value,
645 bool
646 >::type = false
647 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000648 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000649 explicit
Howard Hinnant74f26f22012-07-06 21:53:48 +0000650 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000651 : base_(_VSTD::forward<_Tuple>(__t)) {}
652
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000653 template <class _Alloc, class _Tuple,
654 class = typename enable_if
655 <
656 __tuple_convertible<_Tuple, tuple>::value
657 >::type
658 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000659 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000660 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000661 : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000662
663 template <class _Tuple,
664 class = typename enable_if
665 <
666 __tuple_assignable<_Tuple, tuple>::value
667 >::type
668 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000669 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000670 tuple&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000671 operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000672 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000673 base_.operator=(_VSTD::forward<_Tuple>(__t));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000674 return *this;
675 }
676
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000677 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000678 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
679 {base_.swap(__t.base_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000680};
681
682template <>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000683class _LIBCPP_TYPE_VIS_ONLY tuple<>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000684{
685public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000686 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000687 _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000688 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000689 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000690 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000691 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000692 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000693 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
Howard Hinnant99968442011-11-29 18:15:50 +0000694 template <class _Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000695 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000696 tuple(array<_Up, 0>) _NOEXCEPT {}
Howard Hinnant99968442011-11-29 18:15:50 +0000697 template <class _Alloc, class _Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000698 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000699 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000700 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000701 void swap(tuple&) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000702};
703
704template <class ..._Tp>
705inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantaabf2872011-06-01 19:59:32 +0000706typename enable_if
707<
708 __all<__is_swappable<_Tp>::value...>::value,
709 void
710>::type
Howard Hinnanta5e01212011-05-27 19:08:18 +0000711swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
712 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
713 {__t.swap(__u);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000714
715// get
716
717template <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 Hinnantbc8d3f92010-05-11 19:42:16 +0000721{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000722 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000723 return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get();
724}
725
726template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000727inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25 +0000728const typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000729get(const tuple<_Tp...>& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000730{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000731 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000732 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
733}
734
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000735template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000736inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25 +0000737typename tuple_element<_Ip, tuple<_Tp...> >::type&&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000738get(tuple<_Tp...>&& __t) _NOEXCEPT
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000739{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000740 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnant56a85ca2011-01-25 16:31:30 +0000741 return static_cast<type&&>(
Douglas Gregor6c669942011-01-25 16:14:21 +0000742 static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000743}
744
Marshall Clowe8029e52013-07-13 02:54:05 +0000745#if _LIBCPP_STD_VER > 11
746// get by type
747template <typename _T1, size_t _Idx, typename... _Args>
748struct __find_exactly_one_t_helper;
749
750// -- find exactly one
751template <typename _T1, size_t _Idx, typename... _Args>
752struct __find_exactly_one_t_checker {
753 static constexpr size_t value = _Idx;
754// Check the rest of the list to make sure there's only one
755 static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" );
756 };
757
758
759template <typename _T1, size_t _Idx>
760struct __find_exactly_one_t_helper <_T1, _Idx> {
761 static constexpr size_t value = -1;
762 };
763
764template <typename _T1, size_t _Idx, typename _Head, typename... _Args>
765struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> {
766 static constexpr size_t value =
767 std::conditional<
768 std::is_same<_T1, _Head>::value,
Marshall Clow19e78622013-10-01 13:28:20 +0000769 __find_exactly_one_t_checker<_T1, _Idx, _Args...>,
Marshall Clowe8029e52013-07-13 02:54:05 +0000770 __find_exactly_one_t_helper <_T1, _Idx+1, _Args...>
771 >::type::value;
772 };
773
774template <typename _T1, typename... _Args>
775struct __find_exactly_one_t {
776 static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value;
777 static_assert ( value != -1, "type not found in type list" );
778 };
779
780template <class _T1, class... _Args>
781inline _LIBCPP_INLINE_VISIBILITY
782constexpr _T1& get(tuple<_Args...>& __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 const& get(tuple<_Args...> const& __tup) noexcept
790{
791 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
792}
793
794template <class _T1, class... _Args>
795inline _LIBCPP_INLINE_VISIBILITY
796constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
797{
Marshall Clow01a0e902013-07-15 20:46:11 +0000798 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
Marshall Clowe8029e52013-07-13 02:54:05 +0000799}
800
801#endif
802
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000803// tie
804
805template <class ..._Tp>
Marshall Clow8e554d92014-02-25 16:11:46 +0000806inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000807tuple<_Tp&...>
Howard Hinnant74f26f22012-07-06 21:53:48 +0000808tie(_Tp&... __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000809{
810 return tuple<_Tp&...>(__t...);
811}
812
813template <class _Up>
814struct __ignore_t
815{
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000816 template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000817 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000818 const __ignore_t& operator=(_Tp&&) const {return *this;}
819};
820
821namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
822
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000823template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000824
825template <class _Tp>
Marshall Clowa71f9562014-01-03 22:55:49 +0000826struct __make_tuple_return_impl
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000827{
828 typedef _Tp type;
829};
830
831template <class _Tp>
Marshall Clowa71f9562014-01-03 22:55:49 +0000832struct __make_tuple_return_impl<reference_wrapper<_Tp> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000833{
834 typedef _Tp& type;
835};
836
837template <class _Tp>
838struct __make_tuple_return
839{
Marshall Clowa71f9562014-01-03 22:55:49 +0000840 typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000841};
842
843template <class... _Tp>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000844inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000845tuple<typename __make_tuple_return<_Tp>::type...>
846make_tuple(_Tp&&... __t)
847{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000848 return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000849}
850
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000851template <class... _Tp>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000852inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
853tuple<_Tp&&...>
Howard Hinnant74f26f22012-07-06 21:53:48 +0000854forward_as_tuple(_Tp&&... __t) _NOEXCEPT
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000855{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000856 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000857}
858
Howard Hinnant99968442011-11-29 18:15:50 +0000859template <size_t _Ip>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000860struct __tuple_equal
861{
862 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000863 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000864 bool operator()(const _Tp& __x, const _Up& __y)
865 {
Howard Hinnant99968442011-11-29 18:15:50 +0000866 return __tuple_equal<_Ip - 1>()(__x, __y) && get<_Ip-1>(__x) == get<_Ip-1>(__y);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000867 }
868};
869
870template <>
871struct __tuple_equal<0>
872{
873 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000874 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000875 bool operator()(const _Tp&, const _Up&)
876 {
877 return true;
878 }
879};
880
881template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000882inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000883bool
884operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
885{
886 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
887}
888
889template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000890inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000891bool
892operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
893{
894 return !(__x == __y);
895}
896
Howard Hinnant99968442011-11-29 18:15:50 +0000897template <size_t _Ip>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000898struct __tuple_less
899{
900 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000901 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000902 bool operator()(const _Tp& __x, const _Up& __y)
903 {
Howard Hinnant99968442011-11-29 18:15:50 +0000904 return __tuple_less<_Ip-1>()(__x, __y) ||
905 (!__tuple_less<_Ip-1>()(__y, __x) && get<_Ip-1>(__x) < get<_Ip-1>(__y));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000906 }
907};
908
909template <>
910struct __tuple_less<0>
911{
912 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000913 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000914 bool operator()(const _Tp&, const _Up&)
915 {
916 return false;
917 }
918};
919
920template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000921inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000922bool
923operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
924{
925 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
926}
927
928template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000929inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000930bool
931operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
932{
933 return __y < __x;
934}
935
936template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000937inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000938bool
939operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
940{
941 return !(__x < __y);
942}
943
944template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000945inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000946bool
947operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
948{
949 return !(__y < __x);
950}
951
952// tuple_cat
953
Howard Hinnant0e1493e2010-12-11 20:47:50 +0000954template <class _Tp, class _Up> struct __tuple_cat_type;
955
956template <class ..._Ttypes, class ..._Utypes>
Howard Hinnantf83417b2011-01-24 16:07:25 +0000957struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000958{
Howard Hinnant0e1493e2010-12-11 20:47:50 +0000959 typedef tuple<_Ttypes..., _Utypes...> type;
960};
961
962template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
963struct __tuple_cat_return_1
964{
965};
966
967template <class ..._Types, class _Tuple0>
968struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
969{
970 typedef typename __tuple_cat_type<tuple<_Types...>,
971 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
972 type;
973};
974
975template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
976struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
977 : public __tuple_cat_return_1<
978 typename __tuple_cat_type<
979 tuple<_Types...>,
980 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
981 >::type,
982 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
983 _Tuple1, _Tuples...>
984{
985};
986
987template <class ..._Tuples> struct __tuple_cat_return;
988
989template <class _Tuple0, class ..._Tuples>
990struct __tuple_cat_return<_Tuple0, _Tuples...>
991 : public __tuple_cat_return_1<tuple<>,
992 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
993 _Tuples...>
994{
995};
996
997template <>
998struct __tuple_cat_return<>
999{
1000 typedef tuple<> type;
1001};
1002
Marshall Clowda0a0e82013-07-22 16:02:19 +00001003inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant0e1493e2010-12-11 20:47:50 +00001004tuple<>
1005tuple_cat()
1006{
1007 return tuple<>();
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001008}
1009
Howard Hinnant99968442011-11-29 18:15:50 +00001010template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
Howard Hinnante48e3662010-12-12 23:04:37 +00001011struct __tuple_cat_return_ref_imp;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001012
Howard Hinnante48e3662010-12-12 23:04:37 +00001013template <class ..._Types, size_t ..._I0, class _Tuple0>
1014struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001015{
Howard Hinnant0e1493e2010-12-11 20:47:50 +00001016 typedef typename remove_reference<_Tuple0>::type _T0;
Howard Hinnante48e3662010-12-12 23:04:37 +00001017 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1018 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1019};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001020
Howard Hinnante48e3662010-12-12 23:04:37 +00001021template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1022struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1023 _Tuple0, _Tuple1, _Tuples...>
1024 : public __tuple_cat_return_ref_imp<
1025 tuple<_Types..., typename __apply_cv<_Tuple0,
1026 typename tuple_element<_I0,
1027 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1028 typename __make_tuple_indices<tuple_size<typename
1029 remove_reference<_Tuple1>::type>::value>::type,
1030 _Tuple1, _Tuples...>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001031{
Howard Hinnante48e3662010-12-12 23:04:37 +00001032};
1033
1034template <class _Tuple0, class ..._Tuples>
1035struct __tuple_cat_return_ref
1036 : public __tuple_cat_return_ref_imp<tuple<>,
1037 typename __make_tuple_indices<
1038 tuple_size<typename remove_reference<_Tuple0>::type>::value
1039 >::type, _Tuple0, _Tuples...>
1040{
1041};
1042
1043template <class _Types, class _I0, class _J0>
1044struct __tuple_cat;
1045
1046template <class ..._Types, size_t ..._I0, size_t ..._J0>
Howard Hinnantf83417b2011-01-24 16:07:25 +00001047struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
Howard Hinnante48e3662010-12-12 23:04:37 +00001048{
1049 template <class _Tuple0>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001050 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001051 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1052 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1053 {
Marshall Clow1d927e32013-10-05 18:46:37 +00001054 return forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))...,
Howard Hinnant0949eed2011-06-30 21:18:19 +00001055 get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
Howard Hinnante48e3662010-12-12 23:04:37 +00001056 }
1057
1058 template <class _Tuple0, class _Tuple1, class ..._Tuples>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001059 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001060 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1061 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1062 {
1063 typedef typename remove_reference<_Tuple0>::type _T0;
1064 typedef typename remove_reference<_Tuple1>::type _T1;
1065 return __tuple_cat<
1066 tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1067 typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1068 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
Marshall Clow1d927e32013-10-05 18:46:37 +00001069 (forward_as_tuple(
Howard Hinnant0949eed2011-06-30 21:18:19 +00001070 _VSTD::forward<_Types>(get<_I0>(__t))...,
1071 get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
Howard Hinnante48e3662010-12-12 23:04:37 +00001072 ),
Howard Hinnant0949eed2011-06-30 21:18:19 +00001073 _VSTD::forward<_Tuple1>(__t1),
1074 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnante48e3662010-12-12 23:04:37 +00001075 }
1076};
1077
1078template <class _Tuple0, class... _Tuples>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001079inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001080typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1081tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1082{
1083 typedef typename remove_reference<_Tuple0>::type _T0;
1084 return __tuple_cat<tuple<>, __tuple_indices<>,
1085 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
Howard Hinnant0949eed2011-06-30 21:18:19 +00001086 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1087 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001088}
1089
1090template <class ..._Tp, class _Alloc>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001091struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001092 : true_type {};
1093
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001094template <class _T1, class _T2>
1095template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1096inline _LIBCPP_INLINE_VISIBILITY
1097pair<_T1, _T2>::pair(piecewise_construct_t,
1098 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1099 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
Howard Hinnant0949eed2011-06-30 21:18:19 +00001100 : first(_VSTD::forward<_Args1>(get<_I1>( __first_args))...),
1101 second(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001102{
1103}
1104
Howard Hinnant324bb032010-08-22 00:02:43 +00001105#endif // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001106
1107_LIBCPP_END_NAMESPACE_STD
1108
1109#endif // _LIBCPP_TUPLE