tuple revision 234959
1227825Stheraven// -*- C++ -*-
2227825Stheraven//===--------------------------- tuple ------------------------------------===//
3227825Stheraven//
4227825Stheraven//                     The LLVM Compiler Infrastructure
5227825Stheraven//
6227825Stheraven// This file is distributed under the University of Illinois Open Source
7227825Stheraven// License. See LICENSE.TXT for details.
8227825Stheraven//
9227825Stheraven//===----------------------------------------------------------------------===//
10227825Stheraven
11227825Stheraven#ifndef _LIBCPP_TUPLE
12227825Stheraven#define _LIBCPP_TUPLE
13227825Stheraven
14227825Stheraven/*
15227825Stheraven    tuple synopsis
16227825Stheraven
17227825Stheravennamespace std
18227825Stheraven{
19227825Stheraven
20227825Stheraventemplate <class... T>
21227825Stheravenclass tuple {
22227825Stheravenpublic:
23227825Stheraven    constexpr tuple();
24227825Stheraven    explicit tuple(const T&...);
25227825Stheraven    template <class... U>
26227825Stheraven        explicit tuple(U&&...);
27227825Stheraven    tuple(const tuple&) = default;
28227825Stheraven    tuple(tuple&&) = default;
29227825Stheraven    template <class... U>
30227825Stheraven        tuple(const tuple<U...>&);
31227825Stheraven    template <class... U>
32227825Stheraven        tuple(tuple<U...>&&);
33227825Stheraven    template <class U1, class U2>
34227825Stheraven        tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2
35227825Stheraven    template <class U1, class U2>
36227825Stheraven        tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2
37227825Stheraven
38227825Stheraven    // allocator-extended constructors
39227825Stheraven    template <class Alloc>
40227825Stheraven        tuple(allocator_arg_t, const Alloc& a);
41227825Stheraven    template <class Alloc>
42227825Stheraven        tuple(allocator_arg_t, const Alloc& a, const T&...);
43227825Stheraven    template <class Alloc, class... U>
44227825Stheraven        tuple(allocator_arg_t, const Alloc& a, U&&...);
45227825Stheraven    template <class Alloc>
46227825Stheraven        tuple(allocator_arg_t, const Alloc& a, const tuple&);
47227825Stheraven    template <class Alloc>
48227825Stheraven        tuple(allocator_arg_t, const Alloc& a, tuple&&);
49227825Stheraven    template <class Alloc, class... U>
50227825Stheraven        tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
51227825Stheraven    template <class Alloc, class... U>
52227825Stheraven        tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
53227825Stheraven    template <class Alloc, class U1, class U2>
54227825Stheraven        tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
55227825Stheraven    template <class Alloc, class U1, class U2>
56227825Stheraven        tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
57227825Stheraven
58227825Stheraven    tuple& operator=(const tuple&);
59227825Stheraven    tuple&
60227825Stheraven        operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
61227825Stheraven    template <class... U>
62227825Stheraven        tuple& operator=(const tuple<U...>&);
63227825Stheraven    template <class... U>
64227825Stheraven        tuple& operator=(tuple<U...>&&);
65227825Stheraven    template <class U1, class U2>
66227825Stheraven        tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
67227825Stheraven    template <class U1, class U2>
68227825Stheraven        tuple& operator=(pair<U1, U2>&&); //iffsizeof...(T) == 2
69227825Stheraven
70227825Stheraven    void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
71227825Stheraven};
72227825Stheraven
73227825Stheravenconst unspecified ignore;
74227825Stheraven
75227825Stheraventemplate <class... T> tuple<V...>  make_tuple(T&&...);
76227825Stheraventemplate <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept;
77227825Stheraventemplate <class... T> tuple<T&...> tie(T&...) noexcept;
78227825Stheraventemplate <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls);
79227825Stheraven  
80227825Stheraven// 20.4.1.4, tuple helper classes:
81227825Stheraventemplate <class T> class tuple_size; // undefined
82227825Stheraventemplate <class... T> class tuple_size<tuple<T...>>;
83227825Stheraventemplate <intsize_t I, class T> class tuple_element; // undefined
84227825Stheraventemplate <intsize_t I, class... T> class tuple_element<I, tuple<T...>>;
85227825Stheraven
86227825Stheraven// 20.4.1.5, element access:
87227825Stheraventemplate <intsize_t I, class... T>
88227825Stheraven    typename tuple_element<I, tuple<T...>>::type&
89227825Stheraven    get(tuple<T...>&) noexcept;
90227825Stheraventemplate <intsize_t I, class... T>
91227825Stheraven    typename tuple_element<I, tuple<T...>>::type const&
92227825Stheraven    get(const tuple<T...>&) noexcept;
93227825Stheraventemplate <intsize_t I, class... T>
94227825Stheraven    typename tuple_element<I, tuple<T...>>::type&&
95227825Stheraven    get(tuple<T...>&&) noexcept;
96227825Stheraven
97227825Stheraven// 20.4.1.6, relational operators:
98227825Stheraventemplate<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&);
99227825Stheraventemplate<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&);
100227825Stheraventemplate<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&);
101227825Stheraventemplate<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&);
102227825Stheraventemplate<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&);
103227825Stheraventemplate<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&);
104227825Stheraven
105227825Stheraventemplate <class... Types, class Alloc>
106227825Stheraven  struct uses_allocator<tuple<Types...>, Alloc>;
107227825Stheraven
108227825Stheraventemplate <class... Types>
109227825Stheraven  void
110227825Stheraven  swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
111227825Stheraven
112227825Stheraven}  // std
113227825Stheraven
114227825Stheraven*/
115227825Stheraven
116227825Stheraven#include <__config>
117227825Stheraven#include <__tuple>
118227825Stheraven#include <cstddef>
119227825Stheraven#include <type_traits>
120232924Stheraven#include <__functional_base>
121232924Stheraven#include <utility>
122227825Stheraven
123227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
124227825Stheraven#pragma GCC system_header
125227825Stheraven#endif
126227825Stheraven
127227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
128227825Stheraven
129232924Stheraven// allocator_arg_t
130232924Stheraven
131232924Stheravenstruct _LIBCPP_VISIBLE allocator_arg_t { };
132232924Stheraven
133232924Stheravenextern const allocator_arg_t allocator_arg;
134232924Stheraven
135232924Stheraven// uses_allocator
136232924Stheraven
137232924Stheraventemplate <class _Tp>
138232924Stheravenstruct __has_allocator_type
139232924Stheraven{
140232924Stheravenprivate:
141232924Stheraven    struct __two {char _; char __;};
142232924Stheraven    template <class _Up> static __two __test(...);
143232924Stheraven    template <class _Up> static char __test(typename _Up::allocator_type* = 0);
144232924Stheravenpublic:
145232924Stheraven    static const bool value = sizeof(__test<_Tp>(0)) == 1;
146232924Stheraven};
147232924Stheraven
148232924Stheraventemplate <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>
149232924Stheravenstruct __uses_allocator
150232924Stheraven    : public integral_constant<bool,
151232924Stheraven        is_convertible<_Alloc, typename _Tp::allocator_type>::value>
152232924Stheraven{
153232924Stheraven};
154232924Stheraven
155232924Stheraventemplate <class _Tp, class _Alloc>
156232924Stheravenstruct __uses_allocator<_Tp, _Alloc, false>
157232924Stheraven    : public false_type
158232924Stheraven{
159232924Stheraven};
160232924Stheraven
161232924Stheraventemplate <class _Tp, class _Alloc>
162232924Stheravenstruct _LIBCPP_VISIBLE uses_allocator
163232924Stheraven    : public __uses_allocator<_Tp, _Alloc>
164232924Stheraven{
165232924Stheraven};
166232924Stheraven
167227825Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
168227825Stheraven
169232924Stheraven// uses-allocator construction
170232924Stheraven
171232924Stheraventemplate <class _Tp, class _Alloc, class ..._Args>
172232924Stheravenstruct __uses_alloc_ctor_imp
173232924Stheraven{
174232924Stheraven    static const bool __ua = uses_allocator<_Tp, _Alloc>::value;
175232924Stheraven    static const bool __ic =
176232924Stheraven        is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
177232924Stheraven    static const int value = __ua ? 2 - __ic : 0;
178232924Stheraven};
179232924Stheraven
180232924Stheraventemplate <class _Tp, class _Alloc, class ..._Args>
181232924Stheravenstruct __uses_alloc_ctor
182232924Stheraven    : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value>
183232924Stheraven    {};
184232924Stheraven
185232924Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
186232924Stheraven
187232924Stheraven#ifndef _LIBCPP_HAS_NO_VARIADICS
188232924Stheraven
189227825Stheraven// tuple_size
190227825Stheraven
191227825Stheraventemplate <class ..._Tp>
192227825Stheravenclass _LIBCPP_VISIBLE tuple_size<tuple<_Tp...> >
193227825Stheraven    : public integral_constant<size_t, sizeof...(_Tp)>
194227825Stheraven{
195227825Stheraven};
196227825Stheraven
197227825Stheraven// tuple_element
198227825Stheraven
199227825Stheraventemplate <size_t _Ip, class ..._Tp>
200227825Stheravenclass _LIBCPP_VISIBLE tuple_element<_Ip, tuple<_Tp...> >
201227825Stheraven{
202227825Stheravenpublic:
203227825Stheraven    typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
204227825Stheraven};
205227825Stheraven
206227825Stheraven// __tuple_leaf
207227825Stheraven
208232924Stheraventemplate <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
209232924Stheraven#if __has_feature(is_final)
210232924Stheraven                                 && !__is_final(_Hp)
211232924Stheraven#endif
212232924Stheraven         >
213227825Stheravenclass __tuple_leaf;
214227825Stheraven
215227825Stheraventemplate <size_t _Ip, class _Hp, bool _Ep>
216227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
217227825Stheravenvoid swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
218227825Stheraven    _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
219227825Stheraven{
220227825Stheraven    swap(__x.get(), __y.get());
221227825Stheraven}
222227825Stheraven
223227825Stheraventemplate <size_t _Ip, class _Hp, bool>
224227825Stheravenclass __tuple_leaf
225227825Stheraven{
226227825Stheraven    _Hp value;
227227825Stheraven
228227825Stheraven    __tuple_leaf& operator=(const __tuple_leaf&);
229227825Stheravenpublic:
230227825Stheraven    _LIBCPP_INLINE_VISIBILITY __tuple_leaf() : value()
231227825Stheraven       {static_assert(!is_reference<_Hp>::value,
232227825Stheraven              "Attempted to default construct a reference element in a tuple");}
233227825Stheraven
234227825Stheraven    template <class _Alloc>
235227825Stheraven        _LIBCPP_INLINE_VISIBILITY
236227825Stheraven        __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
237227825Stheraven            : value()
238227825Stheraven        {static_assert(!is_reference<_Hp>::value,
239227825Stheraven              "Attempted to default construct a reference element in a tuple");}
240227825Stheraven
241227825Stheraven    template <class _Alloc>
242227825Stheraven        _LIBCPP_INLINE_VISIBILITY
243227825Stheraven        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
244227825Stheraven            : value(allocator_arg_t(), __a)
245227825Stheraven        {static_assert(!is_reference<_Hp>::value,
246227825Stheraven              "Attempted to default construct a reference element in a tuple");}
247227825Stheraven
248227825Stheraven    template <class _Alloc>
249227825Stheraven        _LIBCPP_INLINE_VISIBILITY
250227825Stheraven        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
251227825Stheraven            : value(__a)
252227825Stheraven        {static_assert(!is_reference<_Hp>::value,
253227825Stheraven              "Attempted to default construct a reference element in a tuple");}
254227825Stheraven
255227825Stheraven    template <class _Tp,
256227825Stheraven              class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
257227825Stheraven        _LIBCPP_INLINE_VISIBILITY
258227825Stheraven        explicit __tuple_leaf(_Tp&& __t)
259227825Stheraven            : value(_VSTD::forward<_Tp>(__t))
260227825Stheraven        {static_assert(!is_reference<_Hp>::value ||
261232924Stheraven                       (is_lvalue_reference<_Hp>::value &&
262227825Stheraven                        (is_lvalue_reference<_Tp>::value ||
263227825Stheraven                         is_same<typename remove_reference<_Tp>::type,
264227825Stheraven                                 reference_wrapper<
265227825Stheraven                                    typename remove_reference<_Hp>::type
266227825Stheraven                                 >
267232924Stheraven                                >::value)) ||
268227825Stheraven                        (is_rvalue_reference<_Hp>::value &&
269227825Stheraven                         !is_lvalue_reference<_Tp>::value),
270227825Stheraven       "Attempted to construct a reference element in a tuple with an rvalue");}
271227825Stheraven
272227825Stheraven    template <class _Tp, class _Alloc>
273227825Stheraven        _LIBCPP_INLINE_VISIBILITY
274227825Stheraven        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
275227825Stheraven            : value(_VSTD::forward<_Tp>(__t))
276227825Stheraven        {static_assert(!is_lvalue_reference<_Hp>::value ||
277232924Stheraven                       (is_lvalue_reference<_Hp>::value &&
278227825Stheraven                        (is_lvalue_reference<_Tp>::value ||
279227825Stheraven                         is_same<typename remove_reference<_Tp>::type,
280227825Stheraven                                 reference_wrapper<
281227825Stheraven                                    typename remove_reference<_Hp>::type
282227825Stheraven                                 >
283232924Stheraven                                >::value)),
284227825Stheraven       "Attempted to construct a reference element in a tuple with an rvalue");}
285227825Stheraven
286227825Stheraven    template <class _Tp, class _Alloc>
287227825Stheraven        _LIBCPP_INLINE_VISIBILITY
288227825Stheraven        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
289227825Stheraven            : value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
290227825Stheraven        {static_assert(!is_lvalue_reference<_Hp>::value ||
291232924Stheraven                       (is_lvalue_reference<_Hp>::value &&
292227825Stheraven                        (is_lvalue_reference<_Tp>::value ||
293227825Stheraven                         is_same<typename remove_reference<_Tp>::type,
294227825Stheraven                                 reference_wrapper<
295227825Stheraven                                    typename remove_reference<_Hp>::type
296227825Stheraven                                 >
297232924Stheraven                                >::value)),
298227825Stheraven       "Attempted to construct a reference element in a tuple with an rvalue");}
299227825Stheraven
300227825Stheraven    template <class _Tp, class _Alloc>
301227825Stheraven        _LIBCPP_INLINE_VISIBILITY
302227825Stheraven        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
303227825Stheraven            : value(_VSTD::forward<_Tp>(__t), __a)
304227825Stheraven        {static_assert(!is_lvalue_reference<_Hp>::value ||
305232924Stheraven                       (is_lvalue_reference<_Hp>::value &&
306227825Stheraven                        (is_lvalue_reference<_Tp>::value ||
307227825Stheraven                         is_same<typename remove_reference<_Tp>::type,
308227825Stheraven                                 reference_wrapper<
309227825Stheraven                                    typename remove_reference<_Hp>::type
310227825Stheraven                                 >
311232924Stheraven                                >::value)),
312227825Stheraven       "Attempted to construct a reference element in a tuple with an rvalue");}
313227825Stheraven
314227825Stheraven    __tuple_leaf(const __tuple_leaf& __t)
315227825Stheraven        : value(__t.get())
316227825Stheraven        {static_assert(!is_rvalue_reference<_Hp>::value, "Can not copy a tuple with rvalue reference member");}
317227825Stheraven
318227825Stheraven    template <class _Tp>
319227825Stheraven        _LIBCPP_INLINE_VISIBILITY
320227825Stheraven        explicit __tuple_leaf(const __tuple_leaf<_Ip, _Tp>& __t)
321227825Stheraven            : value(__t.get()) {}
322227825Stheraven
323227825Stheraven    template <class _Tp>
324227825Stheraven        _LIBCPP_INLINE_VISIBILITY
325227825Stheraven        __tuple_leaf&
326227825Stheraven        operator=(_Tp&& __t)
327227825Stheraven        {
328227825Stheraven            value = _VSTD::forward<_Tp>(__t);
329227825Stheraven            return *this;
330227825Stheraven        }
331227825Stheraven
332227825Stheraven    _LIBCPP_INLINE_VISIBILITY
333227825Stheraven    int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
334227825Stheraven    {
335227825Stheraven        _VSTD::swap(*this, __t);
336227825Stheraven        return 0;
337227825Stheraven    }
338227825Stheraven
339227825Stheraven    _LIBCPP_INLINE_VISIBILITY       _Hp& get()       {return value;}
340227825Stheraven    _LIBCPP_INLINE_VISIBILITY const _Hp& get() const {return value;}
341227825Stheraven};
342227825Stheraven
343227825Stheraventemplate <size_t _Ip, class _Hp>
344227825Stheravenclass __tuple_leaf<_Ip, _Hp, true>
345227825Stheraven    : private _Hp
346227825Stheraven{
347227825Stheraven
348227825Stheraven    __tuple_leaf& operator=(const __tuple_leaf&);
349227825Stheravenpublic:
350227825Stheraven    _LIBCPP_INLINE_VISIBILITY __tuple_leaf() {}
351227825Stheraven
352227825Stheraven    template <class _Alloc>
353227825Stheraven        _LIBCPP_INLINE_VISIBILITY
354227825Stheraven        __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
355227825Stheraven
356227825Stheraven    template <class _Alloc>
357227825Stheraven        _LIBCPP_INLINE_VISIBILITY
358227825Stheraven        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
359227825Stheraven            : _Hp(allocator_arg_t(), __a) {}
360227825Stheraven
361227825Stheraven    template <class _Alloc>
362227825Stheraven        _LIBCPP_INLINE_VISIBILITY
363227825Stheraven        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
364227825Stheraven            : _Hp(__a) {}
365227825Stheraven
366227825Stheraven    template <class _Tp,
367227825Stheraven              class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
368227825Stheraven        _LIBCPP_INLINE_VISIBILITY
369227825Stheraven        explicit __tuple_leaf(_Tp&& __t)
370227825Stheraven            : _Hp(_VSTD::forward<_Tp>(__t)) {}
371227825Stheraven
372227825Stheraven    template <class _Tp, class _Alloc>
373227825Stheraven        _LIBCPP_INLINE_VISIBILITY
374227825Stheraven        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
375227825Stheraven            : _Hp(_VSTD::forward<_Tp>(__t)) {}
376227825Stheraven
377227825Stheraven    template <class _Tp, class _Alloc>
378227825Stheraven        _LIBCPP_INLINE_VISIBILITY
379227825Stheraven        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
380227825Stheraven            : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
381227825Stheraven
382227825Stheraven    template <class _Tp, class _Alloc>
383227825Stheraven        _LIBCPP_INLINE_VISIBILITY
384227825Stheraven        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
385227825Stheraven            : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
386227825Stheraven
387227825Stheraven    template <class _Tp>
388227825Stheraven        _LIBCPP_INLINE_VISIBILITY
389227825Stheraven        explicit __tuple_leaf(const __tuple_leaf<_Ip, _Tp>& __t)
390227825Stheraven            : _Hp(__t.get()) {}
391227825Stheraven
392227825Stheraven    template <class _Tp>
393227825Stheraven        _LIBCPP_INLINE_VISIBILITY
394227825Stheraven        __tuple_leaf&
395227825Stheraven        operator=(_Tp&& __t)
396227825Stheraven        {
397227825Stheraven            _Hp::operator=(_VSTD::forward<_Tp>(__t));
398227825Stheraven            return *this;
399227825Stheraven        }
400227825Stheraven
401227825Stheraven    _LIBCPP_INLINE_VISIBILITY
402227825Stheraven    int
403227825Stheraven    swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
404227825Stheraven    {
405227825Stheraven        _VSTD::swap(*this, __t);
406227825Stheraven        return 0;
407227825Stheraven    }
408227825Stheraven
409227825Stheraven    _LIBCPP_INLINE_VISIBILITY       _Hp& get()       {return static_cast<_Hp&>(*this);}
410227825Stheraven    _LIBCPP_INLINE_VISIBILITY const _Hp& get() const {return static_cast<const _Hp&>(*this);}
411227825Stheraven};
412227825Stheraven
413227825Stheraventemplate <class ..._Tp>
414227825Stheraven_LIBCPP_INLINE_VISIBILITY
415227825Stheravenvoid __swallow(_Tp&&...) {}
416227825Stheraven
417227825Stheraventemplate <bool ...> struct __all;
418227825Stheraven
419227825Stheraventemplate <>
420227825Stheravenstruct __all<>
421227825Stheraven{
422227825Stheraven    static const bool value = true;
423227825Stheraven};
424227825Stheraven
425232924Stheraventemplate <bool _B0, bool ... _Bp>
426232924Stheravenstruct __all<_B0, _Bp...>
427227825Stheraven{
428232924Stheraven    static const bool value = _B0 && __all<_Bp...>::value;
429227825Stheraven};
430227825Stheraven
431227825Stheraven// __tuple_impl
432227825Stheraven
433227825Stheraventemplate<class _Indx, class ..._Tp> struct __tuple_impl;
434227825Stheraven
435227825Stheraventemplate<size_t ..._Indx, class ..._Tp>
436227825Stheravenstruct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
437227825Stheraven    : public __tuple_leaf<_Indx, _Tp>...
438227825Stheraven{
439227825Stheraven    template <size_t ..._Uf, class ..._Tf,
440227825Stheraven              size_t ..._Ul, class ..._Tl, class ..._Up>
441227825Stheraven        _LIBCPP_INLINE_VISIBILITY
442227825Stheraven        explicit
443227825Stheraven        __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
444227825Stheraven                     __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
445227825Stheraven                     _Up&&... __u) :
446227825Stheraven            __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
447227825Stheraven            __tuple_leaf<_Ul, _Tl>()...
448227825Stheraven            {}
449227825Stheraven
450227825Stheraven    template <class _Alloc, size_t ..._Uf, class ..._Tf,
451227825Stheraven              size_t ..._Ul, class ..._Tl, class ..._Up>
452227825Stheraven        _LIBCPP_INLINE_VISIBILITY
453227825Stheraven        explicit
454227825Stheraven        __tuple_impl(allocator_arg_t, const _Alloc& __a,
455227825Stheraven                     __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
456227825Stheraven                     __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
457227825Stheraven                     _Up&&... __u) :
458227825Stheraven            __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
459227825Stheraven            _VSTD::forward<_Up>(__u))...,
460227825Stheraven            __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
461227825Stheraven            {}
462227825Stheraven
463227825Stheraven    template <class _Tuple,
464227825Stheraven              class = typename enable_if
465227825Stheraven                      <
466227825Stheraven                         __tuple_convertible<_Tuple, tuple<_Tp...> >::value
467227825Stheraven                      >::type
468227825Stheraven             >
469227825Stheraven        _LIBCPP_INLINE_VISIBILITY
470227825Stheraven        __tuple_impl(_Tuple&& __t)
471227825Stheraven            : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
472227825Stheraven                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
473227825Stheraven            {}
474227825Stheraven
475227825Stheraven    template <class _Alloc, class _Tuple,
476227825Stheraven              class = typename enable_if
477227825Stheraven                      <
478227825Stheraven                         __tuple_convertible<_Tuple, tuple<_Tp...> >::value
479227825Stheraven                      >::type
480227825Stheraven             >
481227825Stheraven        _LIBCPP_INLINE_VISIBILITY
482227825Stheraven        __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
483227825Stheraven            : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
484227825Stheraven                                       typename __make_tuple_types<_Tuple>::type>::type>(), __a,
485227825Stheraven                                       _VSTD::forward<typename tuple_element<_Indx,
486227825Stheraven                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
487227825Stheraven            {}
488227825Stheraven
489227825Stheraven    template <class _Tuple>
490227825Stheraven        _LIBCPP_INLINE_VISIBILITY
491227825Stheraven        typename enable_if
492227825Stheraven        <
493227825Stheraven            __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
494227825Stheraven            __tuple_impl&
495227825Stheraven        >::type
496227825Stheraven        operator=(_Tuple&& __t)
497227825Stheraven        {
498227825Stheraven            __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
499227825Stheraven                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
500227825Stheraven            return *this;
501227825Stheraven        }
502227825Stheraven
503232924Stheraven        _LIBCPP_INLINE_VISIBILITY
504232924Stheraven        __tuple_impl&
505232924Stheraven        operator=(const __tuple_impl& __t)
506232924Stheraven        {
507232924Stheraven            __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
508232924Stheraven            return *this;
509232924Stheraven        }
510232924Stheraven
511227825Stheraven    _LIBCPP_INLINE_VISIBILITY
512227825Stheraven    void swap(__tuple_impl& __t)
513227825Stheraven        _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
514227825Stheraven    {
515227825Stheraven        __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
516227825Stheraven    }
517227825Stheraven};
518227825Stheraven
519227825Stheraventemplate <class ..._Tp>
520227825Stheravenclass _LIBCPP_VISIBLE tuple
521227825Stheraven{
522227825Stheraven    typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
523227825Stheraven
524227825Stheraven    base base_;
525227825Stheraven
526227825Stheraven    template <size_t _Jp, class ..._Up> friend
527232924Stheraven        typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
528227825Stheraven    template <size_t _Jp, class ..._Up> friend
529232924Stheraven        const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
530227825Stheraven    template <size_t _Jp, class ..._Up> friend
531232924Stheraven        typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
532227825Stheravenpublic:
533227825Stheraven
534227825Stheraven    _LIBCPP_INLINE_VISIBILITY
535227825Stheraven    explicit tuple(const _Tp& ... __t)
536227825Stheraven        : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
537227825Stheraven                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
538227825Stheraven                typename __make_tuple_indices<0>::type(),
539227825Stheraven                typename __make_tuple_types<tuple, 0>::type(),
540227825Stheraven                __t...
541227825Stheraven               ) {}
542227825Stheraven
543227825Stheraven    template <class _Alloc>
544227825Stheraven      _LIBCPP_INLINE_VISIBILITY
545227825Stheraven      tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
546227825Stheraven        : base_(allocator_arg_t(), __a,
547227825Stheraven                typename __make_tuple_indices<sizeof...(_Tp)>::type(),
548227825Stheraven                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
549227825Stheraven                typename __make_tuple_indices<0>::type(),
550227825Stheraven                typename __make_tuple_types<tuple, 0>::type(),
551227825Stheraven                __t...
552227825Stheraven               ) {}
553227825Stheraven
554227825Stheraven    template <class ..._Up,
555234959Stheraven              typename enable_if
556227825Stheraven                      <
557227825Stheraven                         sizeof...(_Up) <= sizeof...(_Tp) &&
558227825Stheraven                         __tuple_convertible
559227825Stheraven                         <
560227825Stheraven                            tuple<_Up...>,
561227825Stheraven                            typename __make_tuple_types<tuple,
562227825Stheraven                                     sizeof...(_Up) < sizeof...(_Tp) ?
563227825Stheraven                                        sizeof...(_Up) :
564227825Stheraven                                        sizeof...(_Tp)>::type
565234959Stheraven                         >::value,
566234959Stheraven                         bool
567234959Stheraven                      >::type = false
568227825Stheraven             >
569227825Stheraven        _LIBCPP_INLINE_VISIBILITY
570234959Stheraven        tuple(_Up&&... __u)
571234959Stheraven            : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
572234959Stheraven                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
573234959Stheraven                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
574234959Stheraven                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
575234959Stheraven                    _VSTD::forward<_Up>(__u)...) {}
576234959Stheraven
577234959Stheraven    template <class ..._Up,
578234959Stheraven              typename enable_if
579234959Stheraven                      <
580234959Stheraven                         sizeof...(_Up) <= sizeof...(_Tp) &&
581234959Stheraven                         __tuple_constructible
582234959Stheraven                         <
583234959Stheraven                            tuple<_Up...>,
584234959Stheraven                            typename __make_tuple_types<tuple,
585234959Stheraven                                     sizeof...(_Up) < sizeof...(_Tp) ?
586234959Stheraven                                        sizeof...(_Up) :
587234959Stheraven                                        sizeof...(_Tp)>::type
588234959Stheraven                         >::value &&
589234959Stheraven                         !__tuple_convertible
590234959Stheraven                         <
591234959Stheraven                            tuple<_Up...>,
592234959Stheraven                            typename __make_tuple_types<tuple,
593234959Stheraven                                     sizeof...(_Up) < sizeof...(_Tp) ?
594234959Stheraven                                        sizeof...(_Up) :
595234959Stheraven                                        sizeof...(_Tp)>::type
596234959Stheraven                         >::value,
597234959Stheraven                         bool
598234959Stheraven                      >::type =false
599234959Stheraven             >
600234959Stheraven        _LIBCPP_INLINE_VISIBILITY
601227825Stheraven        explicit
602227825Stheraven        tuple(_Up&&... __u)
603227825Stheraven            : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
604227825Stheraven                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
605227825Stheraven                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
606227825Stheraven                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
607227825Stheraven                    _VSTD::forward<_Up>(__u)...) {}
608227825Stheraven
609227825Stheraven    template <class _Alloc, class ..._Up,
610227825Stheraven              class = typename enable_if
611227825Stheraven                      <
612227825Stheraven                         sizeof...(_Up) <= sizeof...(_Tp) &&
613227825Stheraven                         __tuple_convertible
614227825Stheraven                         <
615227825Stheraven                            tuple<_Up...>,
616227825Stheraven                            typename __make_tuple_types<tuple,
617227825Stheraven                                     sizeof...(_Up) < sizeof...(_Tp) ?
618227825Stheraven                                        sizeof...(_Up) :
619227825Stheraven                                        sizeof...(_Tp)>::type
620227825Stheraven                         >::value
621227825Stheraven                      >::type
622227825Stheraven             >
623227825Stheraven        _LIBCPP_INLINE_VISIBILITY
624227825Stheraven        tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
625227825Stheraven            : base_(allocator_arg_t(), __a,
626227825Stheraven                    typename __make_tuple_indices<sizeof...(_Up)>::type(),
627227825Stheraven                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
628227825Stheraven                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
629227825Stheraven                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
630227825Stheraven                    _VSTD::forward<_Up>(__u)...) {}
631227825Stheraven
632227825Stheraven    template <class _Tuple,
633234959Stheraven              typename enable_if
634227825Stheraven                      <
635234959Stheraven                         __tuple_convertible<_Tuple, tuple>::value,
636234959Stheraven                         bool
637234959Stheraven                      >::type = false
638227825Stheraven             >
639227825Stheraven        _LIBCPP_INLINE_VISIBILITY
640227825Stheraven        tuple(_Tuple&& __t)
641227825Stheraven            : base_(_VSTD::forward<_Tuple>(__t)) {}
642227825Stheraven
643234959Stheraven    template <class _Tuple,
644234959Stheraven              typename enable_if
645234959Stheraven                      <
646234959Stheraven                         __tuple_constructible<_Tuple, tuple>::value &&
647234959Stheraven                         !__tuple_convertible<_Tuple, tuple>::value,
648234959Stheraven                         bool
649234959Stheraven                      >::type = false
650234959Stheraven             >
651234959Stheraven        _LIBCPP_INLINE_VISIBILITY
652234959Stheraven        explicit
653234959Stheraven        tuple(_Tuple&& __t)
654234959Stheraven            : base_(_VSTD::forward<_Tuple>(__t)) {}
655234959Stheraven
656227825Stheraven    template <class _Alloc, class _Tuple,
657227825Stheraven              class = typename enable_if
658227825Stheraven                      <
659227825Stheraven                         __tuple_convertible<_Tuple, tuple>::value
660227825Stheraven                      >::type
661227825Stheraven             >
662227825Stheraven        _LIBCPP_INLINE_VISIBILITY
663227825Stheraven        tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
664227825Stheraven            : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
665227825Stheraven
666227825Stheraven    template <class _Tuple,
667227825Stheraven              class = typename enable_if
668227825Stheraven                      <
669227825Stheraven                         __tuple_assignable<_Tuple, tuple>::value
670227825Stheraven                      >::type
671227825Stheraven             >
672227825Stheraven        _LIBCPP_INLINE_VISIBILITY
673227825Stheraven        tuple&
674227825Stheraven        operator=(_Tuple&& __t)
675227825Stheraven        {
676227825Stheraven            base_.operator=(_VSTD::forward<_Tuple>(__t));
677227825Stheraven            return *this;
678227825Stheraven        }
679227825Stheraven
680227825Stheraven    _LIBCPP_INLINE_VISIBILITY
681227825Stheraven    void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
682227825Stheraven        {base_.swap(__t.base_);}
683227825Stheraven};
684227825Stheraven
685227825Stheraventemplate <>
686227825Stheravenclass _LIBCPP_VISIBLE tuple<>
687227825Stheraven{
688227825Stheravenpublic:
689227825Stheraven    _LIBCPP_INLINE_VISIBILITY
690227825Stheraven    tuple() {}
691227825Stheraven    template <class _Alloc>
692227825Stheraven    _LIBCPP_INLINE_VISIBILITY
693227825Stheraven        tuple(allocator_arg_t, const _Alloc&) {}
694227825Stheraven    template <class _Alloc>
695227825Stheraven    _LIBCPP_INLINE_VISIBILITY
696227825Stheraven        tuple(allocator_arg_t, const _Alloc&, const tuple&) {}
697232924Stheraven    template <class _Up>
698227825Stheraven    _LIBCPP_INLINE_VISIBILITY
699232924Stheraven        tuple(array<_Up, 0>) {}
700232924Stheraven    template <class _Alloc, class _Up>
701227825Stheraven    _LIBCPP_INLINE_VISIBILITY
702232924Stheraven        tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) {}
703227825Stheraven    _LIBCPP_INLINE_VISIBILITY
704227825Stheraven    void swap(tuple&) _NOEXCEPT {}
705227825Stheraven};
706227825Stheraven
707227825Stheraventemplate <class ..._Tp>
708227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
709227825Stheraventypename enable_if
710227825Stheraven<
711227825Stheraven    __all<__is_swappable<_Tp>::value...>::value,
712227825Stheraven    void
713227825Stheraven>::type
714227825Stheravenswap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
715227825Stheraven                 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
716227825Stheraven    {__t.swap(__u);}
717227825Stheraven
718227825Stheraven// get
719227825Stheraven
720227825Stheraventemplate <size_t _Ip, class ..._Tp>
721227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
722227825Stheraventypename tuple_element<_Ip, tuple<_Tp...> >::type&
723232924Stheravenget(tuple<_Tp...>& __t) _NOEXCEPT
724227825Stheraven{
725227825Stheraven    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
726227825Stheraven    return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get();
727227825Stheraven}
728227825Stheraven
729227825Stheraventemplate <size_t _Ip, class ..._Tp>
730227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
731227825Stheravenconst typename tuple_element<_Ip, tuple<_Tp...> >::type&
732232924Stheravenget(const tuple<_Tp...>& __t) _NOEXCEPT
733227825Stheraven{
734227825Stheraven    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
735227825Stheraven    return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
736227825Stheraven}
737227825Stheraven
738227825Stheraventemplate <size_t _Ip, class ..._Tp>
739227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
740227825Stheraventypename tuple_element<_Ip, tuple<_Tp...> >::type&&
741232924Stheravenget(tuple<_Tp...>&& __t) _NOEXCEPT
742227825Stheraven{
743227825Stheraven    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
744227825Stheraven    return static_cast<type&&>(
745227825Stheraven             static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
746227825Stheraven}
747227825Stheraven
748227825Stheraven// tie
749227825Stheraven
750227825Stheraventemplate <class ..._Tp>
751227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
752227825Stheraventuple<_Tp&...>
753227825Stheraventie(_Tp&... __t)
754227825Stheraven{
755227825Stheraven    return tuple<_Tp&...>(__t...);
756227825Stheraven}
757227825Stheraven
758227825Stheraventemplate <class _Up>
759227825Stheravenstruct __ignore_t
760227825Stheraven{
761227825Stheraven    template <class _Tp>
762227825Stheraven        _LIBCPP_INLINE_VISIBILITY
763227825Stheraven        const __ignore_t& operator=(_Tp&&) const {return *this;}
764227825Stheraven};
765227825Stheraven
766227825Stheravennamespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
767227825Stheraven
768227825Stheraventemplate <class _Tp> class reference_wrapper;
769227825Stheraven
770227825Stheraventemplate <class _Tp>
771227825Stheravenstruct ___make_tuple_return
772227825Stheraven{
773227825Stheraven    typedef _Tp type;
774227825Stheraven};
775227825Stheraven
776227825Stheraventemplate <class _Tp>
777227825Stheravenstruct ___make_tuple_return<reference_wrapper<_Tp> >
778227825Stheraven{
779227825Stheraven    typedef _Tp& type;
780227825Stheraven};
781227825Stheraven
782227825Stheraventemplate <class _Tp>
783227825Stheravenstruct __make_tuple_return
784227825Stheraven{
785227825Stheraven    typedef typename ___make_tuple_return<typename decay<_Tp>::type>::type type;
786227825Stheraven};
787227825Stheraven
788227825Stheraventemplate <class... _Tp>
789227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
790227825Stheraventuple<typename __make_tuple_return<_Tp>::type...>
791227825Stheravenmake_tuple(_Tp&&... __t)
792227825Stheraven{
793227825Stheraven    return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
794227825Stheraven}
795227825Stheraven
796227825Stheraventemplate <class... _Tp>
797227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
798227825Stheraventuple<_Tp&&...>
799227825Stheravenforward_as_tuple(_Tp&&... __t)
800227825Stheraven{
801227825Stheraven    return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
802227825Stheraven}
803227825Stheraven
804232924Stheraventemplate <size_t _Ip>
805227825Stheravenstruct __tuple_equal
806227825Stheraven{
807227825Stheraven    template <class _Tp, class _Up>
808227825Stheraven    _LIBCPP_INLINE_VISIBILITY
809227825Stheraven    bool operator()(const _Tp& __x, const _Up& __y)
810227825Stheraven    {
811232924Stheraven        return __tuple_equal<_Ip - 1>()(__x, __y) && get<_Ip-1>(__x) == get<_Ip-1>(__y);
812227825Stheraven    }
813227825Stheraven};
814227825Stheraven
815227825Stheraventemplate <>
816227825Stheravenstruct __tuple_equal<0>
817227825Stheraven{
818227825Stheraven    template <class _Tp, class _Up>
819227825Stheraven    _LIBCPP_INLINE_VISIBILITY
820227825Stheraven    bool operator()(const _Tp&, const _Up&)
821227825Stheraven    {
822227825Stheraven        return true;
823227825Stheraven    }
824227825Stheraven};
825227825Stheraven
826227825Stheraventemplate <class ..._Tp, class ..._Up>
827227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
828227825Stheravenbool
829227825Stheravenoperator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
830227825Stheraven{
831227825Stheraven    return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
832227825Stheraven}
833227825Stheraven
834227825Stheraventemplate <class ..._Tp, class ..._Up>
835227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
836227825Stheravenbool
837227825Stheravenoperator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
838227825Stheraven{
839227825Stheraven    return !(__x == __y);
840227825Stheraven}
841227825Stheraven
842232924Stheraventemplate <size_t _Ip>
843227825Stheravenstruct __tuple_less
844227825Stheraven{
845227825Stheraven    template <class _Tp, class _Up>
846227825Stheraven    _LIBCPP_INLINE_VISIBILITY
847227825Stheraven    bool operator()(const _Tp& __x, const _Up& __y)
848227825Stheraven    {
849232924Stheraven        return __tuple_less<_Ip-1>()(__x, __y) ||
850232924Stheraven             (!__tuple_less<_Ip-1>()(__y, __x) && get<_Ip-1>(__x) < get<_Ip-1>(__y));
851227825Stheraven    }
852227825Stheraven};
853227825Stheraven
854227825Stheraventemplate <>
855227825Stheravenstruct __tuple_less<0>
856227825Stheraven{
857227825Stheraven    template <class _Tp, class _Up>
858227825Stheraven    _LIBCPP_INLINE_VISIBILITY
859227825Stheraven    bool operator()(const _Tp&, const _Up&)
860227825Stheraven    {
861227825Stheraven        return false;
862227825Stheraven    }
863227825Stheraven};
864227825Stheraven
865227825Stheraventemplate <class ..._Tp, class ..._Up>
866227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
867227825Stheravenbool
868227825Stheravenoperator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
869227825Stheraven{
870227825Stheraven    return __tuple_less<sizeof...(_Tp)>()(__x, __y);
871227825Stheraven}
872227825Stheraven
873227825Stheraventemplate <class ..._Tp, class ..._Up>
874227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
875227825Stheravenbool
876227825Stheravenoperator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
877227825Stheraven{
878227825Stheraven    return __y < __x;
879227825Stheraven}
880227825Stheraven
881227825Stheraventemplate <class ..._Tp, class ..._Up>
882227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
883227825Stheravenbool
884227825Stheravenoperator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
885227825Stheraven{
886227825Stheraven    return !(__x < __y);
887227825Stheraven}
888227825Stheraven
889227825Stheraventemplate <class ..._Tp, class ..._Up>
890227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
891227825Stheravenbool
892227825Stheravenoperator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
893227825Stheraven{
894227825Stheraven    return !(__y < __x);
895227825Stheraven}
896227825Stheraven
897227825Stheraven// tuple_cat
898227825Stheraven
899227825Stheraventemplate <class _Tp, class _Up> struct __tuple_cat_type;
900227825Stheraven
901227825Stheraventemplate <class ..._Ttypes, class ..._Utypes>
902227825Stheravenstruct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
903227825Stheraven{
904227825Stheraven    typedef tuple<_Ttypes..., _Utypes...> type;
905227825Stheraven};
906227825Stheraven
907227825Stheraventemplate <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
908227825Stheravenstruct __tuple_cat_return_1
909227825Stheraven{
910227825Stheraven};
911227825Stheraven
912227825Stheraventemplate <class ..._Types, class _Tuple0>
913227825Stheravenstruct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
914227825Stheraven{
915227825Stheraven    typedef typename __tuple_cat_type<tuple<_Types...>,
916227825Stheraven            typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
917227825Stheraven                                                                           type;
918227825Stheraven};
919227825Stheraven
920227825Stheraventemplate <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
921227825Stheravenstruct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
922227825Stheraven    : public __tuple_cat_return_1<
923227825Stheraven                 typename __tuple_cat_type<
924227825Stheraven                     tuple<_Types...>,
925227825Stheraven                     typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
926227825Stheraven                 >::type,
927227825Stheraven                 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
928227825Stheraven                 _Tuple1, _Tuples...>
929227825Stheraven{
930227825Stheraven};
931227825Stheraven
932227825Stheraventemplate <class ..._Tuples> struct __tuple_cat_return;
933227825Stheraven
934227825Stheraventemplate <class _Tuple0, class ..._Tuples>
935227825Stheravenstruct __tuple_cat_return<_Tuple0, _Tuples...>
936227825Stheraven    : public __tuple_cat_return_1<tuple<>,
937227825Stheraven         __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
938227825Stheraven                                                                     _Tuples...>
939227825Stheraven{
940227825Stheraven};
941227825Stheraven
942227825Stheraventemplate <>
943227825Stheravenstruct __tuple_cat_return<>
944227825Stheraven{
945227825Stheraven    typedef tuple<> type;
946227825Stheraven};
947227825Stheraven
948227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
949227825Stheraventuple<>
950227825Stheraventuple_cat()
951227825Stheraven{
952227825Stheraven    return tuple<>();
953227825Stheraven}
954227825Stheraven
955232924Stheraventemplate <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
956227825Stheravenstruct __tuple_cat_return_ref_imp;
957227825Stheraven
958227825Stheraventemplate <class ..._Types, size_t ..._I0, class _Tuple0>
959227825Stheravenstruct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
960227825Stheraven{
961227825Stheraven    typedef typename remove_reference<_Tuple0>::type _T0;
962227825Stheraven    typedef tuple<_Types..., typename __apply_cv<_Tuple0,
963227825Stheraven                          typename tuple_element<_I0, _T0>::type>::type&&...> type;
964227825Stheraven};
965227825Stheraven
966227825Stheraventemplate <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
967227825Stheravenstruct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
968227825Stheraven                                  _Tuple0, _Tuple1, _Tuples...>
969227825Stheraven    : public __tuple_cat_return_ref_imp<
970227825Stheraven         tuple<_Types..., typename __apply_cv<_Tuple0,
971227825Stheraven               typename tuple_element<_I0,
972227825Stheraven                  typename remove_reference<_Tuple0>::type>::type>::type&&...>,
973227825Stheraven         typename __make_tuple_indices<tuple_size<typename
974227825Stheraven                                 remove_reference<_Tuple1>::type>::value>::type,
975227825Stheraven         _Tuple1, _Tuples...>
976227825Stheraven{
977227825Stheraven};
978227825Stheraven
979227825Stheraventemplate <class _Tuple0, class ..._Tuples>
980227825Stheravenstruct __tuple_cat_return_ref
981227825Stheraven    : public __tuple_cat_return_ref_imp<tuple<>,
982227825Stheraven               typename __make_tuple_indices<
983227825Stheraven                        tuple_size<typename remove_reference<_Tuple0>::type>::value
984227825Stheraven               >::type, _Tuple0, _Tuples...>
985227825Stheraven{
986227825Stheraven};
987227825Stheraven
988227825Stheraventemplate <class _Types, class _I0, class _J0>
989227825Stheravenstruct __tuple_cat;
990227825Stheraven
991227825Stheraventemplate <class ..._Types, size_t ..._I0, size_t ..._J0>
992227825Stheravenstruct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
993227825Stheraven{
994227825Stheraven    template <class _Tuple0>
995227825Stheraven    _LIBCPP_INLINE_VISIBILITY
996227825Stheraven    typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
997227825Stheraven    operator()(tuple<_Types...> __t, _Tuple0&& __t0)
998227825Stheraven    {
999227825Stheraven        return _VSTD::forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))...,
1000227825Stheraven                                      get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
1001227825Stheraven    }
1002227825Stheraven
1003227825Stheraven    template <class _Tuple0, class _Tuple1, class ..._Tuples>
1004227825Stheraven    _LIBCPP_INLINE_VISIBILITY
1005227825Stheraven    typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1006227825Stheraven    operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1007227825Stheraven    {
1008227825Stheraven        typedef typename remove_reference<_Tuple0>::type _T0;
1009227825Stheraven        typedef typename remove_reference<_Tuple1>::type _T1;
1010227825Stheraven        return __tuple_cat<
1011227825Stheraven           tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1012227825Stheraven           typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1013227825Stheraven           typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
1014227825Stheraven                           (_VSTD::forward_as_tuple(
1015227825Stheraven                              _VSTD::forward<_Types>(get<_I0>(__t))...,
1016227825Stheraven                              get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
1017227825Stheraven                            ),
1018227825Stheraven                            _VSTD::forward<_Tuple1>(__t1),
1019227825Stheraven                            _VSTD::forward<_Tuples>(__tpls)...);
1020227825Stheraven    }
1021227825Stheraven};
1022227825Stheraven
1023227825Stheraventemplate <class _Tuple0, class... _Tuples>
1024227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1025227825Stheraventypename __tuple_cat_return<_Tuple0, _Tuples...>::type
1026227825Stheraventuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1027227825Stheraven{
1028227825Stheraven    typedef typename remove_reference<_Tuple0>::type _T0;
1029227825Stheraven    return __tuple_cat<tuple<>, __tuple_indices<>,
1030227825Stheraven                  typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
1031227825Stheraven                  (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1032227825Stheraven                                            _VSTD::forward<_Tuples>(__tpls)...);
1033227825Stheraven}
1034227825Stheraven
1035227825Stheraventemplate <class ..._Tp, class _Alloc>
1036227825Stheravenstruct _LIBCPP_VISIBLE uses_allocator<tuple<_Tp...>, _Alloc>
1037227825Stheraven    : true_type {};
1038227825Stheraven
1039227825Stheraventemplate <class _T1, class _T2>
1040227825Stheraventemplate <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1041227825Stheraveninline _LIBCPP_INLINE_VISIBILITY
1042227825Stheravenpair<_T1, _T2>::pair(piecewise_construct_t,
1043227825Stheraven                     tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1044227825Stheraven                     __tuple_indices<_I1...>, __tuple_indices<_I2...>)
1045227825Stheraven    :  first(_VSTD::forward<_Args1>(get<_I1>( __first_args))...),
1046227825Stheraven      second(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
1047227825Stheraven{
1048227825Stheraven}
1049227825Stheraven
1050227825Stheraven#endif  // _LIBCPP_HAS_NO_VARIADICS
1051227825Stheraven
1052227825Stheraven_LIBCPP_END_NAMESPACE_STD
1053227825Stheraven
1054227825Stheraven#endif  // _LIBCPP_TUPLE
1055