blob: a39eeda60b7681168dd66f507d8afcb5d066f423 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:161// -*- C++ -*-
2//===--------------------------- tuple ------------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:014// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:165//
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:1924 explicit tuple(const T&...); // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1625 template <class... U>
Marshall Clowda0a0e82013-07-22 16:02:1926 explicit tuple(U&&...); // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1627 tuple(const tuple&) = default;
Howard Hinnanta5e01212011-05-27 19:08:1828 tuple(tuple&&) = default;
Howard Hinnantbc8d3f92010-05-11 19:42:1629 template <class... U>
Marshall Clowda0a0e82013-07-22 16:02:1930 tuple(const tuple<U...>&); // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1631 template <class... U>
Marshall Clowda0a0e82013-07-22 16:02:1932 tuple(tuple<U...>&&); // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1633 template <class U1, class U2>
Marshall Clowda0a0e82013-07-22 16:02:1934 tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1635 template <class U1, class U2>
Marshall Clowda0a0e82013-07-22 16:02:1936 tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1637
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:1859 tuple&
60 operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
Howard Hinnantbc8d3f92010-05-11 19:42:1661 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:1870 void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
Howard Hinnantbc8d3f92010-05-11 19:42:1671};
72
73const unspecified ignore;
74
Marshall Clowda0a0e82013-07-22 16:02:1975template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
Marshall Clow1d927e32013-10-05 18:46:3776template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
Marshall Clow8e554d92014-02-25 16:11:4677template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
Marshall Clowda0a0e82013-07-22 16:02:1978template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
Howard Hinnant0e1493e2010-12-11 20:47:5079
Howard Hinnantbc8d3f92010-05-11 19:42:1680// 20.4.1.4, tuple helper classes:
81template <class T> class tuple_size; // undefined
82template <class... T> class tuple_size<tuple<T...>>;
Marshall Clowa6607572015-11-19 19:45:2983template <size_t I, class T> class tuple_element; // undefined
84template <size_t I, class... T> class tuple_element<I, tuple<T...>>;
85template <size_t I, class T>
86 using tuple_element_t = typename tuple_element <I, T>::type; // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1687
88// 20.4.1.5, element access:
Marshall Clowa6607572015-11-19 19:45:2989template <size_t I, class... T>
Howard Hinnanta5e01212011-05-27 19:08:1890 typename tuple_element<I, tuple<T...>>::type&
Marshall Clow8fc4f5a2013-07-17 18:25:3691 get(tuple<T...>&) noexcept; // constexpr in C++14
Marshall Clowa6607572015-11-19 19:45:2992template <size_t I, class... T>
93 const typename tuple_element<I, tuple<T...>>::type&
Marshall Clow8fc4f5a2013-07-17 18:25:3694 get(const tuple<T...>&) noexcept; // constexpr in C++14
Marshall Clowa6607572015-11-19 19:45:2995template <size_t I, class... T>
Howard Hinnanta5e01212011-05-27 19:08:1896 typename tuple_element<I, tuple<T...>>::type&&
Marshall Clow8fc4f5a2013-07-17 18:25:3697 get(tuple<T...>&&) noexcept; // constexpr in C++14
Eric Fiselier199bee02015-12-18 00:36:5598template <size_t I, class... T>
99 const typename tuple_element<I, tuple<T...>>::type&&
100 get(const tuple<T...>&&) noexcept; // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16101
Marshall Clowe8029e52013-07-13 02:54:05102template <class T1, class... T>
103 constexpr T1& get(tuple<T...>&) noexcept; // C++14
104template <class T1, class... T>
Marshall Clowa6607572015-11-19 19:45:29105 constexpr const T1& get(const tuple<T...>&) noexcept; // C++14
Marshall Clowe8029e52013-07-13 02:54:05106template <class T1, class... T>
107 constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
Eric Fiselier199bee02015-12-18 00:36:55108template <class T1, class... T>
109 constexpr const T1&& get(const tuple<T...>&&) noexcept; // C++14
Marshall Clowe8029e52013-07-13 02:54:05110
Howard Hinnantbc8d3f92010-05-11 19:42:16111// 20.4.1.6, relational operators:
Marshall Clowda0a0e82013-07-22 16:02:19112template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
113template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
114template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
115template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
116template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
117template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16118
119template <class... Types, class Alloc>
120 struct uses_allocator<tuple<Types...>, Alloc>;
121
122template <class... Types>
Howard Hinnanta5e01212011-05-27 19:08:18123 void
124 swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:16125
Howard Hinnantbc8d3f92010-05-11 19:42:16126} // std
127
128*/
129
130#include <__config>
131#include <__tuple>
132#include <cstddef>
Howard Hinnantbc8d3f92010-05-11 19:42:16133#include <type_traits>
Howard Hinnant6cc99fa2011-12-19 17:58:44134#include <__functional_base>
135#include <utility>
Howard Hinnantbc8d3f92010-05-11 19:42:16136
Howard Hinnant08e17472011-10-17 20:05:10137#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16138#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10139#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16140
141_LIBCPP_BEGIN_NAMESPACE_STD
142
143#ifndef _LIBCPP_HAS_NO_VARIADICS
144
145// tuple_size
146
147template <class ..._Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34148class _LIBCPP_TYPE_VIS_ONLY tuple_size<tuple<_Tp...> >
Howard Hinnantbc8d3f92010-05-11 19:42:16149 : public integral_constant<size_t, sizeof...(_Tp)>
150{
151};
152
Howard Hinnantbc8d3f92010-05-11 19:42:16153// tuple_element
154
155template <size_t _Ip, class ..._Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34156class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> >
Howard Hinnantbc8d3f92010-05-11 19:42:16157{
158public:
Howard Hinnantf83417b2011-01-24 16:07:25159 typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16160};
161
Marshall Clow50fe0c72014-03-03 06:18:11162#if _LIBCPP_STD_VER > 11
163template <size_t _Ip, class ..._Tp>
164using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
165#endif
166
Howard Hinnantbc8d3f92010-05-11 19:42:16167// __tuple_leaf
168
Eric Fiselier3a0e4302015-06-13 07:08:02169template <size_t _Ip, class _Hp,
170 bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
Howard Hinnantd4cf2152011-12-11 20:31:33171 >
Howard Hinnantbc8d3f92010-05-11 19:42:16172class __tuple_leaf;
173
174template <size_t _Ip, class _Hp, bool _Ep>
Howard Hinnantee6ccd02010-09-23 18:58:28175inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16176void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
Howard Hinnanta5e01212011-05-27 19:08:18177 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16178{
179 swap(__x.get(), __y.get());
180}
181
182template <size_t _Ip, class _Hp, bool>
183class __tuple_leaf
184{
185 _Hp value;
186
187 __tuple_leaf& operator=(const __tuple_leaf&);
188public:
Howard Hinnant4eebfc32012-07-06 20:50:27189 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
190 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value()
Howard Hinnantbc8d3f92010-05-11 19:42:16191 {static_assert(!is_reference<_Hp>::value,
192 "Attempted to default construct a reference element in a tuple");}
193
194 template <class _Alloc>
195 _LIBCPP_INLINE_VISIBILITY
196 __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
197 : value()
198 {static_assert(!is_reference<_Hp>::value,
199 "Attempted to default construct a reference element in a tuple");}
200
201 template <class _Alloc>
202 _LIBCPP_INLINE_VISIBILITY
203 __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
204 : value(allocator_arg_t(), __a)
205 {static_assert(!is_reference<_Hp>::value,
206 "Attempted to default construct a reference element in a tuple");}
207
208 template <class _Alloc>
209 _LIBCPP_INLINE_VISIBILITY
210 __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
211 : value(__a)
212 {static_assert(!is_reference<_Hp>::value,
213 "Attempted to default construct a reference element in a tuple");}
214
Howard Hinnante049cc52010-09-27 17:54:17215 template <class _Tp,
Eric Fiselier9020c082014-07-24 18:48:34216 class = typename enable_if<
217 __lazy_and<
218 __lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
219 , is_constructible<_Hp, _Tp>
220 >::value
221 >::type
222 >
Marshall Clowda0a0e82013-07-22 16:02:19223 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48224 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
Howard Hinnant0949eed2011-06-30 21:18:19225 : value(_VSTD::forward<_Tp>(__t))
Howard Hinnante049cc52010-09-27 17:54:17226 {static_assert(!is_reference<_Hp>::value ||
Howard Hinnantec3773c2011-12-01 20:21:04227 (is_lvalue_reference<_Hp>::value &&
Howard Hinnantbc8d3f92010-05-11 19:42:16228 (is_lvalue_reference<_Tp>::value ||
229 is_same<typename remove_reference<_Tp>::type,
230 reference_wrapper<
231 typename remove_reference<_Hp>::type
232 >
Howard Hinnantec3773c2011-12-01 20:21:04233 >::value)) ||
Howard Hinnante049cc52010-09-27 17:54:17234 (is_rvalue_reference<_Hp>::value &&
235 !is_lvalue_reference<_Tp>::value),
Howard Hinnantbc8d3f92010-05-11 19:42:16236 "Attempted to construct a reference element in a tuple with an rvalue");}
237
238 template <class _Tp, class _Alloc>
239 _LIBCPP_INLINE_VISIBILITY
240 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19241 : value(_VSTD::forward<_Tp>(__t))
Howard Hinnantbc8d3f92010-05-11 19:42:16242 {static_assert(!is_lvalue_reference<_Hp>::value ||
Howard Hinnantec3773c2011-12-01 20:21:04243 (is_lvalue_reference<_Hp>::value &&
Howard Hinnantbc8d3f92010-05-11 19:42:16244 (is_lvalue_reference<_Tp>::value ||
245 is_same<typename remove_reference<_Tp>::type,
246 reference_wrapper<
247 typename remove_reference<_Hp>::type
248 >
Howard Hinnantec3773c2011-12-01 20:21:04249 >::value)),
Howard Hinnantbc8d3f92010-05-11 19:42:16250 "Attempted to construct a reference element in a tuple with an rvalue");}
251
252 template <class _Tp, class _Alloc>
253 _LIBCPP_INLINE_VISIBILITY
254 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19255 : value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
Howard Hinnantbc8d3f92010-05-11 19:42:16256 {static_assert(!is_lvalue_reference<_Hp>::value ||
Howard Hinnantec3773c2011-12-01 20:21:04257 (is_lvalue_reference<_Hp>::value &&
Howard Hinnantbc8d3f92010-05-11 19:42:16258 (is_lvalue_reference<_Tp>::value ||
259 is_same<typename remove_reference<_Tp>::type,
260 reference_wrapper<
261 typename remove_reference<_Hp>::type
262 >
Howard Hinnantec3773c2011-12-01 20:21:04263 >::value)),
Howard Hinnantbc8d3f92010-05-11 19:42:16264 "Attempted to construct a reference element in a tuple with an rvalue");}
265
266 template <class _Tp, class _Alloc>
267 _LIBCPP_INLINE_VISIBILITY
268 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19269 : value(_VSTD::forward<_Tp>(__t), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16270 {static_assert(!is_lvalue_reference<_Hp>::value ||
Howard Hinnantec3773c2011-12-01 20:21:04271 (is_lvalue_reference<_Hp>::value &&
Howard Hinnantbc8d3f92010-05-11 19:42:16272 (is_lvalue_reference<_Tp>::value ||
273 is_same<typename remove_reference<_Tp>::type,
274 reference_wrapper<
275 typename remove_reference<_Hp>::type
276 >
Howard Hinnantec3773c2011-12-01 20:21:04277 >::value)),
Howard Hinnantbc8d3f92010-05-11 19:42:16278 "Attempted to construct a reference element in a tuple with an rvalue");}
279
Marshall Clow398c9d82014-04-21 23:48:09280 __tuple_leaf(const __tuple_leaf& __t) = default;
281 __tuple_leaf(__tuple_leaf&& __t) = default;
Howard Hinnantbc8d3f92010-05-11 19:42:16282
283 template <class _Tp>
284 _LIBCPP_INLINE_VISIBILITY
285 __tuple_leaf&
Howard Hinnant74f26f22012-07-06 21:53:48286 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16287 {
Howard Hinnant0949eed2011-06-30 21:18:19288 value = _VSTD::forward<_Tp>(__t);
Howard Hinnantbc8d3f92010-05-11 19:42:16289 return *this;
290 }
291
292 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18293 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16294 {
Howard Hinnant0949eed2011-06-30 21:18:19295 _VSTD::swap(*this, __t);
Howard Hinnantbc8d3f92010-05-11 19:42:16296 return 0;
297 }
298
Marshall Clowda0a0e82013-07-22 16:02:19299 _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:16301};
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:27310 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
311 _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16312
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:17327 template <class _Tp,
Eric Fiselier9020c082014-07-24 18:48:34328 class = typename enable_if<
329 __lazy_and<
330 __lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
331 , is_constructible<_Hp, _Tp>
332 >::value
333 >::type
334 >
Marshall Clowda0a0e82013-07-22 16:02:19335 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48336 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
Howard Hinnant0949eed2011-06-30 21:18:19337 : _Hp(_VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16338
339 template <class _Tp, class _Alloc>
340 _LIBCPP_INLINE_VISIBILITY
341 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19342 : _Hp(_VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16343
344 template <class _Tp, class _Alloc>
345 _LIBCPP_INLINE_VISIBILITY
346 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19347 : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16348
349 template <class _Tp, class _Alloc>
350 _LIBCPP_INLINE_VISIBILITY
351 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19352 : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16353
Eric Fiselier9020c082014-07-24 18:48:34354 __tuple_leaf(__tuple_leaf const &) = default;
355 __tuple_leaf(__tuple_leaf &&) = default;
356
Howard Hinnantbc8d3f92010-05-11 19:42:16357 template <class _Tp>
358 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16359 __tuple_leaf&
Howard Hinnant74f26f22012-07-06 21:53:48360 operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16361 {
Howard Hinnant0949eed2011-06-30 21:18:19362 _Hp::operator=(_VSTD::forward<_Tp>(__t));
Howard Hinnantbc8d3f92010-05-11 19:42:16363 return *this;
364 }
365
Howard Hinnanta5e01212011-05-27 19:08:18366 _LIBCPP_INLINE_VISIBILITY
367 int
368 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16369 {
Howard Hinnant0949eed2011-06-30 21:18:19370 _VSTD::swap(*this, __t);
Howard Hinnantbc8d3f92010-05-11 19:42:16371 return 0;
372 }
373
Marshall Clowda0a0e82013-07-22 16:02:19374 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
375 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
Howard Hinnantbc8d3f92010-05-11 19:42:16376};
377
Howard Hinnantee6ccd02010-09-23 18:58:28378template <class ..._Tp>
379_LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48380void __swallow(_Tp&&...) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16381
Eric Fiselier6cb69ff2014-11-25 21:57:41382template <bool ..._Pred>
Marshall Clowbbc7c742014-10-15 10:33:02383struct __all
Eric Fiselier6cb69ff2014-11-25 21:57:41384 : is_same<__all<_Pred...>, __all<(_Pred, true)...>>
Marshall Clowbbc7c742014-10-15 10:33:02385{ };
Howard Hinnanta5e01212011-05-27 19:08:18386
Eric Fiselier55ad3ac2016-04-15 03:29:40387template <class ..._Tp>
388struct __lazy_all : __all<_Tp::value...> {};
389
Marshall Clowbbc7c742014-10-15 10:33:02390template <class _Tp>
391struct __all_default_constructible;
Howard Hinnanta5e01212011-05-27 19:08:18392
Marshall Clowbbc7c742014-10-15 10:33:02393template <class ..._Tp>
394struct __all_default_constructible<__tuple_types<_Tp...>>
395 : __all<is_default_constructible<_Tp>::value...>
396{ };
Howard Hinnanta5e01212011-05-27 19:08:18397
Howard Hinnantbc8d3f92010-05-11 19:42:16398// __tuple_impl
399
400template<class _Indx, class ..._Tp> struct __tuple_impl;
401
402template<size_t ..._Indx, class ..._Tp>
403struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
404 : public __tuple_leaf<_Indx, _Tp>...
405{
Howard Hinnant5394c1e2012-07-06 20:39:45406 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27407 _LIBCPP_CONSTEXPR __tuple_impl()
408 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
Howard Hinnant5394c1e2012-07-06 20:39:45409
Howard Hinnantbc8d3f92010-05-11 19:42:16410 template <size_t ..._Uf, class ..._Tf,
411 size_t ..._Ul, class ..._Tl, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19412 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16413 explicit
414 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
415 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
Howard Hinnant74f26f22012-07-06 21:53:48416 _Up&&... __u)
417 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
418 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
Howard Hinnant0949eed2011-06-30 21:18:19419 __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
Howard Hinnantbc8d3f92010-05-11 19:42:16420 __tuple_leaf<_Ul, _Tl>()...
421 {}
422
423 template <class _Alloc, size_t ..._Uf, class ..._Tf,
424 size_t ..._Ul, class ..._Tl, class ..._Up>
Howard Hinnantee6ccd02010-09-23 18:58:28425 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16426 explicit
427 __tuple_impl(allocator_arg_t, const _Alloc& __a,
428 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
429 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
430 _Up&&... __u) :
431 __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
Howard Hinnant0949eed2011-06-30 21:18:19432 _VSTD::forward<_Up>(__u))...,
Howard Hinnantbc8d3f92010-05-11 19:42:16433 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
434 {}
435
436 template <class _Tuple,
437 class = typename enable_if
438 <
Howard Hinnant99324892013-04-14 00:01:13439 __tuple_constructible<_Tuple, tuple<_Tp...> >::value
Howard Hinnantbc8d3f92010-05-11 19:42:16440 >::type
441 >
Marshall Clowda0a0e82013-07-22 16:02:19442 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48443 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
444 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
Howard Hinnant0949eed2011-06-30 21:18:19445 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
446 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
Howard Hinnantbc8d3f92010-05-11 19:42:16447 {}
448
449 template <class _Alloc, class _Tuple,
450 class = typename enable_if
451 <
Howard Hinnantf83417b2011-01-24 16:07:25452 __tuple_convertible<_Tuple, tuple<_Tp...> >::value
Howard Hinnantbc8d3f92010-05-11 19:42:16453 >::type
454 >
Howard Hinnantee6ccd02010-09-23 18:58:28455 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16456 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
457 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
Howard Hinnant324bb032010-08-22 00:02:43458 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
Howard Hinnant0949eed2011-06-30 21:18:19459 _VSTD::forward<typename tuple_element<_Indx,
460 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
Howard Hinnantbc8d3f92010-05-11 19:42:16461 {}
462
463 template <class _Tuple>
Howard Hinnantee6ccd02010-09-23 18:58:28464 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16465 typename enable_if
466 <
Howard Hinnantf83417b2011-01-24 16:07:25467 __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
Howard Hinnantbc8d3f92010-05-11 19:42:16468 __tuple_impl&
469 >::type
Howard Hinnant74f26f22012-07-06 21:53:48470 operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
471 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16472 {
Howard Hinnant0949eed2011-06-30 21:18:19473 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
474 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
Howard Hinnantbc8d3f92010-05-11 19:42:16475 return *this;
476 }
477
Howard Hinnant3de50862013-11-06 17:45:43478 __tuple_impl(const __tuple_impl&) = default;
479 __tuple_impl(__tuple_impl&&) = default;
480
481 _LIBCPP_INLINE_VISIBILITY
482 __tuple_impl&
483 operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
484 {
485 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
486 return *this;
487 }
488
489 _LIBCPP_INLINE_VISIBILITY
490 __tuple_impl&
491 operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
492 {
493 __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
494 return *this;
495 }
Howard Hinnant28484442012-02-15 20:13:52496
Howard Hinnantee6ccd02010-09-23 18:58:28497 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16498 void swap(__tuple_impl& __t)
Howard Hinnanta5e01212011-05-27 19:08:18499 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16500 {
501 __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
502 }
503};
504
505template <class ..._Tp>
Howard Hinnant0f678bd2013-08-12 18:38:34506class _LIBCPP_TYPE_VIS_ONLY tuple
Howard Hinnantbc8d3f92010-05-11 19:42:16507{
508 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
509
510 base base_;
511
Marshall Clow8fc4f5a2013-07-17 18:25:36512 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04513 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
Marshall Clow8fc4f5a2013-07-17 18:25:36514 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04515 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
Marshall Clow8fc4f5a2013-07-17 18:25:36516 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantec3773c2011-12-01 20:21:04517 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
Eric Fiselier199bee02015-12-18 00:36:55518 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
519 const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16520public:
521
Eric Fiselierda1818a2015-02-21 02:30:41522 template <bool _Dummy = true, class = typename enable_if<
523 __all<__dependent_type<is_default_constructible<_Tp>, _Dummy>::value...>::value
Marshall Clowbbc7c742014-10-15 10:33:02524 >::type>
Howard Hinnantee6ccd02010-09-23 18:58:28525 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27526 _LIBCPP_CONSTEXPR tuple()
527 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
Howard Hinnant5394c1e2012-07-06 20:39:45528
Eric Fiselier55ad3ac2016-04-15 03:29:40529 template <class _AllocArgT, class _Alloc, bool _Dummy = true, class = typename enable_if<
530 __lazy_and<
531 is_base_of<allocator_arg_t, _AllocArgT>,
532 __lazy_all<__dependent_type<is_default_constructible<_Tp>, _Dummy>...>
533 >::value
534 >::type>
535 _LIBCPP_INLINE_VISIBILITY
536 tuple(_AllocArgT, _Alloc const& __a)
537 : base_(allocator_arg_t(), __a,
538 __tuple_indices<>(), __tuple_types<>(),
539 typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
540 __tuple_types<_Tp...>()) {}
541
Marshall Clowda0a0e82013-07-22 16:02:19542 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48543 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16544 : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
545 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
546 typename __make_tuple_indices<0>::type(),
547 typename __make_tuple_types<tuple, 0>::type(),
548 __t...
549 ) {}
550
551 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28552 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16553 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
554 : base_(allocator_arg_t(), __a,
555 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
556 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
557 typename __make_tuple_indices<0>::type(),
558 typename __make_tuple_types<tuple, 0>::type(),
559 __t...
560 ) {}
561
562 template <class ..._Up,
Howard Hinnantdc1345f2012-04-01 23:10:42563 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16564 <
565 sizeof...(_Up) <= sizeof...(_Tp) &&
566 __tuple_convertible
567 <
568 tuple<_Up...>,
569 typename __make_tuple_types<tuple,
570 sizeof...(_Up) < sizeof...(_Tp) ?
571 sizeof...(_Up) :
572 sizeof...(_Tp)>::type
Marshall Clowbbc7c742014-10-15 10:33:02573 >::value &&
574 __all_default_constructible<
575 typename __make_tuple_types<tuple, sizeof...(_Tp),
576 sizeof...(_Up) < sizeof...(_Tp) ?
577 sizeof...(_Up) :
578 sizeof...(_Tp)>::type
Howard Hinnantdc1345f2012-04-01 23:10:42579 >::value,
580 bool
581 >::type = false
582 >
Marshall Clowda0a0e82013-07-22 16:02:19583 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantdc1345f2012-04-01 23:10:42584 tuple(_Up&&... __u)
Howard Hinnant74f26f22012-07-06 21:53:48585 _NOEXCEPT_((
Marshall Clow86d311c2014-09-16 17:08:21586 is_nothrow_constructible<base,
Howard Hinnant74f26f22012-07-06 21:53:48587 typename __make_tuple_indices<sizeof...(_Up)>::type,
588 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
589 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
590 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
Marshall Clow86d311c2014-09-16 17:08:21591 _Up...
Howard Hinnant74f26f22012-07-06 21:53:48592 >::value
593 ))
Howard Hinnantdc1345f2012-04-01 23:10:42594 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
595 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
596 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
597 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
598 _VSTD::forward<_Up>(__u)...) {}
599
600 template <class ..._Up,
601 typename enable_if
602 <
603 sizeof...(_Up) <= sizeof...(_Tp) &&
604 __tuple_constructible
605 <
606 tuple<_Up...>,
607 typename __make_tuple_types<tuple,
608 sizeof...(_Up) < sizeof...(_Tp) ?
609 sizeof...(_Up) :
610 sizeof...(_Tp)>::type
611 >::value &&
612 !__tuple_convertible
613 <
614 tuple<_Up...>,
615 typename __make_tuple_types<tuple,
616 sizeof...(_Up) < sizeof...(_Tp) ?
617 sizeof...(_Up) :
618 sizeof...(_Tp)>::type
Marshall Clowbbc7c742014-10-15 10:33:02619 >::value &&
620 __all_default_constructible<
621 typename __make_tuple_types<tuple, sizeof...(_Tp),
622 sizeof...(_Up) < sizeof...(_Tp) ?
623 sizeof...(_Up) :
624 sizeof...(_Tp)>::type
Howard Hinnantdc1345f2012-04-01 23:10:42625 >::value,
626 bool
627 >::type =false
Howard Hinnantbc8d3f92010-05-11 19:42:16628 >
Marshall Clowda0a0e82013-07-22 16:02:19629 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16630 explicit
631 tuple(_Up&&... __u)
Howard Hinnant74f26f22012-07-06 21:53:48632 _NOEXCEPT_((
Marshall Clow86d311c2014-09-16 17:08:21633 is_nothrow_constructible<base,
Howard Hinnant74f26f22012-07-06 21:53:48634 typename __make_tuple_indices<sizeof...(_Up)>::type,
635 typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
636 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
637 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
638 _Up...
639 >::value
640 ))
Howard Hinnantbc8d3f92010-05-11 19:42:16641 : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
642 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
643 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
644 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
Howard Hinnant0949eed2011-06-30 21:18:19645 _VSTD::forward<_Up>(__u)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16646
647 template <class _Alloc, class ..._Up,
648 class = typename enable_if
649 <
Eric Fiselier55ad3ac2016-04-15 03:29:40650 sizeof...(_Up) == sizeof...(_Tp) &&
651 __tuple_convertible<tuple<_Up...>, tuple>::value
Howard Hinnantbc8d3f92010-05-11 19:42:16652 >::type
653 >
Howard Hinnantee6ccd02010-09-23 18:58:28654 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16655 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
656 : base_(allocator_arg_t(), __a,
657 typename __make_tuple_indices<sizeof...(_Up)>::type(),
658 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
659 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
660 typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
Howard Hinnant0949eed2011-06-30 21:18:19661 _VSTD::forward<_Up>(__u)...) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16662
663 template <class _Tuple,
Howard Hinnantdc1345f2012-04-01 23:10:42664 typename enable_if
Howard Hinnantbc8d3f92010-05-11 19:42:16665 <
Howard Hinnantdc1345f2012-04-01 23:10:42666 __tuple_convertible<_Tuple, tuple>::value,
667 bool
668 >::type = false
Howard Hinnantbc8d3f92010-05-11 19:42:16669 >
Marshall Clowda0a0e82013-07-22 16:02:19670 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant74f26f22012-07-06 21:53:48671 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
Howard Hinnant0949eed2011-06-30 21:18:19672 : base_(_VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16673
Howard Hinnantdc1345f2012-04-01 23:10:42674 template <class _Tuple,
675 typename enable_if
676 <
677 __tuple_constructible<_Tuple, tuple>::value &&
678 !__tuple_convertible<_Tuple, tuple>::value,
679 bool
680 >::type = false
681 >
Marshall Clowda0a0e82013-07-22 16:02:19682 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantdc1345f2012-04-01 23:10:42683 explicit
Howard Hinnant74f26f22012-07-06 21:53:48684 tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
Howard Hinnantdc1345f2012-04-01 23:10:42685 : base_(_VSTD::forward<_Tuple>(__t)) {}
686
Howard Hinnantbc8d3f92010-05-11 19:42:16687 template <class _Alloc, class _Tuple,
688 class = typename enable_if
689 <
690 __tuple_convertible<_Tuple, tuple>::value
691 >::type
692 >
Howard Hinnantee6ccd02010-09-23 18:58:28693 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16694 tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
Howard Hinnant0949eed2011-06-30 21:18:19695 : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16696
697 template <class _Tuple,
698 class = typename enable_if
699 <
700 __tuple_assignable<_Tuple, tuple>::value
701 >::type
702 >
Howard Hinnantee6ccd02010-09-23 18:58:28703 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16704 tuple&
Howard Hinnant74f26f22012-07-06 21:53:48705 operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value))
Howard Hinnantbc8d3f92010-05-11 19:42:16706 {
Howard Hinnant0949eed2011-06-30 21:18:19707 base_.operator=(_VSTD::forward<_Tuple>(__t));
Howard Hinnantbc8d3f92010-05-11 19:42:16708 return *this;
709 }
710
Howard Hinnantee6ccd02010-09-23 18:58:28711 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18712 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
713 {base_.swap(__t.base_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16714};
715
716template <>
Howard Hinnant0f678bd2013-08-12 18:38:34717class _LIBCPP_TYPE_VIS_ONLY tuple<>
Howard Hinnantbc8d3f92010-05-11 19:42:16718{
719public:
Howard Hinnantee6ccd02010-09-23 18:58:28720 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant4eebfc32012-07-06 20:50:27721 _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16722 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28723 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48724 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16725 template <class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28726 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48727 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
Howard Hinnant99968442011-11-29 18:15:50728 template <class _Up>
Howard Hinnantee6ccd02010-09-23 18:58:28729 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48730 tuple(array<_Up, 0>) _NOEXCEPT {}
Howard Hinnant99968442011-11-29 18:15:50731 template <class _Alloc, class _Up>
Howard Hinnantee6ccd02010-09-23 18:58:28732 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant74f26f22012-07-06 21:53:48733 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
Howard Hinnantee6ccd02010-09-23 18:58:28734 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanta5e01212011-05-27 19:08:18735 void swap(tuple&) _NOEXCEPT {}
Howard Hinnantbc8d3f92010-05-11 19:42:16736};
737
738template <class ..._Tp>
739inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantaabf2872011-06-01 19:59:32740typename enable_if
741<
742 __all<__is_swappable<_Tp>::value...>::value,
743 void
744>::type
Howard Hinnanta5e01212011-05-27 19:08:18745swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
746 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
747 {__t.swap(__u);}
Howard Hinnantbc8d3f92010-05-11 19:42:16748
749// get
750
751template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36752inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25753typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnantec3773c2011-12-01 20:21:04754get(tuple<_Tp...>& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16755{
Howard Hinnantf83417b2011-01-24 16:07:25756 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16757 return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get();
758}
759
760template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36761inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25762const typename tuple_element<_Ip, tuple<_Tp...> >::type&
Howard Hinnantec3773c2011-12-01 20:21:04763get(const tuple<_Tp...>& __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16764{
Howard Hinnantf83417b2011-01-24 16:07:25765 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16766 return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
767}
768
Howard Hinnantcd2254b2010-11-17 19:52:17769template <size_t _Ip, class ..._Tp>
Marshall Clow8fc4f5a2013-07-17 18:25:36770inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantf83417b2011-01-24 16:07:25771typename tuple_element<_Ip, tuple<_Tp...> >::type&&
Howard Hinnantec3773c2011-12-01 20:21:04772get(tuple<_Tp...>&& __t) _NOEXCEPT
Howard Hinnantcd2254b2010-11-17 19:52:17773{
Howard Hinnantf83417b2011-01-24 16:07:25774 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
Howard Hinnant56a85ca2011-01-25 16:31:30775 return static_cast<type&&>(
Douglas Gregor6c669942011-01-25 16:14:21776 static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
Howard Hinnantcd2254b2010-11-17 19:52:17777}
778
Eric Fiselier199bee02015-12-18 00:36:55779template <size_t _Ip, class ..._Tp>
780inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
781const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
782get(const tuple<_Tp...>&& __t) _NOEXCEPT
783{
784 typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
785 return static_cast<const type&&>(
786 static_cast<const __tuple_leaf<_Ip, type>&&>(__t.base_).get());
787}
788
Marshall Clowe8029e52013-07-13 02:54:05789#if _LIBCPP_STD_VER > 11
790// get by type
791template <typename _T1, size_t _Idx, typename... _Args>
792struct __find_exactly_one_t_helper;
793
794// -- find exactly one
795template <typename _T1, size_t _Idx, typename... _Args>
796struct __find_exactly_one_t_checker {
797 static constexpr size_t value = _Idx;
798// Check the rest of the list to make sure there's only one
799 static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" );
800 };
801
802
803template <typename _T1, size_t _Idx>
804struct __find_exactly_one_t_helper <_T1, _Idx> {
805 static constexpr size_t value = -1;
806 };
807
808template <typename _T1, size_t _Idx, typename _Head, typename... _Args>
809struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> {
810 static constexpr size_t value =
811 std::conditional<
812 std::is_same<_T1, _Head>::value,
Marshall Clow19e78622013-10-01 13:28:20813 __find_exactly_one_t_checker<_T1, _Idx, _Args...>,
Marshall Clowe8029e52013-07-13 02:54:05814 __find_exactly_one_t_helper <_T1, _Idx+1, _Args...>
815 >::type::value;
816 };
817
818template <typename _T1, typename... _Args>
819struct __find_exactly_one_t {
820 static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value;
821 static_assert ( value != -1, "type not found in type list" );
822 };
823
824template <class _T1, class... _Args>
825inline _LIBCPP_INLINE_VISIBILITY
826constexpr _T1& get(tuple<_Args...>& __tup) noexcept
827{
828 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
829}
830
831template <class _T1, class... _Args>
832inline _LIBCPP_INLINE_VISIBILITY
833constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
834{
835 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
836}
837
838template <class _T1, class... _Args>
839inline _LIBCPP_INLINE_VISIBILITY
840constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
841{
Marshall Clow01a0e902013-07-15 20:46:11842 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
Marshall Clowe8029e52013-07-13 02:54:05843}
844
Eric Fiselier199bee02015-12-18 00:36:55845template <class _T1, class... _Args>
846inline _LIBCPP_INLINE_VISIBILITY
847constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
848{
849 return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
850}
851
Marshall Clowe8029e52013-07-13 02:54:05852#endif
853
Howard Hinnantbc8d3f92010-05-11 19:42:16854// tie
855
856template <class ..._Tp>
Marshall Clow8e554d92014-02-25 16:11:46857inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16858tuple<_Tp&...>
Howard Hinnant74f26f22012-07-06 21:53:48859tie(_Tp&... __t) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16860{
861 return tuple<_Tp&...>(__t...);
862}
863
864template <class _Up>
865struct __ignore_t
866{
Howard Hinnantbc8d3f92010-05-11 19:42:16867 template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28868 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16869 const __ignore_t& operator=(_Tp&&) const {return *this;}
870};
871
872namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
873
Howard Hinnantbc8d3f92010-05-11 19:42:16874template <class _Tp>
Marshall Clowa71f9562014-01-03 22:55:49875struct __make_tuple_return_impl
Howard Hinnantbc8d3f92010-05-11 19:42:16876{
877 typedef _Tp type;
878};
879
880template <class _Tp>
Marshall Clowa71f9562014-01-03 22:55:49881struct __make_tuple_return_impl<reference_wrapper<_Tp> >
Howard Hinnantbc8d3f92010-05-11 19:42:16882{
883 typedef _Tp& type;
884};
885
886template <class _Tp>
887struct __make_tuple_return
888{
Marshall Clowa71f9562014-01-03 22:55:49889 typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
Howard Hinnantbc8d3f92010-05-11 19:42:16890};
891
892template <class... _Tp>
Marshall Clowda0a0e82013-07-22 16:02:19893inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16894tuple<typename __make_tuple_return<_Tp>::type...>
895make_tuple(_Tp&&... __t)
896{
Howard Hinnant0949eed2011-06-30 21:18:19897 return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnantbc8d3f92010-05-11 19:42:16898}
899
Howard Hinnant3c1ffba2010-08-19 18:59:38900template <class... _Tp>
Marshall Clowda0a0e82013-07-22 16:02:19901inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
902tuple<_Tp&&...>
Howard Hinnant74f26f22012-07-06 21:53:48903forward_as_tuple(_Tp&&... __t) _NOEXCEPT
Howard Hinnant3c1ffba2010-08-19 18:59:38904{
Howard Hinnant0949eed2011-06-30 21:18:19905 return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
Howard Hinnant3c1ffba2010-08-19 18:59:38906}
907
Howard Hinnant99968442011-11-29 18:15:50908template <size_t _Ip>
Howard Hinnantbc8d3f92010-05-11 19:42:16909struct __tuple_equal
910{
911 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19912 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16913 bool operator()(const _Tp& __x, const _Up& __y)
914 {
Marshall Clowba6dbf42014-06-24 00:46:19915 return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
Howard Hinnantbc8d3f92010-05-11 19:42:16916 }
917};
918
919template <>
920struct __tuple_equal<0>
921{
922 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19923 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16924 bool operator()(const _Tp&, const _Up&)
925 {
926 return true;
927 }
928};
929
930template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19931inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16932bool
933operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
934{
935 return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
936}
937
938template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19939inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16940bool
941operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
942{
943 return !(__x == __y);
944}
945
Howard Hinnant99968442011-11-29 18:15:50946template <size_t _Ip>
Howard Hinnantbc8d3f92010-05-11 19:42:16947struct __tuple_less
948{
949 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19950 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16951 bool operator()(const _Tp& __x, const _Up& __y)
952 {
Duncan P. N. Exon Smith07b133f2015-01-21 02:51:17953 const size_t __idx = tuple_size<_Tp>::value - _Ip;
954 if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
955 return true;
956 if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
957 return false;
958 return __tuple_less<_Ip-1>()(__x, __y);
Howard Hinnantbc8d3f92010-05-11 19:42:16959 }
960};
961
962template <>
963struct __tuple_less<0>
964{
965 template <class _Tp, class _Up>
Marshall Clowda0a0e82013-07-22 16:02:19966 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16967 bool operator()(const _Tp&, const _Up&)
968 {
969 return false;
970 }
971};
972
973template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19974inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16975bool
976operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
977{
978 return __tuple_less<sizeof...(_Tp)>()(__x, __y);
979}
980
981template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19982inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16983bool
984operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
985{
986 return __y < __x;
987}
988
989template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19990inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16991bool
992operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
993{
994 return !(__x < __y);
995}
996
997template <class ..._Tp, class ..._Up>
Marshall Clowda0a0e82013-07-22 16:02:19998inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnantbc8d3f92010-05-11 19:42:16999bool
1000operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1001{
1002 return !(__y < __x);
1003}
1004
1005// tuple_cat
1006
Howard Hinnant0e1493e2010-12-11 20:47:501007template <class _Tp, class _Up> struct __tuple_cat_type;
1008
1009template <class ..._Ttypes, class ..._Utypes>
Howard Hinnantf83417b2011-01-24 16:07:251010struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
Howard Hinnantbc8d3f92010-05-11 19:42:161011{
Howard Hinnant0e1493e2010-12-11 20:47:501012 typedef tuple<_Ttypes..., _Utypes...> type;
1013};
1014
1015template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
1016struct __tuple_cat_return_1
1017{
1018};
1019
1020template <class ..._Types, class _Tuple0>
1021struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
1022{
1023 typedef typename __tuple_cat_type<tuple<_Types...>,
1024 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
1025 type;
1026};
1027
1028template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
1029struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
1030 : public __tuple_cat_return_1<
1031 typename __tuple_cat_type<
1032 tuple<_Types...>,
1033 typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
1034 >::type,
1035 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
1036 _Tuple1, _Tuples...>
1037{
1038};
1039
1040template <class ..._Tuples> struct __tuple_cat_return;
1041
1042template <class _Tuple0, class ..._Tuples>
1043struct __tuple_cat_return<_Tuple0, _Tuples...>
1044 : public __tuple_cat_return_1<tuple<>,
1045 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
1046 _Tuples...>
1047{
1048};
1049
1050template <>
1051struct __tuple_cat_return<>
1052{
1053 typedef tuple<> type;
1054};
1055
Marshall Clowda0a0e82013-07-22 16:02:191056inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnant0e1493e2010-12-11 20:47:501057tuple<>
1058tuple_cat()
1059{
1060 return tuple<>();
Howard Hinnantbc8d3f92010-05-11 19:42:161061}
1062
Howard Hinnant99968442011-11-29 18:15:501063template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
Howard Hinnante48e3662010-12-12 23:04:371064struct __tuple_cat_return_ref_imp;
Howard Hinnantbc8d3f92010-05-11 19:42:161065
Howard Hinnante48e3662010-12-12 23:04:371066template <class ..._Types, size_t ..._I0, class _Tuple0>
1067struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
Howard Hinnantbc8d3f92010-05-11 19:42:161068{
Howard Hinnant0e1493e2010-12-11 20:47:501069 typedef typename remove_reference<_Tuple0>::type _T0;
Howard Hinnante48e3662010-12-12 23:04:371070 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1071 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1072};
Howard Hinnantbc8d3f92010-05-11 19:42:161073
Howard Hinnante48e3662010-12-12 23:04:371074template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1075struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1076 _Tuple0, _Tuple1, _Tuples...>
1077 : public __tuple_cat_return_ref_imp<
1078 tuple<_Types..., typename __apply_cv<_Tuple0,
1079 typename tuple_element<_I0,
1080 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1081 typename __make_tuple_indices<tuple_size<typename
1082 remove_reference<_Tuple1>::type>::value>::type,
1083 _Tuple1, _Tuples...>
Howard Hinnantbc8d3f92010-05-11 19:42:161084{
Howard Hinnante48e3662010-12-12 23:04:371085};
1086
1087template <class _Tuple0, class ..._Tuples>
1088struct __tuple_cat_return_ref
1089 : public __tuple_cat_return_ref_imp<tuple<>,
1090 typename __make_tuple_indices<
1091 tuple_size<typename remove_reference<_Tuple0>::type>::value
1092 >::type, _Tuple0, _Tuples...>
1093{
1094};
1095
1096template <class _Types, class _I0, class _J0>
1097struct __tuple_cat;
1098
1099template <class ..._Types, size_t ..._I0, size_t ..._J0>
Howard Hinnantf83417b2011-01-24 16:07:251100struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
Howard Hinnante48e3662010-12-12 23:04:371101{
1102 template <class _Tuple0>
Marshall Clowda0a0e82013-07-22 16:02:191103 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:371104 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1105 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1106 {
Marshall Clowba6dbf42014-06-24 00:46:191107 return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1108 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
Howard Hinnante48e3662010-12-12 23:04:371109 }
1110
1111 template <class _Tuple0, class _Tuple1, class ..._Tuples>
Marshall Clowda0a0e82013-07-22 16:02:191112 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:371113 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1114 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1115 {
1116 typedef typename remove_reference<_Tuple0>::type _T0;
1117 typedef typename remove_reference<_Tuple1>::type _T1;
1118 return __tuple_cat<
1119 tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1120 typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1121 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
Marshall Clow1d927e32013-10-05 18:46:371122 (forward_as_tuple(
Marshall Clowba6dbf42014-06-24 00:46:191123 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1124 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
Howard Hinnante48e3662010-12-12 23:04:371125 ),
Howard Hinnant0949eed2011-06-30 21:18:191126 _VSTD::forward<_Tuple1>(__t1),
1127 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnante48e3662010-12-12 23:04:371128 }
1129};
1130
1131template <class _Tuple0, class... _Tuples>
Marshall Clowda0a0e82013-07-22 16:02:191132inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
Howard Hinnante48e3662010-12-12 23:04:371133typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1134tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1135{
1136 typedef typename remove_reference<_Tuple0>::type _T0;
1137 return __tuple_cat<tuple<>, __tuple_indices<>,
1138 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
Howard Hinnant0949eed2011-06-30 21:18:191139 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1140 _VSTD::forward<_Tuples>(__tpls)...);
Howard Hinnantbc8d3f92010-05-11 19:42:161141}
1142
1143template <class ..._Tp, class _Alloc>
Howard Hinnant0f678bd2013-08-12 18:38:341144struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc>
Howard Hinnantbc8d3f92010-05-11 19:42:161145 : true_type {};
1146
Howard Hinnantbc8d3f92010-05-11 19:42:161147template <class _T1, class _T2>
1148template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1149inline _LIBCPP_INLINE_VISIBILITY
1150pair<_T1, _T2>::pair(piecewise_construct_t,
1151 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1152 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
Marshall Clowba6dbf42014-06-24 00:46:191153 : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
1154 second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
Howard Hinnantbc8d3f92010-05-11 19:42:161155{
1156}
1157
Howard Hinnant324bb032010-08-22 00:02:431158#endif // _LIBCPP_HAS_NO_VARIADICS
Howard Hinnantbc8d3f92010-05-11 19:42:161159
1160_LIBCPP_END_NAMESPACE_STD
1161
1162#endif // _LIBCPP_TUPLE