xref: /minix3/external/bsd/libc++/dist/libcxx/include/tuple (revision 4684ddb6aab0b36791c8099bc705d6140b3d05d0)
1*4684ddb6SLionel Sambuc// -*- C++ -*-
2*4684ddb6SLionel Sambuc//===--------------------------- tuple ------------------------------------===//
3*4684ddb6SLionel Sambuc//
4*4684ddb6SLionel Sambuc//                     The LLVM Compiler Infrastructure
5*4684ddb6SLionel Sambuc//
6*4684ddb6SLionel Sambuc// This file is distributed under the University of Illinois Open Source
7*4684ddb6SLionel Sambuc// License. See LICENSE.TXT for details.
8*4684ddb6SLionel Sambuc//
9*4684ddb6SLionel Sambuc//===----------------------------------------------------------------------===//
10*4684ddb6SLionel Sambuc
11*4684ddb6SLionel Sambuc#ifndef _LIBCPP_TUPLE
12*4684ddb6SLionel Sambuc#define _LIBCPP_TUPLE
13*4684ddb6SLionel Sambuc
14*4684ddb6SLionel Sambuc/*
15*4684ddb6SLionel Sambuc    tuple synopsis
16*4684ddb6SLionel Sambuc
17*4684ddb6SLionel Sambucnamespace std
18*4684ddb6SLionel Sambuc{
19*4684ddb6SLionel Sambuc
20*4684ddb6SLionel Sambuctemplate <class... T>
21*4684ddb6SLionel Sambucclass tuple {
22*4684ddb6SLionel Sambucpublic:
23*4684ddb6SLionel Sambuc    constexpr tuple();
24*4684ddb6SLionel Sambuc    explicit tuple(const T&...);  // constexpr in C++14
25*4684ddb6SLionel Sambuc    template <class... U>
26*4684ddb6SLionel Sambuc        explicit tuple(U&&...);  // constexpr in C++14
27*4684ddb6SLionel Sambuc    tuple(const tuple&) = default;
28*4684ddb6SLionel Sambuc    tuple(tuple&&) = default;
29*4684ddb6SLionel Sambuc    template <class... U>
30*4684ddb6SLionel Sambuc        tuple(const tuple<U...>&);  // constexpr in C++14
31*4684ddb6SLionel Sambuc    template <class... U>
32*4684ddb6SLionel Sambuc        tuple(tuple<U...>&&);  // constexpr in C++14
33*4684ddb6SLionel Sambuc    template <class U1, class U2>
34*4684ddb6SLionel Sambuc        tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
35*4684ddb6SLionel Sambuc    template <class U1, class U2>
36*4684ddb6SLionel Sambuc        tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2  // constexpr in C++14
37*4684ddb6SLionel Sambuc
38*4684ddb6SLionel Sambuc    // allocator-extended constructors
39*4684ddb6SLionel Sambuc    template <class Alloc>
40*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a);
41*4684ddb6SLionel Sambuc    template <class Alloc>
42*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, const T&...);
43*4684ddb6SLionel Sambuc    template <class Alloc, class... U>
44*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, U&&...);
45*4684ddb6SLionel Sambuc    template <class Alloc>
46*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, const tuple&);
47*4684ddb6SLionel Sambuc    template <class Alloc>
48*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, tuple&&);
49*4684ddb6SLionel Sambuc    template <class Alloc, class... U>
50*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
51*4684ddb6SLionel Sambuc    template <class Alloc, class... U>
52*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
53*4684ddb6SLionel Sambuc    template <class Alloc, class U1, class U2>
54*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
55*4684ddb6SLionel Sambuc    template <class Alloc, class U1, class U2>
56*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
57*4684ddb6SLionel Sambuc
58*4684ddb6SLionel Sambuc    tuple& operator=(const tuple&);
59*4684ddb6SLionel Sambuc    tuple&
60*4684ddb6SLionel Sambuc        operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
61*4684ddb6SLionel Sambuc    template <class... U>
62*4684ddb6SLionel Sambuc        tuple& operator=(const tuple<U...>&);
63*4684ddb6SLionel Sambuc    template <class... U>
64*4684ddb6SLionel Sambuc        tuple& operator=(tuple<U...>&&);
65*4684ddb6SLionel Sambuc    template <class U1, class U2>
66*4684ddb6SLionel Sambuc        tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
67*4684ddb6SLionel Sambuc    template <class U1, class U2>
68*4684ddb6SLionel Sambuc        tuple& operator=(pair<U1, U2>&&); //iffsizeof...(T) == 2
69*4684ddb6SLionel Sambuc
70*4684ddb6SLionel Sambuc    void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
71*4684ddb6SLionel Sambuc};
72*4684ddb6SLionel Sambuc
73*4684ddb6SLionel Sambucconst unspecified ignore;
74*4684ddb6SLionel Sambuc
75*4684ddb6SLionel Sambuctemplate <class... T> tuple<V...>  make_tuple(T&&...); // constexpr in C++14
76*4684ddb6SLionel Sambuctemplate <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
77*4684ddb6SLionel Sambuctemplate <class... T> tuple<T&...> tie(T&...) noexcept;
78*4684ddb6SLionel Sambuctemplate <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
79*4684ddb6SLionel Sambuc
80*4684ddb6SLionel Sambuc// 20.4.1.4, tuple helper classes:
81*4684ddb6SLionel Sambuctemplate <class T> class tuple_size; // undefined
82*4684ddb6SLionel Sambuctemplate <class... T> class tuple_size<tuple<T...>>;
83*4684ddb6SLionel Sambuctemplate <intsize_t I, class T> class tuple_element; // undefined
84*4684ddb6SLionel Sambuctemplate <intsize_t I, class... T> class tuple_element<I, tuple<T...>>;
85*4684ddb6SLionel Sambuc
86*4684ddb6SLionel Sambuc// 20.4.1.5, element access:
87*4684ddb6SLionel Sambuctemplate <intsize_t I, class... T>
88*4684ddb6SLionel Sambuc    typename tuple_element<I, tuple<T...>>::type&
89*4684ddb6SLionel Sambuc    get(tuple<T...>&) noexcept; // constexpr in C++14
90*4684ddb6SLionel Sambuctemplate <intsize_t I, class... T>
91*4684ddb6SLionel Sambuc    typename tuple_element<I, tuple<T...>>::type const&
92*4684ddb6SLionel Sambuc    get(const tuple<T...>&) noexcept; // constexpr in C++14
93*4684ddb6SLionel Sambuctemplate <intsize_t I, class... T>
94*4684ddb6SLionel Sambuc    typename tuple_element<I, tuple<T...>>::type&&
95*4684ddb6SLionel Sambuc    get(tuple<T...>&&) noexcept; // constexpr in C++14
96*4684ddb6SLionel Sambuc
97*4684ddb6SLionel Sambuctemplate <class T1, class... T>
98*4684ddb6SLionel Sambuc    constexpr T1& get(tuple<T...>&) noexcept;  // C++14
99*4684ddb6SLionel Sambuctemplate <class T1, class... T>
100*4684ddb6SLionel Sambuc    constexpr T1 const& get(const tuple<T...>&) noexcept;   // C++14
101*4684ddb6SLionel Sambuctemplate <class T1, class... T>
102*4684ddb6SLionel Sambuc    constexpr T1&& get(tuple<T...>&&) noexcept;   // C++14
103*4684ddb6SLionel Sambuc
104*4684ddb6SLionel Sambuc// 20.4.1.6, relational operators:
105*4684ddb6SLionel Sambuctemplate<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
106*4684ddb6SLionel Sambuctemplate<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&);  // constexpr in C++14
107*4684ddb6SLionel Sambuctemplate<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
108*4684ddb6SLionel Sambuctemplate<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&);  // constexpr in C++14
109*4684ddb6SLionel Sambuctemplate<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
110*4684ddb6SLionel Sambuctemplate<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
111*4684ddb6SLionel Sambuc
112*4684ddb6SLionel Sambuctemplate <class... Types, class Alloc>
113*4684ddb6SLionel Sambuc  struct uses_allocator<tuple<Types...>, Alloc>;
114*4684ddb6SLionel Sambuc
115*4684ddb6SLionel Sambuctemplate <class... Types>
116*4684ddb6SLionel Sambuc  void
117*4684ddb6SLionel Sambuc  swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
118*4684ddb6SLionel Sambuc
119*4684ddb6SLionel Sambuc}  // std
120*4684ddb6SLionel Sambuc
121*4684ddb6SLionel Sambuc*/
122*4684ddb6SLionel Sambuc
123*4684ddb6SLionel Sambuc#include <__config>
124*4684ddb6SLionel Sambuc#include <__tuple>
125*4684ddb6SLionel Sambuc#include <cstddef>
126*4684ddb6SLionel Sambuc#include <type_traits>
127*4684ddb6SLionel Sambuc#include <__functional_base>
128*4684ddb6SLionel Sambuc#include <utility>
129*4684ddb6SLionel Sambuc
130*4684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
131*4684ddb6SLionel Sambuc#pragma GCC system_header
132*4684ddb6SLionel Sambuc#endif
133*4684ddb6SLionel Sambuc
134*4684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD
135*4684ddb6SLionel Sambuc
136*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS
137*4684ddb6SLionel Sambuc
138*4684ddb6SLionel Sambuc// tuple_size
139*4684ddb6SLionel Sambuc
140*4684ddb6SLionel Sambuctemplate <class ..._Tp>
141*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY tuple_size<tuple<_Tp...> >
142*4684ddb6SLionel Sambuc    : public integral_constant<size_t, sizeof...(_Tp)>
143*4684ddb6SLionel Sambuc{
144*4684ddb6SLionel Sambuc};
145*4684ddb6SLionel Sambuc
146*4684ddb6SLionel Sambuc// tuple_element
147*4684ddb6SLionel Sambuc
148*4684ddb6SLionel Sambuctemplate <size_t _Ip, class ..._Tp>
149*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> >
150*4684ddb6SLionel Sambuc{
151*4684ddb6SLionel Sambucpublic:
152*4684ddb6SLionel Sambuc    typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
153*4684ddb6SLionel Sambuc};
154*4684ddb6SLionel Sambuc
155*4684ddb6SLionel Sambuc// __tuple_leaf
156*4684ddb6SLionel Sambuc
157*4684ddb6SLionel Sambuctemplate <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
158*4684ddb6SLionel Sambuc#if __has_feature(is_final)
159*4684ddb6SLionel Sambuc                                 && !__is_final(_Hp)
160*4684ddb6SLionel Sambuc#endif
161*4684ddb6SLionel Sambuc         >
162*4684ddb6SLionel Sambucclass __tuple_leaf;
163*4684ddb6SLionel Sambuc
164*4684ddb6SLionel Sambuctemplate <size_t _Ip, class _Hp, bool _Ep>
165*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
166*4684ddb6SLionel Sambucvoid swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
167*4684ddb6SLionel Sambuc    _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
168*4684ddb6SLionel Sambuc{
169*4684ddb6SLionel Sambuc    swap(__x.get(), __y.get());
170*4684ddb6SLionel Sambuc}
171*4684ddb6SLionel Sambuc
172*4684ddb6SLionel Sambuctemplate <size_t _Ip, class _Hp, bool>
173*4684ddb6SLionel Sambucclass __tuple_leaf
174*4684ddb6SLionel Sambuc{
175*4684ddb6SLionel Sambuc    _Hp value;
176*4684ddb6SLionel Sambuc
177*4684ddb6SLionel Sambuc    __tuple_leaf& operator=(const __tuple_leaf&);
178*4684ddb6SLionel Sambucpublic:
179*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
180*4684ddb6SLionel Sambuc             _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value()
181*4684ddb6SLionel Sambuc       {static_assert(!is_reference<_Hp>::value,
182*4684ddb6SLionel Sambuc              "Attempted to default construct a reference element in a tuple");}
183*4684ddb6SLionel Sambuc
184*4684ddb6SLionel Sambuc    template <class _Alloc>
185*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
186*4684ddb6SLionel Sambuc        __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
187*4684ddb6SLionel Sambuc            : value()
188*4684ddb6SLionel Sambuc        {static_assert(!is_reference<_Hp>::value,
189*4684ddb6SLionel Sambuc              "Attempted to default construct a reference element in a tuple");}
190*4684ddb6SLionel Sambuc
191*4684ddb6SLionel Sambuc    template <class _Alloc>
192*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
193*4684ddb6SLionel Sambuc        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
194*4684ddb6SLionel Sambuc            : value(allocator_arg_t(), __a)
195*4684ddb6SLionel Sambuc        {static_assert(!is_reference<_Hp>::value,
196*4684ddb6SLionel Sambuc              "Attempted to default construct a reference element in a tuple");}
197*4684ddb6SLionel Sambuc
198*4684ddb6SLionel Sambuc    template <class _Alloc>
199*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
200*4684ddb6SLionel Sambuc        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
201*4684ddb6SLionel Sambuc            : value(__a)
202*4684ddb6SLionel Sambuc        {static_assert(!is_reference<_Hp>::value,
203*4684ddb6SLionel Sambuc              "Attempted to default construct a reference element in a tuple");}
204*4684ddb6SLionel Sambuc
205*4684ddb6SLionel Sambuc    template <class _Tp,
206*4684ddb6SLionel Sambuc              class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
207*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
208*4684ddb6SLionel Sambuc        explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
209*4684ddb6SLionel Sambuc            : value(_VSTD::forward<_Tp>(__t))
210*4684ddb6SLionel Sambuc        {static_assert(!is_reference<_Hp>::value ||
211*4684ddb6SLionel Sambuc                       (is_lvalue_reference<_Hp>::value &&
212*4684ddb6SLionel Sambuc                        (is_lvalue_reference<_Tp>::value ||
213*4684ddb6SLionel Sambuc                         is_same<typename remove_reference<_Tp>::type,
214*4684ddb6SLionel Sambuc                                 reference_wrapper<
215*4684ddb6SLionel Sambuc                                    typename remove_reference<_Hp>::type
216*4684ddb6SLionel Sambuc                                 >
217*4684ddb6SLionel Sambuc                                >::value)) ||
218*4684ddb6SLionel Sambuc                        (is_rvalue_reference<_Hp>::value &&
219*4684ddb6SLionel Sambuc                         !is_lvalue_reference<_Tp>::value),
220*4684ddb6SLionel Sambuc       "Attempted to construct a reference element in a tuple with an rvalue");}
221*4684ddb6SLionel Sambuc
222*4684ddb6SLionel Sambuc    template <class _Tp, class _Alloc>
223*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
224*4684ddb6SLionel Sambuc        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
225*4684ddb6SLionel Sambuc            : value(_VSTD::forward<_Tp>(__t))
226*4684ddb6SLionel Sambuc        {static_assert(!is_lvalue_reference<_Hp>::value ||
227*4684ddb6SLionel Sambuc                       (is_lvalue_reference<_Hp>::value &&
228*4684ddb6SLionel Sambuc                        (is_lvalue_reference<_Tp>::value ||
229*4684ddb6SLionel Sambuc                         is_same<typename remove_reference<_Tp>::type,
230*4684ddb6SLionel Sambuc                                 reference_wrapper<
231*4684ddb6SLionel Sambuc                                    typename remove_reference<_Hp>::type
232*4684ddb6SLionel Sambuc                                 >
233*4684ddb6SLionel Sambuc                                >::value)),
234*4684ddb6SLionel Sambuc       "Attempted to construct a reference element in a tuple with an rvalue");}
235*4684ddb6SLionel Sambuc
236*4684ddb6SLionel Sambuc    template <class _Tp, class _Alloc>
237*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
238*4684ddb6SLionel Sambuc        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
239*4684ddb6SLionel Sambuc            : value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
240*4684ddb6SLionel Sambuc        {static_assert(!is_lvalue_reference<_Hp>::value ||
241*4684ddb6SLionel Sambuc                       (is_lvalue_reference<_Hp>::value &&
242*4684ddb6SLionel Sambuc                        (is_lvalue_reference<_Tp>::value ||
243*4684ddb6SLionel Sambuc                         is_same<typename remove_reference<_Tp>::type,
244*4684ddb6SLionel Sambuc                                 reference_wrapper<
245*4684ddb6SLionel Sambuc                                    typename remove_reference<_Hp>::type
246*4684ddb6SLionel Sambuc                                 >
247*4684ddb6SLionel Sambuc                                >::value)),
248*4684ddb6SLionel Sambuc       "Attempted to construct a reference element in a tuple with an rvalue");}
249*4684ddb6SLionel Sambuc
250*4684ddb6SLionel Sambuc    template <class _Tp, class _Alloc>
251*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
252*4684ddb6SLionel Sambuc        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
253*4684ddb6SLionel Sambuc            : value(_VSTD::forward<_Tp>(__t), __a)
254*4684ddb6SLionel Sambuc        {static_assert(!is_lvalue_reference<_Hp>::value ||
255*4684ddb6SLionel Sambuc                       (is_lvalue_reference<_Hp>::value &&
256*4684ddb6SLionel Sambuc                        (is_lvalue_reference<_Tp>::value ||
257*4684ddb6SLionel Sambuc                         is_same<typename remove_reference<_Tp>::type,
258*4684ddb6SLionel Sambuc                                 reference_wrapper<
259*4684ddb6SLionel Sambuc                                    typename remove_reference<_Hp>::type
260*4684ddb6SLionel Sambuc                                 >
261*4684ddb6SLionel Sambuc                                >::value)),
262*4684ddb6SLionel Sambuc       "Attempted to construct a reference element in a tuple with an rvalue");}
263*4684ddb6SLionel Sambuc
264*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
265*4684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11
266*4684ddb6SLionel Sambuc    __tuple_leaf(const __tuple_leaf& __t) _NOEXCEPT_(is_nothrow_copy_constructible<_Hp>::value)
267*4684ddb6SLionel Sambuc        : value(__t.get())
268*4684ddb6SLionel Sambuc        {static_assert(!is_rvalue_reference<_Hp>::value, "Can not copy a tuple with rvalue reference member");}
269*4684ddb6SLionel Sambuc
270*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
271*4684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR_AFTER_CXX11
272*4684ddb6SLionel Sambuc    __tuple_leaf(__tuple_leaf&& __t) _NOEXCEPT_(is_nothrow_move_constructible<_Hp>::value)
273*4684ddb6SLionel Sambuc        : value(_VSTD::forward<_Hp>(__t.get()))
274*4684ddb6SLionel Sambuc        {}
275*4684ddb6SLionel Sambuc
276*4684ddb6SLionel Sambuc    template <class _Tp>
277*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
278*4684ddb6SLionel Sambuc        __tuple_leaf&
279*4684ddb6SLionel Sambuc        operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
280*4684ddb6SLionel Sambuc        {
281*4684ddb6SLionel Sambuc            value = _VSTD::forward<_Tp>(__t);
282*4684ddb6SLionel Sambuc            return *this;
283*4684ddb6SLionel Sambuc        }
284*4684ddb6SLionel Sambuc
285*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
286*4684ddb6SLionel Sambuc    int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
287*4684ddb6SLionel Sambuc    {
288*4684ddb6SLionel Sambuc        _VSTD::swap(*this, __t);
289*4684ddb6SLionel Sambuc        return 0;
290*4684ddb6SLionel Sambuc    }
291*4684ddb6SLionel Sambuc
292*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11       _Hp& get()       _NOEXCEPT {return value;}
293*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return value;}
294*4684ddb6SLionel Sambuc};
295*4684ddb6SLionel Sambuc
296*4684ddb6SLionel Sambuctemplate <size_t _Ip, class _Hp>
297*4684ddb6SLionel Sambucclass __tuple_leaf<_Ip, _Hp, true>
298*4684ddb6SLionel Sambuc    : private _Hp
299*4684ddb6SLionel Sambuc{
300*4684ddb6SLionel Sambuc
301*4684ddb6SLionel Sambuc    __tuple_leaf& operator=(const __tuple_leaf&);
302*4684ddb6SLionel Sambucpublic:
303*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
304*4684ddb6SLionel Sambuc             _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
305*4684ddb6SLionel Sambuc
306*4684ddb6SLionel Sambuc    template <class _Alloc>
307*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
308*4684ddb6SLionel Sambuc        __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
309*4684ddb6SLionel Sambuc
310*4684ddb6SLionel Sambuc    template <class _Alloc>
311*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
312*4684ddb6SLionel Sambuc        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
313*4684ddb6SLionel Sambuc            : _Hp(allocator_arg_t(), __a) {}
314*4684ddb6SLionel Sambuc
315*4684ddb6SLionel Sambuc    template <class _Alloc>
316*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
317*4684ddb6SLionel Sambuc        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
318*4684ddb6SLionel Sambuc            : _Hp(__a) {}
319*4684ddb6SLionel Sambuc
320*4684ddb6SLionel Sambuc    template <class _Tp,
321*4684ddb6SLionel Sambuc              class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
322*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
323*4684ddb6SLionel Sambuc        explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
324*4684ddb6SLionel Sambuc            : _Hp(_VSTD::forward<_Tp>(__t)) {}
325*4684ddb6SLionel Sambuc
326*4684ddb6SLionel Sambuc    template <class _Tp, class _Alloc>
327*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
328*4684ddb6SLionel Sambuc        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
329*4684ddb6SLionel Sambuc            : _Hp(_VSTD::forward<_Tp>(__t)) {}
330*4684ddb6SLionel Sambuc
331*4684ddb6SLionel Sambuc    template <class _Tp, class _Alloc>
332*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
333*4684ddb6SLionel Sambuc        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
334*4684ddb6SLionel Sambuc            : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
335*4684ddb6SLionel Sambuc
336*4684ddb6SLionel Sambuc    template <class _Tp, class _Alloc>
337*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
338*4684ddb6SLionel Sambuc        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
339*4684ddb6SLionel Sambuc            : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
340*4684ddb6SLionel Sambuc
341*4684ddb6SLionel Sambuc    template <class _Tp>
342*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
343*4684ddb6SLionel Sambuc        __tuple_leaf&
344*4684ddb6SLionel Sambuc        operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
345*4684ddb6SLionel Sambuc        {
346*4684ddb6SLionel Sambuc            _Hp::operator=(_VSTD::forward<_Tp>(__t));
347*4684ddb6SLionel Sambuc            return *this;
348*4684ddb6SLionel Sambuc        }
349*4684ddb6SLionel Sambuc
350*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
351*4684ddb6SLionel Sambuc    int
352*4684ddb6SLionel Sambuc    swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
353*4684ddb6SLionel Sambuc    {
354*4684ddb6SLionel Sambuc        _VSTD::swap(*this, __t);
355*4684ddb6SLionel Sambuc        return 0;
356*4684ddb6SLionel Sambuc    }
357*4684ddb6SLionel Sambuc
358*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11       _Hp& get()       _NOEXCEPT {return static_cast<_Hp&>(*this);}
359*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
360*4684ddb6SLionel Sambuc};
361*4684ddb6SLionel Sambuc
362*4684ddb6SLionel Sambuctemplate <class ..._Tp>
363*4684ddb6SLionel Sambuc_LIBCPP_INLINE_VISIBILITY
364*4684ddb6SLionel Sambucvoid __swallow(_Tp&&...) _NOEXCEPT {}
365*4684ddb6SLionel Sambuc
366*4684ddb6SLionel Sambuctemplate <bool ...> struct __all;
367*4684ddb6SLionel Sambuc
368*4684ddb6SLionel Sambuctemplate <>
369*4684ddb6SLionel Sambucstruct __all<>
370*4684ddb6SLionel Sambuc{
371*4684ddb6SLionel Sambuc    static const bool value = true;
372*4684ddb6SLionel Sambuc};
373*4684ddb6SLionel Sambuc
374*4684ddb6SLionel Sambuctemplate <bool _B0, bool ... _Bp>
375*4684ddb6SLionel Sambucstruct __all<_B0, _Bp...>
376*4684ddb6SLionel Sambuc{
377*4684ddb6SLionel Sambuc    static const bool value = _B0 && __all<_Bp...>::value;
378*4684ddb6SLionel Sambuc};
379*4684ddb6SLionel Sambuc
380*4684ddb6SLionel Sambuc// __tuple_impl
381*4684ddb6SLionel Sambuc
382*4684ddb6SLionel Sambuctemplate<class _Indx, class ..._Tp> struct __tuple_impl;
383*4684ddb6SLionel Sambuc
384*4684ddb6SLionel Sambuctemplate<size_t ..._Indx, class ..._Tp>
385*4684ddb6SLionel Sambucstruct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
386*4684ddb6SLionel Sambuc    : public __tuple_leaf<_Indx, _Tp>...
387*4684ddb6SLionel Sambuc{
388*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
389*4684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR __tuple_impl()
390*4684ddb6SLionel Sambuc        _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
391*4684ddb6SLionel Sambuc
392*4684ddb6SLionel Sambuc    template <size_t ..._Uf, class ..._Tf,
393*4684ddb6SLionel Sambuc              size_t ..._Ul, class ..._Tl, class ..._Up>
394*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
395*4684ddb6SLionel Sambuc        explicit
396*4684ddb6SLionel Sambuc        __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
397*4684ddb6SLionel Sambuc                     __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
398*4684ddb6SLionel Sambuc                     _Up&&... __u)
399*4684ddb6SLionel Sambuc                     _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
400*4684ddb6SLionel Sambuc                                 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
401*4684ddb6SLionel Sambuc            __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
402*4684ddb6SLionel Sambuc            __tuple_leaf<_Ul, _Tl>()...
403*4684ddb6SLionel Sambuc            {}
404*4684ddb6SLionel Sambuc
405*4684ddb6SLionel Sambuc    template <class _Alloc, size_t ..._Uf, class ..._Tf,
406*4684ddb6SLionel Sambuc              size_t ..._Ul, class ..._Tl, class ..._Up>
407*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
408*4684ddb6SLionel Sambuc        explicit
409*4684ddb6SLionel Sambuc        __tuple_impl(allocator_arg_t, const _Alloc& __a,
410*4684ddb6SLionel Sambuc                     __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
411*4684ddb6SLionel Sambuc                     __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
412*4684ddb6SLionel Sambuc                     _Up&&... __u) :
413*4684ddb6SLionel Sambuc            __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
414*4684ddb6SLionel Sambuc            _VSTD::forward<_Up>(__u))...,
415*4684ddb6SLionel Sambuc            __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
416*4684ddb6SLionel Sambuc            {}
417*4684ddb6SLionel Sambuc
418*4684ddb6SLionel Sambuc    template <class _Tuple,
419*4684ddb6SLionel Sambuc              class = typename enable_if
420*4684ddb6SLionel Sambuc                      <
421*4684ddb6SLionel Sambuc                         __tuple_constructible<_Tuple, tuple<_Tp...> >::value
422*4684ddb6SLionel Sambuc                      >::type
423*4684ddb6SLionel Sambuc             >
424*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
425*4684ddb6SLionel Sambuc        __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
426*4684ddb6SLionel Sambuc                                       typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
427*4684ddb6SLionel Sambuc            : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
428*4684ddb6SLionel Sambuc                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
429*4684ddb6SLionel Sambuc            {}
430*4684ddb6SLionel Sambuc
431*4684ddb6SLionel Sambuc    template <class _Alloc, class _Tuple,
432*4684ddb6SLionel Sambuc              class = typename enable_if
433*4684ddb6SLionel Sambuc                      <
434*4684ddb6SLionel Sambuc                         __tuple_convertible<_Tuple, tuple<_Tp...> >::value
435*4684ddb6SLionel Sambuc                      >::type
436*4684ddb6SLionel Sambuc             >
437*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
438*4684ddb6SLionel Sambuc        __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
439*4684ddb6SLionel Sambuc            : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
440*4684ddb6SLionel Sambuc                                       typename __make_tuple_types<_Tuple>::type>::type>(), __a,
441*4684ddb6SLionel Sambuc                                       _VSTD::forward<typename tuple_element<_Indx,
442*4684ddb6SLionel Sambuc                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
443*4684ddb6SLionel Sambuc            {}
444*4684ddb6SLionel Sambuc
445*4684ddb6SLionel Sambuc    template <class _Tuple>
446*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
447*4684ddb6SLionel Sambuc        typename enable_if
448*4684ddb6SLionel Sambuc        <
449*4684ddb6SLionel Sambuc            __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
450*4684ddb6SLionel Sambuc            __tuple_impl&
451*4684ddb6SLionel Sambuc        >::type
452*4684ddb6SLionel Sambuc        operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
453*4684ddb6SLionel Sambuc                                       typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
454*4684ddb6SLionel Sambuc        {
455*4684ddb6SLionel Sambuc            __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
456*4684ddb6SLionel Sambuc                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
457*4684ddb6SLionel Sambuc            return *this;
458*4684ddb6SLionel Sambuc        }
459*4684ddb6SLionel Sambuc
460*4684ddb6SLionel Sambuc    __tuple_impl(const __tuple_impl&) = default;
461*4684ddb6SLionel Sambuc    __tuple_impl(__tuple_impl&&) = default;
462*4684ddb6SLionel Sambuc
463*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
464*4684ddb6SLionel Sambuc    __tuple_impl&
465*4684ddb6SLionel Sambuc    operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
466*4684ddb6SLionel Sambuc    {
467*4684ddb6SLionel Sambuc        __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
468*4684ddb6SLionel Sambuc        return *this;
469*4684ddb6SLionel Sambuc    }
470*4684ddb6SLionel Sambuc
471*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
472*4684ddb6SLionel Sambuc    __tuple_impl&
473*4684ddb6SLionel Sambuc    operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
474*4684ddb6SLionel Sambuc    {
475*4684ddb6SLionel Sambuc        __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
476*4684ddb6SLionel Sambuc        return *this;
477*4684ddb6SLionel Sambuc    }
478*4684ddb6SLionel Sambuc
479*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
480*4684ddb6SLionel Sambuc    void swap(__tuple_impl& __t)
481*4684ddb6SLionel Sambuc        _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
482*4684ddb6SLionel Sambuc    {
483*4684ddb6SLionel Sambuc        __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
484*4684ddb6SLionel Sambuc    }
485*4684ddb6SLionel Sambuc};
486*4684ddb6SLionel Sambuc
487*4684ddb6SLionel Sambuctemplate <class ..._Tp>
488*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY tuple
489*4684ddb6SLionel Sambuc{
490*4684ddb6SLionel Sambuc    typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
491*4684ddb6SLionel Sambuc
492*4684ddb6SLionel Sambuc    base base_;
493*4684ddb6SLionel Sambuc
494*4684ddb6SLionel Sambuc    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
495*4684ddb6SLionel Sambuc        typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
496*4684ddb6SLionel Sambuc    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
497*4684ddb6SLionel Sambuc        const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
498*4684ddb6SLionel Sambuc    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
499*4684ddb6SLionel Sambuc        typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
500*4684ddb6SLionel Sambucpublic:
501*4684ddb6SLionel Sambuc
502*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
503*4684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR tuple()
504*4684ddb6SLionel Sambuc        _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
505*4684ddb6SLionel Sambuc
506*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
507*4684ddb6SLionel Sambuc    explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
508*4684ddb6SLionel Sambuc        : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
509*4684ddb6SLionel Sambuc                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
510*4684ddb6SLionel Sambuc                typename __make_tuple_indices<0>::type(),
511*4684ddb6SLionel Sambuc                typename __make_tuple_types<tuple, 0>::type(),
512*4684ddb6SLionel Sambuc                __t...
513*4684ddb6SLionel Sambuc               ) {}
514*4684ddb6SLionel Sambuc
515*4684ddb6SLionel Sambuc    template <class _Alloc>
516*4684ddb6SLionel Sambuc      _LIBCPP_INLINE_VISIBILITY
517*4684ddb6SLionel Sambuc      tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
518*4684ddb6SLionel Sambuc        : base_(allocator_arg_t(), __a,
519*4684ddb6SLionel Sambuc                typename __make_tuple_indices<sizeof...(_Tp)>::type(),
520*4684ddb6SLionel Sambuc                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
521*4684ddb6SLionel Sambuc                typename __make_tuple_indices<0>::type(),
522*4684ddb6SLionel Sambuc                typename __make_tuple_types<tuple, 0>::type(),
523*4684ddb6SLionel Sambuc                __t...
524*4684ddb6SLionel Sambuc               ) {}
525*4684ddb6SLionel Sambuc
526*4684ddb6SLionel Sambuc    template <class ..._Up,
527*4684ddb6SLionel Sambuc              typename enable_if
528*4684ddb6SLionel Sambuc                      <
529*4684ddb6SLionel Sambuc                         sizeof...(_Up) <= sizeof...(_Tp) &&
530*4684ddb6SLionel Sambuc                         __tuple_convertible
531*4684ddb6SLionel Sambuc                         <
532*4684ddb6SLionel Sambuc                            tuple<_Up...>,
533*4684ddb6SLionel Sambuc                            typename __make_tuple_types<tuple,
534*4684ddb6SLionel Sambuc                                     sizeof...(_Up) < sizeof...(_Tp) ?
535*4684ddb6SLionel Sambuc                                        sizeof...(_Up) :
536*4684ddb6SLionel Sambuc                                        sizeof...(_Tp)>::type
537*4684ddb6SLionel Sambuc                         >::value,
538*4684ddb6SLionel Sambuc                         bool
539*4684ddb6SLionel Sambuc                      >::type = false
540*4684ddb6SLionel Sambuc             >
541*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
542*4684ddb6SLionel Sambuc        tuple(_Up&&... __u)
543*4684ddb6SLionel Sambuc            _NOEXCEPT_((
544*4684ddb6SLionel Sambuc                is_nothrow_constructible<
545*4684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Up)>::type,
546*4684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
547*4684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
548*4684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
549*4684ddb6SLionel Sambuc                    _Up...
550*4684ddb6SLionel Sambuc                >::value
551*4684ddb6SLionel Sambuc            ))
552*4684ddb6SLionel Sambuc            : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
553*4684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
554*4684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
555*4684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
556*4684ddb6SLionel Sambuc                    _VSTD::forward<_Up>(__u)...) {}
557*4684ddb6SLionel Sambuc
558*4684ddb6SLionel Sambuc    template <class ..._Up,
559*4684ddb6SLionel Sambuc              typename enable_if
560*4684ddb6SLionel Sambuc                      <
561*4684ddb6SLionel Sambuc                         sizeof...(_Up) <= sizeof...(_Tp) &&
562*4684ddb6SLionel Sambuc                         __tuple_constructible
563*4684ddb6SLionel Sambuc                         <
564*4684ddb6SLionel Sambuc                            tuple<_Up...>,
565*4684ddb6SLionel Sambuc                            typename __make_tuple_types<tuple,
566*4684ddb6SLionel Sambuc                                     sizeof...(_Up) < sizeof...(_Tp) ?
567*4684ddb6SLionel Sambuc                                        sizeof...(_Up) :
568*4684ddb6SLionel Sambuc                                        sizeof...(_Tp)>::type
569*4684ddb6SLionel Sambuc                         >::value &&
570*4684ddb6SLionel Sambuc                         !__tuple_convertible
571*4684ddb6SLionel Sambuc                         <
572*4684ddb6SLionel Sambuc                            tuple<_Up...>,
573*4684ddb6SLionel Sambuc                            typename __make_tuple_types<tuple,
574*4684ddb6SLionel Sambuc                                     sizeof...(_Up) < sizeof...(_Tp) ?
575*4684ddb6SLionel Sambuc                                        sizeof...(_Up) :
576*4684ddb6SLionel Sambuc                                        sizeof...(_Tp)>::type
577*4684ddb6SLionel Sambuc                         >::value,
578*4684ddb6SLionel Sambuc                         bool
579*4684ddb6SLionel Sambuc                      >::type =false
580*4684ddb6SLionel Sambuc             >
581*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
582*4684ddb6SLionel Sambuc        explicit
583*4684ddb6SLionel Sambuc        tuple(_Up&&... __u)
584*4684ddb6SLionel Sambuc            _NOEXCEPT_((
585*4684ddb6SLionel Sambuc                is_nothrow_constructible<
586*4684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Up)>::type,
587*4684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
588*4684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
589*4684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
590*4684ddb6SLionel Sambuc                    _Up...
591*4684ddb6SLionel Sambuc                >::value
592*4684ddb6SLionel Sambuc            ))
593*4684ddb6SLionel Sambuc            : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
594*4684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
595*4684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
596*4684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
597*4684ddb6SLionel Sambuc                    _VSTD::forward<_Up>(__u)...) {}
598*4684ddb6SLionel Sambuc
599*4684ddb6SLionel Sambuc    template <class _Alloc, class ..._Up,
600*4684ddb6SLionel Sambuc              class = typename enable_if
601*4684ddb6SLionel Sambuc                      <
602*4684ddb6SLionel Sambuc                         sizeof...(_Up) <= sizeof...(_Tp) &&
603*4684ddb6SLionel Sambuc                         __tuple_convertible
604*4684ddb6SLionel Sambuc                         <
605*4684ddb6SLionel Sambuc                            tuple<_Up...>,
606*4684ddb6SLionel Sambuc                            typename __make_tuple_types<tuple,
607*4684ddb6SLionel Sambuc                                     sizeof...(_Up) < sizeof...(_Tp) ?
608*4684ddb6SLionel Sambuc                                        sizeof...(_Up) :
609*4684ddb6SLionel Sambuc                                        sizeof...(_Tp)>::type
610*4684ddb6SLionel Sambuc                         >::value
611*4684ddb6SLionel Sambuc                      >::type
612*4684ddb6SLionel Sambuc             >
613*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
614*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
615*4684ddb6SLionel Sambuc            : base_(allocator_arg_t(), __a,
616*4684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Up)>::type(),
617*4684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
618*4684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
619*4684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
620*4684ddb6SLionel Sambuc                    _VSTD::forward<_Up>(__u)...) {}
621*4684ddb6SLionel Sambuc
622*4684ddb6SLionel Sambuc    template <class _Tuple,
623*4684ddb6SLionel Sambuc              typename enable_if
624*4684ddb6SLionel Sambuc                      <
625*4684ddb6SLionel Sambuc                         __tuple_convertible<_Tuple, tuple>::value,
626*4684ddb6SLionel Sambuc                         bool
627*4684ddb6SLionel Sambuc                      >::type = false
628*4684ddb6SLionel Sambuc             >
629*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
630*4684ddb6SLionel Sambuc        tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
631*4684ddb6SLionel Sambuc            : base_(_VSTD::forward<_Tuple>(__t)) {}
632*4684ddb6SLionel Sambuc
633*4684ddb6SLionel Sambuc    template <class _Tuple,
634*4684ddb6SLionel Sambuc              typename enable_if
635*4684ddb6SLionel Sambuc                      <
636*4684ddb6SLionel Sambuc                         __tuple_constructible<_Tuple, tuple>::value &&
637*4684ddb6SLionel Sambuc                         !__tuple_convertible<_Tuple, tuple>::value,
638*4684ddb6SLionel Sambuc                         bool
639*4684ddb6SLionel Sambuc                      >::type = false
640*4684ddb6SLionel Sambuc             >
641*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
642*4684ddb6SLionel Sambuc        explicit
643*4684ddb6SLionel Sambuc        tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
644*4684ddb6SLionel Sambuc            : base_(_VSTD::forward<_Tuple>(__t)) {}
645*4684ddb6SLionel Sambuc
646*4684ddb6SLionel Sambuc    template <class _Alloc, class _Tuple,
647*4684ddb6SLionel Sambuc              class = typename enable_if
648*4684ddb6SLionel Sambuc                      <
649*4684ddb6SLionel Sambuc                         __tuple_convertible<_Tuple, tuple>::value
650*4684ddb6SLionel Sambuc                      >::type
651*4684ddb6SLionel Sambuc             >
652*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
653*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
654*4684ddb6SLionel Sambuc            : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
655*4684ddb6SLionel Sambuc
656*4684ddb6SLionel Sambuc    template <class _Tuple,
657*4684ddb6SLionel Sambuc              class = typename enable_if
658*4684ddb6SLionel Sambuc                      <
659*4684ddb6SLionel Sambuc                         __tuple_assignable<_Tuple, tuple>::value
660*4684ddb6SLionel Sambuc                      >::type
661*4684ddb6SLionel Sambuc             >
662*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
663*4684ddb6SLionel Sambuc        tuple&
664*4684ddb6SLionel Sambuc        operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value))
665*4684ddb6SLionel Sambuc        {
666*4684ddb6SLionel Sambuc            base_.operator=(_VSTD::forward<_Tuple>(__t));
667*4684ddb6SLionel Sambuc            return *this;
668*4684ddb6SLionel Sambuc        }
669*4684ddb6SLionel Sambuc
670*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
671*4684ddb6SLionel Sambuc    void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
672*4684ddb6SLionel Sambuc        {base_.swap(__t.base_);}
673*4684ddb6SLionel Sambuc};
674*4684ddb6SLionel Sambuc
675*4684ddb6SLionel Sambuctemplate <>
676*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY tuple<>
677*4684ddb6SLionel Sambuc{
678*4684ddb6SLionel Sambucpublic:
679*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
680*4684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
681*4684ddb6SLionel Sambuc    template <class _Alloc>
682*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
683*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
684*4684ddb6SLionel Sambuc    template <class _Alloc>
685*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
686*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
687*4684ddb6SLionel Sambuc    template <class _Up>
688*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
689*4684ddb6SLionel Sambuc        tuple(array<_Up, 0>) _NOEXCEPT {}
690*4684ddb6SLionel Sambuc    template <class _Alloc, class _Up>
691*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
692*4684ddb6SLionel Sambuc        tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
693*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
694*4684ddb6SLionel Sambuc    void swap(tuple&) _NOEXCEPT {}
695*4684ddb6SLionel Sambuc};
696*4684ddb6SLionel Sambuc
697*4684ddb6SLionel Sambuctemplate <class ..._Tp>
698*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
699*4684ddb6SLionel Sambuctypename enable_if
700*4684ddb6SLionel Sambuc<
701*4684ddb6SLionel Sambuc    __all<__is_swappable<_Tp>::value...>::value,
702*4684ddb6SLionel Sambuc    void
703*4684ddb6SLionel Sambuc>::type
704*4684ddb6SLionel Sambucswap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
705*4684ddb6SLionel Sambuc                 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
706*4684ddb6SLionel Sambuc    {__t.swap(__u);}
707*4684ddb6SLionel Sambuc
708*4684ddb6SLionel Sambuc// get
709*4684ddb6SLionel Sambuc
710*4684ddb6SLionel Sambuctemplate <size_t _Ip, class ..._Tp>
711*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
712*4684ddb6SLionel Sambuctypename tuple_element<_Ip, tuple<_Tp...> >::type&
713*4684ddb6SLionel Sambucget(tuple<_Tp...>& __t) _NOEXCEPT
714*4684ddb6SLionel Sambuc{
715*4684ddb6SLionel Sambuc    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
716*4684ddb6SLionel Sambuc    return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get();
717*4684ddb6SLionel Sambuc}
718*4684ddb6SLionel Sambuc
719*4684ddb6SLionel Sambuctemplate <size_t _Ip, class ..._Tp>
720*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
721*4684ddb6SLionel Sambucconst typename tuple_element<_Ip, tuple<_Tp...> >::type&
722*4684ddb6SLionel Sambucget(const tuple<_Tp...>& __t) _NOEXCEPT
723*4684ddb6SLionel Sambuc{
724*4684ddb6SLionel Sambuc    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
725*4684ddb6SLionel Sambuc    return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
726*4684ddb6SLionel Sambuc}
727*4684ddb6SLionel Sambuc
728*4684ddb6SLionel Sambuctemplate <size_t _Ip, class ..._Tp>
729*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
730*4684ddb6SLionel Sambuctypename tuple_element<_Ip, tuple<_Tp...> >::type&&
731*4684ddb6SLionel Sambucget(tuple<_Tp...>&& __t) _NOEXCEPT
732*4684ddb6SLionel Sambuc{
733*4684ddb6SLionel Sambuc    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
734*4684ddb6SLionel Sambuc    return static_cast<type&&>(
735*4684ddb6SLionel Sambuc             static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
736*4684ddb6SLionel Sambuc}
737*4684ddb6SLionel Sambuc
738*4684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
739*4684ddb6SLionel Sambuc// get by type
740*4684ddb6SLionel Sambuctemplate <typename _T1, size_t _Idx, typename... _Args>
741*4684ddb6SLionel Sambucstruct __find_exactly_one_t_helper;
742*4684ddb6SLionel Sambuc
743*4684ddb6SLionel Sambuc// -- find exactly one
744*4684ddb6SLionel Sambuctemplate <typename _T1, size_t _Idx, typename... _Args>
745*4684ddb6SLionel Sambucstruct __find_exactly_one_t_checker {
746*4684ddb6SLionel Sambuc    static constexpr size_t value = _Idx;
747*4684ddb6SLionel Sambuc//  Check the rest of the list to make sure there's only one
748*4684ddb6SLionel Sambuc    static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" );
749*4684ddb6SLionel Sambuc    };
750*4684ddb6SLionel Sambuc
751*4684ddb6SLionel Sambuc
752*4684ddb6SLionel Sambuctemplate <typename _T1, size_t _Idx>
753*4684ddb6SLionel Sambucstruct __find_exactly_one_t_helper <_T1, _Idx> {
754*4684ddb6SLionel Sambuc    static constexpr size_t value = -1;
755*4684ddb6SLionel Sambuc    };
756*4684ddb6SLionel Sambuc
757*4684ddb6SLionel Sambuctemplate <typename _T1, size_t _Idx, typename _Head, typename... _Args>
758*4684ddb6SLionel Sambucstruct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> {
759*4684ddb6SLionel Sambuc    static constexpr size_t value =
760*4684ddb6SLionel Sambuc        std::conditional<
761*4684ddb6SLionel Sambuc            std::is_same<_T1, _Head>::value,
762*4684ddb6SLionel Sambuc            __find_exactly_one_t_checker<_T1, _Idx,   _Args...>,
763*4684ddb6SLionel Sambuc            __find_exactly_one_t_helper <_T1, _Idx+1, _Args...>
764*4684ddb6SLionel Sambuc        >::type::value;
765*4684ddb6SLionel Sambuc    };
766*4684ddb6SLionel Sambuc
767*4684ddb6SLionel Sambuctemplate <typename _T1, typename... _Args>
768*4684ddb6SLionel Sambucstruct __find_exactly_one_t {
769*4684ddb6SLionel Sambuc    static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value;
770*4684ddb6SLionel Sambuc    static_assert ( value != -1, "type not found in type list" );
771*4684ddb6SLionel Sambuc    };
772*4684ddb6SLionel Sambuc
773*4684ddb6SLionel Sambuctemplate <class _T1, class... _Args>
774*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
775*4684ddb6SLionel Sambucconstexpr _T1& get(tuple<_Args...>& __tup) noexcept
776*4684ddb6SLionel Sambuc{
777*4684ddb6SLionel Sambuc    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
778*4684ddb6SLionel Sambuc}
779*4684ddb6SLionel Sambuc
780*4684ddb6SLionel Sambuctemplate <class _T1, class... _Args>
781*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
782*4684ddb6SLionel Sambucconstexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
783*4684ddb6SLionel Sambuc{
784*4684ddb6SLionel Sambuc    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
785*4684ddb6SLionel Sambuc}
786*4684ddb6SLionel Sambuc
787*4684ddb6SLionel Sambuctemplate <class _T1, class... _Args>
788*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
789*4684ddb6SLionel Sambucconstexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
790*4684ddb6SLionel Sambuc{
791*4684ddb6SLionel Sambuc    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
792*4684ddb6SLionel Sambuc}
793*4684ddb6SLionel Sambuc
794*4684ddb6SLionel Sambuc#endif
795*4684ddb6SLionel Sambuc
796*4684ddb6SLionel Sambuc// tie
797*4684ddb6SLionel Sambuc
798*4684ddb6SLionel Sambuctemplate <class ..._Tp>
799*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
800*4684ddb6SLionel Sambuctuple<_Tp&...>
801*4684ddb6SLionel Sambuctie(_Tp&... __t) _NOEXCEPT
802*4684ddb6SLionel Sambuc{
803*4684ddb6SLionel Sambuc    return tuple<_Tp&...>(__t...);
804*4684ddb6SLionel Sambuc}
805*4684ddb6SLionel Sambuc
806*4684ddb6SLionel Sambuctemplate <class _Up>
807*4684ddb6SLionel Sambucstruct __ignore_t
808*4684ddb6SLionel Sambuc{
809*4684ddb6SLionel Sambuc    template <class _Tp>
810*4684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
811*4684ddb6SLionel Sambuc        const __ignore_t& operator=(_Tp&&) const {return *this;}
812*4684ddb6SLionel Sambuc};
813*4684ddb6SLionel Sambuc
814*4684ddb6SLionel Sambucnamespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
815*4684ddb6SLionel Sambuc
816*4684ddb6SLionel Sambuctemplate <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
817*4684ddb6SLionel Sambuc
818*4684ddb6SLionel Sambuctemplate <class _Tp>
819*4684ddb6SLionel Sambucstruct ___make_tuple_return
820*4684ddb6SLionel Sambuc{
821*4684ddb6SLionel Sambuc    typedef _Tp type;
822*4684ddb6SLionel Sambuc};
823*4684ddb6SLionel Sambuc
824*4684ddb6SLionel Sambuctemplate <class _Tp>
825*4684ddb6SLionel Sambucstruct ___make_tuple_return<reference_wrapper<_Tp> >
826*4684ddb6SLionel Sambuc{
827*4684ddb6SLionel Sambuc    typedef _Tp& type;
828*4684ddb6SLionel Sambuc};
829*4684ddb6SLionel Sambuc
830*4684ddb6SLionel Sambuctemplate <class _Tp>
831*4684ddb6SLionel Sambucstruct __make_tuple_return
832*4684ddb6SLionel Sambuc{
833*4684ddb6SLionel Sambuc    typedef typename ___make_tuple_return<typename decay<_Tp>::type>::type type;
834*4684ddb6SLionel Sambuc};
835*4684ddb6SLionel Sambuc
836*4684ddb6SLionel Sambuctemplate <class... _Tp>
837*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
838*4684ddb6SLionel Sambuctuple<typename __make_tuple_return<_Tp>::type...>
839*4684ddb6SLionel Sambucmake_tuple(_Tp&&... __t)
840*4684ddb6SLionel Sambuc{
841*4684ddb6SLionel Sambuc    return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
842*4684ddb6SLionel Sambuc}
843*4684ddb6SLionel Sambuc
844*4684ddb6SLionel Sambuctemplate <class... _Tp>
845*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
846*4684ddb6SLionel Sambuctuple<_Tp&&...>
847*4684ddb6SLionel Sambucforward_as_tuple(_Tp&&... __t) _NOEXCEPT
848*4684ddb6SLionel Sambuc{
849*4684ddb6SLionel Sambuc    return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
850*4684ddb6SLionel Sambuc}
851*4684ddb6SLionel Sambuc
852*4684ddb6SLionel Sambuctemplate <size_t _Ip>
853*4684ddb6SLionel Sambucstruct __tuple_equal
854*4684ddb6SLionel Sambuc{
855*4684ddb6SLionel Sambuc    template <class _Tp, class _Up>
856*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
857*4684ddb6SLionel Sambuc    bool operator()(const _Tp& __x, const _Up& __y)
858*4684ddb6SLionel Sambuc    {
859*4684ddb6SLionel Sambuc        return __tuple_equal<_Ip - 1>()(__x, __y) && get<_Ip-1>(__x) == get<_Ip-1>(__y);
860*4684ddb6SLionel Sambuc    }
861*4684ddb6SLionel Sambuc};
862*4684ddb6SLionel Sambuc
863*4684ddb6SLionel Sambuctemplate <>
864*4684ddb6SLionel Sambucstruct __tuple_equal<0>
865*4684ddb6SLionel Sambuc{
866*4684ddb6SLionel Sambuc    template <class _Tp, class _Up>
867*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
868*4684ddb6SLionel Sambuc    bool operator()(const _Tp&, const _Up&)
869*4684ddb6SLionel Sambuc    {
870*4684ddb6SLionel Sambuc        return true;
871*4684ddb6SLionel Sambuc    }
872*4684ddb6SLionel Sambuc};
873*4684ddb6SLionel Sambuc
874*4684ddb6SLionel Sambuctemplate <class ..._Tp, class ..._Up>
875*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
876*4684ddb6SLionel Sambucbool
877*4684ddb6SLionel Sambucoperator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
878*4684ddb6SLionel Sambuc{
879*4684ddb6SLionel Sambuc    return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
880*4684ddb6SLionel Sambuc}
881*4684ddb6SLionel Sambuc
882*4684ddb6SLionel Sambuctemplate <class ..._Tp, class ..._Up>
883*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
884*4684ddb6SLionel Sambucbool
885*4684ddb6SLionel Sambucoperator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
886*4684ddb6SLionel Sambuc{
887*4684ddb6SLionel Sambuc    return !(__x == __y);
888*4684ddb6SLionel Sambuc}
889*4684ddb6SLionel Sambuc
890*4684ddb6SLionel Sambuctemplate <size_t _Ip>
891*4684ddb6SLionel Sambucstruct __tuple_less
892*4684ddb6SLionel Sambuc{
893*4684ddb6SLionel Sambuc    template <class _Tp, class _Up>
894*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
895*4684ddb6SLionel Sambuc    bool operator()(const _Tp& __x, const _Up& __y)
896*4684ddb6SLionel Sambuc    {
897*4684ddb6SLionel Sambuc        return __tuple_less<_Ip-1>()(__x, __y) ||
898*4684ddb6SLionel Sambuc             (!__tuple_less<_Ip-1>()(__y, __x) && get<_Ip-1>(__x) < get<_Ip-1>(__y));
899*4684ddb6SLionel Sambuc    }
900*4684ddb6SLionel Sambuc};
901*4684ddb6SLionel Sambuc
902*4684ddb6SLionel Sambuctemplate <>
903*4684ddb6SLionel Sambucstruct __tuple_less<0>
904*4684ddb6SLionel Sambuc{
905*4684ddb6SLionel Sambuc    template <class _Tp, class _Up>
906*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
907*4684ddb6SLionel Sambuc    bool operator()(const _Tp&, const _Up&)
908*4684ddb6SLionel Sambuc    {
909*4684ddb6SLionel Sambuc        return false;
910*4684ddb6SLionel Sambuc    }
911*4684ddb6SLionel Sambuc};
912*4684ddb6SLionel Sambuc
913*4684ddb6SLionel Sambuctemplate <class ..._Tp, class ..._Up>
914*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
915*4684ddb6SLionel Sambucbool
916*4684ddb6SLionel Sambucoperator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
917*4684ddb6SLionel Sambuc{
918*4684ddb6SLionel Sambuc    return __tuple_less<sizeof...(_Tp)>()(__x, __y);
919*4684ddb6SLionel Sambuc}
920*4684ddb6SLionel Sambuc
921*4684ddb6SLionel Sambuctemplate <class ..._Tp, class ..._Up>
922*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
923*4684ddb6SLionel Sambucbool
924*4684ddb6SLionel Sambucoperator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
925*4684ddb6SLionel Sambuc{
926*4684ddb6SLionel Sambuc    return __y < __x;
927*4684ddb6SLionel Sambuc}
928*4684ddb6SLionel Sambuc
929*4684ddb6SLionel Sambuctemplate <class ..._Tp, class ..._Up>
930*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
931*4684ddb6SLionel Sambucbool
932*4684ddb6SLionel Sambucoperator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
933*4684ddb6SLionel Sambuc{
934*4684ddb6SLionel Sambuc    return !(__x < __y);
935*4684ddb6SLionel Sambuc}
936*4684ddb6SLionel Sambuc
937*4684ddb6SLionel Sambuctemplate <class ..._Tp, class ..._Up>
938*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
939*4684ddb6SLionel Sambucbool
940*4684ddb6SLionel Sambucoperator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
941*4684ddb6SLionel Sambuc{
942*4684ddb6SLionel Sambuc    return !(__y < __x);
943*4684ddb6SLionel Sambuc}
944*4684ddb6SLionel Sambuc
945*4684ddb6SLionel Sambuc// tuple_cat
946*4684ddb6SLionel Sambuc
947*4684ddb6SLionel Sambuctemplate <class _Tp, class _Up> struct __tuple_cat_type;
948*4684ddb6SLionel Sambuc
949*4684ddb6SLionel Sambuctemplate <class ..._Ttypes, class ..._Utypes>
950*4684ddb6SLionel Sambucstruct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
951*4684ddb6SLionel Sambuc{
952*4684ddb6SLionel Sambuc    typedef tuple<_Ttypes..., _Utypes...> type;
953*4684ddb6SLionel Sambuc};
954*4684ddb6SLionel Sambuc
955*4684ddb6SLionel Sambuctemplate <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
956*4684ddb6SLionel Sambucstruct __tuple_cat_return_1
957*4684ddb6SLionel Sambuc{
958*4684ddb6SLionel Sambuc};
959*4684ddb6SLionel Sambuc
960*4684ddb6SLionel Sambuctemplate <class ..._Types, class _Tuple0>
961*4684ddb6SLionel Sambucstruct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
962*4684ddb6SLionel Sambuc{
963*4684ddb6SLionel Sambuc    typedef typename __tuple_cat_type<tuple<_Types...>,
964*4684ddb6SLionel Sambuc            typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
965*4684ddb6SLionel Sambuc                                                                           type;
966*4684ddb6SLionel Sambuc};
967*4684ddb6SLionel Sambuc
968*4684ddb6SLionel Sambuctemplate <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
969*4684ddb6SLionel Sambucstruct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
970*4684ddb6SLionel Sambuc    : public __tuple_cat_return_1<
971*4684ddb6SLionel Sambuc                 typename __tuple_cat_type<
972*4684ddb6SLionel Sambuc                     tuple<_Types...>,
973*4684ddb6SLionel Sambuc                     typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
974*4684ddb6SLionel Sambuc                 >::type,
975*4684ddb6SLionel Sambuc                 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
976*4684ddb6SLionel Sambuc                 _Tuple1, _Tuples...>
977*4684ddb6SLionel Sambuc{
978*4684ddb6SLionel Sambuc};
979*4684ddb6SLionel Sambuc
980*4684ddb6SLionel Sambuctemplate <class ..._Tuples> struct __tuple_cat_return;
981*4684ddb6SLionel Sambuc
982*4684ddb6SLionel Sambuctemplate <class _Tuple0, class ..._Tuples>
983*4684ddb6SLionel Sambucstruct __tuple_cat_return<_Tuple0, _Tuples...>
984*4684ddb6SLionel Sambuc    : public __tuple_cat_return_1<tuple<>,
985*4684ddb6SLionel Sambuc         __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
986*4684ddb6SLionel Sambuc                                                                     _Tuples...>
987*4684ddb6SLionel Sambuc{
988*4684ddb6SLionel Sambuc};
989*4684ddb6SLionel Sambuc
990*4684ddb6SLionel Sambuctemplate <>
991*4684ddb6SLionel Sambucstruct __tuple_cat_return<>
992*4684ddb6SLionel Sambuc{
993*4684ddb6SLionel Sambuc    typedef tuple<> type;
994*4684ddb6SLionel Sambuc};
995*4684ddb6SLionel Sambuc
996*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
997*4684ddb6SLionel Sambuctuple<>
998*4684ddb6SLionel Sambuctuple_cat()
999*4684ddb6SLionel Sambuc{
1000*4684ddb6SLionel Sambuc    return tuple<>();
1001*4684ddb6SLionel Sambuc}
1002*4684ddb6SLionel Sambuc
1003*4684ddb6SLionel Sambuctemplate <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
1004*4684ddb6SLionel Sambucstruct __tuple_cat_return_ref_imp;
1005*4684ddb6SLionel Sambuc
1006*4684ddb6SLionel Sambuctemplate <class ..._Types, size_t ..._I0, class _Tuple0>
1007*4684ddb6SLionel Sambucstruct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
1008*4684ddb6SLionel Sambuc{
1009*4684ddb6SLionel Sambuc    typedef typename remove_reference<_Tuple0>::type _T0;
1010*4684ddb6SLionel Sambuc    typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1011*4684ddb6SLionel Sambuc                          typename tuple_element<_I0, _T0>::type>::type&&...> type;
1012*4684ddb6SLionel Sambuc};
1013*4684ddb6SLionel Sambuc
1014*4684ddb6SLionel Sambuctemplate <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1015*4684ddb6SLionel Sambucstruct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1016*4684ddb6SLionel Sambuc                                  _Tuple0, _Tuple1, _Tuples...>
1017*4684ddb6SLionel Sambuc    : public __tuple_cat_return_ref_imp<
1018*4684ddb6SLionel Sambuc         tuple<_Types..., typename __apply_cv<_Tuple0,
1019*4684ddb6SLionel Sambuc               typename tuple_element<_I0,
1020*4684ddb6SLionel Sambuc                  typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1021*4684ddb6SLionel Sambuc         typename __make_tuple_indices<tuple_size<typename
1022*4684ddb6SLionel Sambuc                                 remove_reference<_Tuple1>::type>::value>::type,
1023*4684ddb6SLionel Sambuc         _Tuple1, _Tuples...>
1024*4684ddb6SLionel Sambuc{
1025*4684ddb6SLionel Sambuc};
1026*4684ddb6SLionel Sambuc
1027*4684ddb6SLionel Sambuctemplate <class _Tuple0, class ..._Tuples>
1028*4684ddb6SLionel Sambucstruct __tuple_cat_return_ref
1029*4684ddb6SLionel Sambuc    : public __tuple_cat_return_ref_imp<tuple<>,
1030*4684ddb6SLionel Sambuc               typename __make_tuple_indices<
1031*4684ddb6SLionel Sambuc                        tuple_size<typename remove_reference<_Tuple0>::type>::value
1032*4684ddb6SLionel Sambuc               >::type, _Tuple0, _Tuples...>
1033*4684ddb6SLionel Sambuc{
1034*4684ddb6SLionel Sambuc};
1035*4684ddb6SLionel Sambuc
1036*4684ddb6SLionel Sambuctemplate <class _Types, class _I0, class _J0>
1037*4684ddb6SLionel Sambucstruct __tuple_cat;
1038*4684ddb6SLionel Sambuc
1039*4684ddb6SLionel Sambuctemplate <class ..._Types, size_t ..._I0, size_t ..._J0>
1040*4684ddb6SLionel Sambucstruct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
1041*4684ddb6SLionel Sambuc{
1042*4684ddb6SLionel Sambuc    template <class _Tuple0>
1043*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1044*4684ddb6SLionel Sambuc    typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1045*4684ddb6SLionel Sambuc    operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1046*4684ddb6SLionel Sambuc    {
1047*4684ddb6SLionel Sambuc        return forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))...,
1048*4684ddb6SLionel Sambuc                                      get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
1049*4684ddb6SLionel Sambuc    }
1050*4684ddb6SLionel Sambuc
1051*4684ddb6SLionel Sambuc    template <class _Tuple0, class _Tuple1, class ..._Tuples>
1052*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1053*4684ddb6SLionel Sambuc    typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1054*4684ddb6SLionel Sambuc    operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1055*4684ddb6SLionel Sambuc    {
1056*4684ddb6SLionel Sambuc        typedef typename remove_reference<_Tuple0>::type _T0;
1057*4684ddb6SLionel Sambuc        typedef typename remove_reference<_Tuple1>::type _T1;
1058*4684ddb6SLionel Sambuc        return __tuple_cat<
1059*4684ddb6SLionel Sambuc           tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1060*4684ddb6SLionel Sambuc           typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1061*4684ddb6SLionel Sambuc           typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
1062*4684ddb6SLionel Sambuc                           (forward_as_tuple(
1063*4684ddb6SLionel Sambuc                              _VSTD::forward<_Types>(get<_I0>(__t))...,
1064*4684ddb6SLionel Sambuc                              get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
1065*4684ddb6SLionel Sambuc                            ),
1066*4684ddb6SLionel Sambuc                            _VSTD::forward<_Tuple1>(__t1),
1067*4684ddb6SLionel Sambuc                            _VSTD::forward<_Tuples>(__tpls)...);
1068*4684ddb6SLionel Sambuc    }
1069*4684ddb6SLionel Sambuc};
1070*4684ddb6SLionel Sambuc
1071*4684ddb6SLionel Sambuctemplate <class _Tuple0, class... _Tuples>
1072*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1073*4684ddb6SLionel Sambuctypename __tuple_cat_return<_Tuple0, _Tuples...>::type
1074*4684ddb6SLionel Sambuctuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1075*4684ddb6SLionel Sambuc{
1076*4684ddb6SLionel Sambuc    typedef typename remove_reference<_Tuple0>::type _T0;
1077*4684ddb6SLionel Sambuc    return __tuple_cat<tuple<>, __tuple_indices<>,
1078*4684ddb6SLionel Sambuc                  typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
1079*4684ddb6SLionel Sambuc                  (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1080*4684ddb6SLionel Sambuc                                            _VSTD::forward<_Tuples>(__tpls)...);
1081*4684ddb6SLionel Sambuc}
1082*4684ddb6SLionel Sambuc
1083*4684ddb6SLionel Sambuctemplate <class ..._Tp, class _Alloc>
1084*4684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc>
1085*4684ddb6SLionel Sambuc    : true_type {};
1086*4684ddb6SLionel Sambuc
1087*4684ddb6SLionel Sambuctemplate <class _T1, class _T2>
1088*4684ddb6SLionel Sambuctemplate <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1089*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1090*4684ddb6SLionel Sambucpair<_T1, _T2>::pair(piecewise_construct_t,
1091*4684ddb6SLionel Sambuc                     tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1092*4684ddb6SLionel Sambuc                     __tuple_indices<_I1...>, __tuple_indices<_I2...>)
1093*4684ddb6SLionel Sambuc    :  first(_VSTD::forward<_Args1>(get<_I1>( __first_args))...),
1094*4684ddb6SLionel Sambuc      second(_VSTD::forward<_Args2>(get<_I2>(__second_args))...)
1095*4684ddb6SLionel Sambuc{
1096*4684ddb6SLionel Sambuc}
1097*4684ddb6SLionel Sambuc
1098*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_VARIADICS
1099*4684ddb6SLionel Sambuc
1100*4684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD
1101*4684ddb6SLionel Sambuc
1102*4684ddb6SLionel Sambuc#endif  // _LIBCPP_TUPLE
1103