blob: e98ae7228e7011238325a181a23b82740b258aaa [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 Clow398c9d82014-04-21 23:48:09 +0000271 __tuple_leaf(const __tuple_leaf& __t) = default;
272 __tuple_leaf(__tuple_leaf&& __t) = default;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000273
274 template <class _Tp>
275 _LIBCPP_INLINE_VISIBILITY
276 __tuple_leaf&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000277 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000278 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000279 value = _VSTD::forward<_Tp>(__t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000280 return *this;
281 }
282
283 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000284 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000285 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000286 _VSTD::swap(*this, __t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000287 return 0;
288 }
289
Marshall Clowda0a0e82013-07-22 16:02:19 +0000290 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return value;}
291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return value;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000292};
293
294template <size_t _Ip, class _Hp>
295class __tuple_leaf<_Ip, _Hp, true>
296 : private _Hp
297{
298
299 __tuple_leaf& operator=(const __tuple_leaf&);
300public:
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000301 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
302 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000303
304 template <class _Alloc>
305 _LIBCPP_INLINE_VISIBILITY
306 __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
307
308 template <class _Alloc>
309 _LIBCPP_INLINE_VISIBILITY
310 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
311 : _Hp(allocator_arg_t(), __a) {}
312
313 template <class _Alloc>
314 _LIBCPP_INLINE_VISIBILITY
315 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
316 : _Hp(__a) {}
317
Howard Hinnante049cc52010-09-27 17:54:17 +0000318 template <class _Tp,
319 class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000320 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000321 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000322 : _Hp(_VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000323
324 template <class _Tp, class _Alloc>
325 _LIBCPP_INLINE_VISIBILITY
326 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000327 : _Hp(_VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000328
329 template <class _Tp, class _Alloc>
330 _LIBCPP_INLINE_VISIBILITY
331 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000332 : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000333
334 template <class _Tp, class _Alloc>
335 _LIBCPP_INLINE_VISIBILITY
336 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000337 : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000338
339 template <class _Tp>
340 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000341 __tuple_leaf&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000342 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000343 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000344 _Hp::operator=(_VSTD::forward<_Tp>(__t));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000345 return *this;
346 }
347
Howard Hinnanta5e01212011-05-27 19:08:18 +0000348 _LIBCPP_INLINE_VISIBILITY
349 int
350 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000351 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000352 _VSTD::swap(*this, __t);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000353 return 0;
354 }
355
Marshall Clowda0a0e82013-07-22 16:02:19 +0000356 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
357 _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 +0000358};
359
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000360template <class ..._Tp>
361_LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000362void __swallow(_Tp&&...) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000363
Howard Hinnanta5e01212011-05-27 19:08:18 +0000364template <bool ...> struct __all;
365
366template <>
367struct __all<>
368{
369 static const bool value = true;
370};
371
Howard Hinnant99968442011-11-29 18:15:50 +0000372template <bool _B0, bool ... _Bp>
373struct __all<_B0, _Bp...>
Howard Hinnanta5e01212011-05-27 19:08:18 +0000374{
Howard Hinnant99968442011-11-29 18:15:50 +0000375 static const bool value = _B0 && __all<_Bp...>::value;
Howard Hinnanta5e01212011-05-27 19:08:18 +0000376};
377
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000378// __tuple_impl
379
380template<class _Indx, class ..._Tp> struct __tuple_impl;
381
382template<size_t ..._Indx, class ..._Tp>
383struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
384 : public __tuple_leaf<_Indx, _Tp>...
385{
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000386 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000387 _LIBCPP_CONSTEXPR __tuple_impl()
388 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000389
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000390 template <size_t ..._Uf, class ..._Tf,
391 size_t ..._Ul, class ..._Tl, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000392 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000393 explicit
394 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
395 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
Howard Hinnant74f26f22012-07-06 21:53:48 +0000396 _Up&&... __u)
397 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
398 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
Howard Hinnant0949eed2011-06-30 21:18:19 +0000399 __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000400 __tuple_leaf<_Ul, _Tl>()...
401 {}
402
403 template <class _Alloc, size_t ..._Uf, class ..._Tf,
404 size_t ..._Ul, class ..._Tl, class ..._Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000405 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000406 explicit
407 __tuple_impl(allocator_arg_t, const _Alloc& __a,
408 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
409 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
410 _Up&&... __u) :
411 __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
Howard Hinnant0949eed2011-06-30 21:18:19 +0000412 _VSTD::forward<_Up>(__u))...,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000413 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
414 {}
415
416 template <class _Tuple,
417 class = typename enable_if
418 <
Howard Hinnant99324892013-04-14 00:01:13 +0000419 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000420 >::type
421 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000422 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000423 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
424 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000425 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
426 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000427 {}
428
429 template <class _Alloc, class _Tuple,
430 class = typename enable_if
431 <
Howard Hinnantf83417b2011-01-24 16:07:25 +0000432 __tuple_convertible<_Tuple, tuple<_Tp...> >::value
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000433 >::type
434 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000435 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000436 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
437 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
Howard Hinnant324bb032010-08-22 00:02:43 +0000438 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
Howard Hinnant0949eed2011-06-30 21:18:19 +0000439 _VSTD::forward<typename tuple_element<_Indx,
440 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000441 {}
442
443 template <class _Tuple>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000444 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000445 typename enable_if
446 <
Howard Hinnantf83417b2011-01-24 16:07:25 +0000447 __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000448 __tuple_impl&
449 >::type
Howard Hinnant74f26f22012-07-06 21:53:48 +0000450 operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
451 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000452 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000453 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
454 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000455 return *this;
456 }
457
Howard Hinnant3de50862013-11-06 17:45:43 +0000458 __tuple_impl(const __tuple_impl&) = default;
459 __tuple_impl(__tuple_impl&&) = default;
460
461 _LIBCPP_INLINE_VISIBILITY
462 __tuple_impl&
463 operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
464 {
465 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
466 return *this;
467 }
468
469 _LIBCPP_INLINE_VISIBILITY
470 __tuple_impl&
471 operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
472 {
473 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
474 return *this;
475 }
Howard Hinnant28484442012-02-15 20:13:52 +0000476
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000477 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000478 void swap(__tuple_impl& __t)
Howard Hinnanta5e01212011-05-27 19:08:18 +0000479 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000480 {
481 __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
482 }
483};
484
485template <class ..._Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000486class _LIBCPP_TYPE_VIS_ONLY tuple
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000487{
488 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
489
490 base base_;
491
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000492 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000493 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000494 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000495 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
Marshall Clow8fc4f5a2013-07-17 18:25:36 +0000496 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04 +0000497 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000498public:
499
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000500 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000501 _LIBCPP_CONSTEXPR tuple()
502 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
Howard Hinnant5394c1e2012-07-06 20:39:45 +0000503
Marshall Clowda0a0e82013-07-22 16:02:19 +0000504 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000505 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000506 : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
507 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
508 typename __make_tuple_indices<0>::type(),
509 typename __make_tuple_types<tuple, 0>::type(),
510 __t...
511 ) {}
512
513 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000514 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000515 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
516 : base_(allocator_arg_t(), __a,
517 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
518 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
519 typename __make_tuple_indices<0>::type(),
520 typename __make_tuple_types<tuple, 0>::type(),
521 __t...
522 ) {}
523
524 template <class ..._Up,
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000525 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000526 <
527 sizeof...(_Up) <= sizeof...(_Tp) &&
528 __tuple_convertible
529 <
530 tuple<_Up...>,
531 typename __make_tuple_types<tuple,
532 sizeof...(_Up) < sizeof...(_Tp) ?
533 sizeof...(_Up) :
534 sizeof...(_Tp)>::type
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000535 >::value,
536 bool
537 >::type = false
538 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000539 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000540 tuple(_Up&&... __u)
Howard Hinnant74f26f22012-07-06 21:53:48 +0000541 _NOEXCEPT_((
542 is_nothrow_constructible<
543 typename __make_tuple_indices<sizeof...(_Up)>::type,
544 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
545 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
546 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
547 _Up...
548 >::value
549 ))
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000550 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
551 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
552 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
553 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
554 _VSTD::forward<_Up>(__u)...) {}
555
556 template <class ..._Up,
557 typename enable_if
558 <
559 sizeof...(_Up) <= sizeof...(_Tp) &&
560 __tuple_constructible
561 <
562 tuple<_Up...>,
563 typename __make_tuple_types<tuple,
564 sizeof...(_Up) < sizeof...(_Tp) ?
565 sizeof...(_Up) :
566 sizeof...(_Tp)>::type
567 >::value &&
568 !__tuple_convertible
569 <
570 tuple<_Up...>,
571 typename __make_tuple_types<tuple,
572 sizeof...(_Up) < sizeof...(_Tp) ?
573 sizeof...(_Up) :
574 sizeof...(_Tp)>::type
575 >::value,
576 bool
577 >::type =false
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000578 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000579 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000580 explicit
581 tuple(_Up&&... __u)
Howard Hinnant74f26f22012-07-06 21:53:48 +0000582 _NOEXCEPT_((
583 is_nothrow_constructible<
584 typename __make_tuple_indices<sizeof...(_Up)>::type,
585 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
586 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
587 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
588 _Up...
589 >::value
590 ))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000591 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
592 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
593 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
594 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
Howard Hinnant0949eed2011-06-30 21:18:19 +0000595 _VSTD::forward<_Up>(__u)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000596
597 template <class _Alloc, class ..._Up,
598 class = typename enable_if
599 <
600 sizeof...(_Up) <= sizeof...(_Tp) &&
601 __tuple_convertible
602 <
603 tuple<_Up...>,
604 typename __make_tuple_types<tuple,
605 sizeof...(_Up) < sizeof...(_Tp) ?
606 sizeof...(_Up) :
607 sizeof...(_Tp)>::type
608 >::value
609 >::type
610 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000611 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000612 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
613 : base_(allocator_arg_t(), __a,
614 typename __make_tuple_indices<sizeof...(_Up)>::type(),
615 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
616 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
617 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
Howard Hinnant0949eed2011-06-30 21:18:19 +0000618 _VSTD::forward<_Up>(__u)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000619
620 template <class _Tuple,
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000621 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000622 <
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000623 __tuple_convertible<_Tuple, tuple>::value,
624 bool
625 >::type = false
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000626 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000627 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48 +0000628 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
Howard Hinnant0949eed2011-06-30 21:18:19 +0000629 : base_(_VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000630
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000631 template <class _Tuple,
632 typename enable_if
633 <
634 __tuple_constructible<_Tuple, tuple>::value &&
635 !__tuple_convertible<_Tuple, tuple>::value,
636 bool
637 >::type = false
638 >
Marshall Clowda0a0e82013-07-22 16:02:19 +0000639 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000640 explicit
Howard Hinnant74f26f22012-07-06 21:53:48 +0000641 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
Howard Hinnantdc1345f2012-04-01 23:10:42 +0000642 : base_(_VSTD::forward<_Tuple>(__t)) {}
643
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000644 template <class _Alloc, class _Tuple,
645 class = typename enable_if
646 <
647 __tuple_convertible<_Tuple, tuple>::value
648 >::type
649 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000650 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000651 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000652 : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000653
654 template <class _Tuple,
655 class = typename enable_if
656 <
657 __tuple_assignable<_Tuple, tuple>::value
658 >::type
659 >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000660 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000661 tuple&
Howard Hinnant74f26f22012-07-06 21:53:48 +0000662 operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000663 {
Howard Hinnant0949eed2011-06-30 21:18:19 +0000664 base_.operator=(_VSTD::forward<_Tuple>(__t));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000665 return *this;
666 }
667
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000668 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000669 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
670 {base_.swap(__t.base_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000671};
672
673template <>
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000674class _LIBCPP_TYPE_VIS_ONLY tuple<>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000675{
676public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000677 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27 +0000678 _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000679 template <class _Alloc>
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&) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000682 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000683 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000684 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
Howard Hinnant99968442011-11-29 18:15:50 +0000685 template <class _Up>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000686 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48 +0000687 tuple(array<_Up, 0>) _NOEXCEPT {}
Howard Hinnant99968442011-11-29 18:15:50 +0000688 template <class _Alloc, class _Up>
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&, array<_Up, 0>) _NOEXCEPT {}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000691 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18 +0000692 void swap(tuple&) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000693};
694
695template <class ..._Tp>
696inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantaabf2872011-06-01 19:59:32 +0000697typename enable_if
698<
699 __all<__is_swappable<_Tp>::value...>::value,
700 void
701>::type
Howard Hinnanta5e01212011-05-27 19:08:18 +0000702swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
703 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
704 {__t.swap(__u);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000705
706// get
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 +0000710typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000711get(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<__tuple_leaf<_Ip, type>&>(__t.base_).get();
715}
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 +0000719const typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000720get(const 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<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
724}
725
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000726template <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 +0000728typename tuple_element<_Ip, tuple<_Tp...> >::type&&
Howard Hinnantec3773c2011-12-01 20:21:04 +0000729get(tuple<_Tp...>&& __t) _NOEXCEPT
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000730{
Howard Hinnantf83417b2011-01-24 16:07:25 +0000731 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnant56a85ca2011-01-25 16:31:30 +0000732 return static_cast<type&&>(
Douglas Gregor6c669942011-01-25 16:14:21 +0000733 static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
Howard Hinnantcd2254b2010-11-17 19:52:17 +0000734}
735
Marshall Clowe8029e52013-07-13 02:54:05 +0000736#if _LIBCPP_STD_VER > 11
737// get by type
738template <typename _T1, size_t _Idx, typename... _Args>
739struct __find_exactly_one_t_helper;
740
741// -- find exactly one
742template <typename _T1, size_t _Idx, typename... _Args>
743struct __find_exactly_one_t_checker {
744 static constexpr size_t value = _Idx;
745// Check the rest of the list to make sure there's only one
746 static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" );
747 };
748
749
750template <typename _T1, size_t _Idx>
751struct __find_exactly_one_t_helper <_T1, _Idx> {
752 static constexpr size_t value = -1;
753 };
754
755template <typename _T1, size_t _Idx, typename _Head, typename... _Args>
756struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> {
757 static constexpr size_t value =
758 std::conditional<
759 std::is_same<_T1, _Head>::value,
Marshall Clow19e78622013-10-01 13:28:20 +0000760 __find_exactly_one_t_checker<_T1, _Idx, _Args...>,
Marshall Clowe8029e52013-07-13 02:54:05 +0000761 __find_exactly_one_t_helper <_T1, _Idx+1, _Args...>
762 >::type::value;
763 };
764
765template <typename _T1, typename... _Args>
766struct __find_exactly_one_t {
767 static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value;
768 static_assert ( value != -1, "type not found in type list" );
769 };
770
771template <class _T1, class... _Args>
772inline _LIBCPP_INLINE_VISIBILITY
773constexpr _T1& get(tuple<_Args...>& __tup) noexcept
774{
775 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
776}
777
778template <class _T1, class... _Args>
779inline _LIBCPP_INLINE_VISIBILITY
780constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
781{
782 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
783}
784
785template <class _T1, class... _Args>
786inline _LIBCPP_INLINE_VISIBILITY
787constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
788{
Marshall Clow01a0e902013-07-15 20:46:11 +0000789 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
Marshall Clowe8029e52013-07-13 02:54:05 +0000790}
791
792#endif
793
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000794// tie
795
796template <class ..._Tp>
Marshall Clow8e554d92014-02-25 16:11:46 +0000797inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000798tuple<_Tp&...>
Howard Hinnant74f26f22012-07-06 21:53:48 +0000799tie(_Tp&... __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000800{
801 return tuple<_Tp&...>(__t...);
802}
803
804template <class _Up>
805struct __ignore_t
806{
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000807 template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000808 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000809 const __ignore_t& operator=(_Tp&&) const {return *this;}
810};
811
812namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
813
Howard Hinnant0f678bd2013-08-12 18:38:34 +0000814template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000815
816template <class _Tp>
Marshall Clowa71f9562014-01-03 22:55:49 +0000817struct __make_tuple_return_impl
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000818{
819 typedef _Tp type;
820};
821
822template <class _Tp>
Marshall Clowa71f9562014-01-03 22:55:49 +0000823struct __make_tuple_return_impl<reference_wrapper<_Tp> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000824{
825 typedef _Tp& type;
826};
827
828template <class _Tp>
829struct __make_tuple_return
830{
Marshall Clowa71f9562014-01-03 22:55:49 +0000831 typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000832};
833
834template <class... _Tp>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000835inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000836tuple<typename __make_tuple_return<_Tp>::type...>
837make_tuple(_Tp&&... __t)
838{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000839 return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000840}
841
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000842template <class... _Tp>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000843inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
844tuple<_Tp&&...>
Howard Hinnant74f26f22012-07-06 21:53:48 +0000845forward_as_tuple(_Tp&&... __t) _NOEXCEPT
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000846{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000847 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnant3c1ffba2010-08-19 18:59:38 +0000848}
849
Howard Hinnant99968442011-11-29 18:15:50 +0000850template <size_t _Ip>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000851struct __tuple_equal
852{
853 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000854 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000855 bool operator()(const _Tp& __x, const _Up& __y)
856 {
Marshall Clowba6dbf42014-06-24 00:46:19 +0000857 return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000858 }
859};
860
861template <>
862struct __tuple_equal<0>
863{
864 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000865 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000866 bool operator()(const _Tp&, const _Up&)
867 {
868 return true;
869 }
870};
871
872template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000873inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000874bool
875operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
876{
877 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
878}
879
880template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000881inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000882bool
883operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
884{
885 return !(__x == __y);
886}
887
Howard Hinnant99968442011-11-29 18:15:50 +0000888template <size_t _Ip>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000889struct __tuple_less
890{
891 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000892 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000893 bool operator()(const _Tp& __x, const _Up& __y)
894 {
Howard Hinnant99968442011-11-29 18:15:50 +0000895 return __tuple_less<_Ip-1>()(__x, __y) ||
Marshall Clowba6dbf42014-06-24 00:46:19 +0000896 (!__tuple_less<_Ip-1>()(__y, __x) && _VSTD::get<_Ip-1>(__x) < _VSTD::get<_Ip-1>(__y));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000897 }
898};
899
900template <>
901struct __tuple_less<0>
902{
903 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000904 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000905 bool operator()(const _Tp&, const _Up&)
906 {
907 return false;
908 }
909};
910
911template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000912inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000913bool
914operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
915{
916 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
917}
918
919template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000920inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000921bool
922operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
923{
924 return __y < __x;
925}
926
927template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000928inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000929bool
930operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
931{
932 return !(__x < __y);
933}
934
935template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19 +0000936inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000937bool
938operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
939{
940 return !(__y < __x);
941}
942
943// tuple_cat
944
Howard Hinnant0e1493e2010-12-11 20:47:50 +0000945template <class _Tp, class _Up> struct __tuple_cat_type;
946
947template <class ..._Ttypes, class ..._Utypes>
Howard Hinnantf83417b2011-01-24 16:07:25 +0000948struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000949{
Howard Hinnant0e1493e2010-12-11 20:47:50 +0000950 typedef tuple<_Ttypes..., _Utypes...> type;
951};
952
953template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
954struct __tuple_cat_return_1
955{
956};
957
958template <class ..._Types, class _Tuple0>
959struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
960{
961 typedef typename __tuple_cat_type<tuple<_Types...>,
962 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
963 type;
964};
965
966template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
967struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
968 : public __tuple_cat_return_1<
969 typename __tuple_cat_type<
970 tuple<_Types...>,
971 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
972 >::type,
973 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
974 _Tuple1, _Tuples...>
975{
976};
977
978template <class ..._Tuples> struct __tuple_cat_return;
979
980template <class _Tuple0, class ..._Tuples>
981struct __tuple_cat_return<_Tuple0, _Tuples...>
982 : public __tuple_cat_return_1<tuple<>,
983 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
984 _Tuples...>
985{
986};
987
988template <>
989struct __tuple_cat_return<>
990{
991 typedef tuple<> type;
992};
993
Marshall Clowda0a0e82013-07-22 16:02:19 +0000994inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant0e1493e2010-12-11 20:47:50 +0000995tuple<>
996tuple_cat()
997{
998 return tuple<>();
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000999}
1000
Howard Hinnant99968442011-11-29 18:15:50 +00001001template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
Howard Hinnante48e3662010-12-12 23:04:37 +00001002struct __tuple_cat_return_ref_imp;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001003
Howard Hinnante48e3662010-12-12 23:04:37 +00001004template <class ..._Types, size_t ..._I0, class _Tuple0>
1005struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001006{
Howard Hinnant0e1493e2010-12-11 20:47:50 +00001007 typedef typename remove_reference<_Tuple0>::type _T0;
Howard Hinnante48e3662010-12-12 23:04:37 +00001008 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1009 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1010};
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001011
Howard Hinnante48e3662010-12-12 23:04:37 +00001012template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1013struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1014 _Tuple0, _Tuple1, _Tuples...>
1015 : public __tuple_cat_return_ref_imp<
1016 tuple<_Types..., typename __apply_cv<_Tuple0,
1017 typename tuple_element<_I0,
1018 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1019 typename __make_tuple_indices<tuple_size<typename
1020 remove_reference<_Tuple1>::type>::value>::type,
1021 _Tuple1, _Tuples...>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001022{
Howard Hinnante48e3662010-12-12 23:04:37 +00001023};
1024
1025template <class _Tuple0, class ..._Tuples>
1026struct __tuple_cat_return_ref
1027 : public __tuple_cat_return_ref_imp<tuple<>,
1028 typename __make_tuple_indices<
1029 tuple_size<typename remove_reference<_Tuple0>::type>::value
1030 >::type, _Tuple0, _Tuples...>
1031{
1032};
1033
1034template <class _Types, class _I0, class _J0>
1035struct __tuple_cat;
1036
1037template <class ..._Types, size_t ..._I0, size_t ..._J0>
Howard Hinnantf83417b2011-01-24 16:07:25 +00001038struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
Howard Hinnante48e3662010-12-12 23:04:37 +00001039{
1040 template <class _Tuple0>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001041 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001042 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1043 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1044 {
Marshall Clowba6dbf42014-06-24 00:46:19 +00001045 return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1046 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
Howard Hinnante48e3662010-12-12 23:04:37 +00001047 }
1048
1049 template <class _Tuple0, class _Tuple1, class ..._Tuples>
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&&, _Tuple1&&, _Tuples&&...>::type
1052 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1053 {
1054 typedef typename remove_reference<_Tuple0>::type _T0;
1055 typedef typename remove_reference<_Tuple1>::type _T1;
1056 return __tuple_cat<
1057 tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1058 typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1059 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
Marshall Clow1d927e32013-10-05 18:46:37 +00001060 (forward_as_tuple(
Marshall Clowba6dbf42014-06-24 00:46:19 +00001061 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1062 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
Howard Hinnante48e3662010-12-12 23:04:37 +00001063 ),
Howard Hinnant0949eed2011-06-30 21:18:19 +00001064 _VSTD::forward<_Tuple1>(__t1),
1065 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnante48e3662010-12-12 23:04:37 +00001066 }
1067};
1068
1069template <class _Tuple0, class... _Tuples>
Marshall Clowda0a0e82013-07-22 16:02:19 +00001070inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:37 +00001071typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1072tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1073{
1074 typedef typename remove_reference<_Tuple0>::type _T0;
1075 return __tuple_cat<tuple<>, __tuple_indices<>,
1076 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
Howard Hinnant0949eed2011-06-30 21:18:19 +00001077 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1078 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001079}
1080
1081template <class ..._Tp, class _Alloc>
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001082struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001083 : true_type {};
1084
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001085template <class _T1, class _T2>
1086template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1087inline _LIBCPP_INLINE_VISIBILITY
1088pair<_T1, _T2>::pair(piecewise_construct_t,
1089 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1090 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
Marshall Clowba6dbf42014-06-24 00:46:19 +00001091 : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
1092 second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001093{
1094}
1095
Howard Hinnant324bb032010-08-22 00:02:43 +00001096#endif // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001097
1098_LIBCPP_END_NAMESPACE_STD
1099
1100#endif // _LIBCPP_TUPLE