xref: /aosp_15_r20/external/libcxx/include/tuple (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===--------------------------- tuple ------------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is distributed under the University of Illinois Open Source
7*58b9f456SAndroid Build Coastguard Worker// License. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_TUPLE
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_TUPLE
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker    tuple synopsis
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard Workernamespace std
18*58b9f456SAndroid Build Coastguard Worker{
19*58b9f456SAndroid Build Coastguard Worker
20*58b9f456SAndroid Build Coastguard Workertemplate <class... T>
21*58b9f456SAndroid Build Coastguard Workerclass tuple {
22*58b9f456SAndroid Build Coastguard Workerpublic:
23*58b9f456SAndroid Build Coastguard Worker    constexpr tuple();
24*58b9f456SAndroid Build Coastguard Worker    explicit tuple(const T&...);  // constexpr in C++14
25*58b9f456SAndroid Build Coastguard Worker    template <class... U>
26*58b9f456SAndroid Build Coastguard Worker        explicit tuple(U&&...);  // constexpr in C++14
27*58b9f456SAndroid Build Coastguard Worker    tuple(const tuple&) = default;
28*58b9f456SAndroid Build Coastguard Worker    tuple(tuple&&) = default;
29*58b9f456SAndroid Build Coastguard Worker    template <class... U>
30*58b9f456SAndroid Build Coastguard Worker        tuple(const tuple<U...>&);  // constexpr in C++14
31*58b9f456SAndroid Build Coastguard Worker    template <class... U>
32*58b9f456SAndroid Build Coastguard Worker        tuple(tuple<U...>&&);  // constexpr in C++14
33*58b9f456SAndroid Build Coastguard Worker    template <class U1, class U2>
34*58b9f456SAndroid Build Coastguard Worker        tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
35*58b9f456SAndroid Build Coastguard Worker    template <class U1, class U2>
36*58b9f456SAndroid Build Coastguard Worker        tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2  // constexpr in C++14
37*58b9f456SAndroid Build Coastguard Worker
38*58b9f456SAndroid Build Coastguard Worker    // allocator-extended constructors
39*58b9f456SAndroid Build Coastguard Worker    template <class Alloc>
40*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const Alloc& a);
41*58b9f456SAndroid Build Coastguard Worker    template <class Alloc>
42*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const Alloc& a, const T&...);
43*58b9f456SAndroid Build Coastguard Worker    template <class Alloc, class... U>
44*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const Alloc& a, U&&...);
45*58b9f456SAndroid Build Coastguard Worker    template <class Alloc>
46*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const Alloc& a, const tuple&);
47*58b9f456SAndroid Build Coastguard Worker    template <class Alloc>
48*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const Alloc& a, tuple&&);
49*58b9f456SAndroid Build Coastguard Worker    template <class Alloc, class... U>
50*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
51*58b9f456SAndroid Build Coastguard Worker    template <class Alloc, class... U>
52*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
53*58b9f456SAndroid Build Coastguard Worker    template <class Alloc, class U1, class U2>
54*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
55*58b9f456SAndroid Build Coastguard Worker    template <class Alloc, class U1, class U2>
56*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
57*58b9f456SAndroid Build Coastguard Worker
58*58b9f456SAndroid Build Coastguard Worker    tuple& operator=(const tuple&);
59*58b9f456SAndroid Build Coastguard Worker    tuple&
60*58b9f456SAndroid Build Coastguard Worker        operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
61*58b9f456SAndroid Build Coastguard Worker    template <class... U>
62*58b9f456SAndroid Build Coastguard Worker        tuple& operator=(const tuple<U...>&);
63*58b9f456SAndroid Build Coastguard Worker    template <class... U>
64*58b9f456SAndroid Build Coastguard Worker        tuple& operator=(tuple<U...>&&);
65*58b9f456SAndroid Build Coastguard Worker    template <class U1, class U2>
66*58b9f456SAndroid Build Coastguard Worker        tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
67*58b9f456SAndroid Build Coastguard Worker    template <class U1, class U2>
68*58b9f456SAndroid Build Coastguard Worker        tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2
69*58b9f456SAndroid Build Coastguard Worker
70*58b9f456SAndroid Build Coastguard Worker    void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
71*58b9f456SAndroid Build Coastguard Worker};
72*58b9f456SAndroid Build Coastguard Worker
73*58b9f456SAndroid Build Coastguard Workerinline constexpr unspecified ignore;
74*58b9f456SAndroid Build Coastguard Worker
75*58b9f456SAndroid Build Coastguard Workertemplate <class... T> tuple<V...>  make_tuple(T&&...); // constexpr in C++14
76*58b9f456SAndroid Build Coastguard Workertemplate <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
77*58b9f456SAndroid Build Coastguard Workertemplate <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
78*58b9f456SAndroid Build Coastguard Workertemplate <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
79*58b9f456SAndroid Build Coastguard Worker
80*58b9f456SAndroid Build Coastguard Worker// [tuple.apply], calling a function with a tuple of arguments:
81*58b9f456SAndroid Build Coastguard Workertemplate <class F, class Tuple>
82*58b9f456SAndroid Build Coastguard Worker  constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17
83*58b9f456SAndroid Build Coastguard Workertemplate <class T, class Tuple>
84*58b9f456SAndroid Build Coastguard Worker  constexpr T make_from_tuple(Tuple&& t); // C++17
85*58b9f456SAndroid Build Coastguard Worker
86*58b9f456SAndroid Build Coastguard Worker// 20.4.1.4, tuple helper classes:
87*58b9f456SAndroid Build Coastguard Workertemplate <class T> struct tuple_size; // undefined
88*58b9f456SAndroid Build Coastguard Workertemplate <class... T> struct tuple_size<tuple<T...>>;
89*58b9f456SAndroid Build Coastguard Workertemplate <class T>
90*58b9f456SAndroid Build Coastguard Worker inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
91*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class T> class tuple_element; // undefined
92*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class... T> class tuple_element<I, tuple<T...>>;
93*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class T>
94*58b9f456SAndroid Build Coastguard Worker  using tuple_element_t = typename tuple_element <I, T>::type; // C++14
95*58b9f456SAndroid Build Coastguard Worker
96*58b9f456SAndroid Build Coastguard Worker// 20.4.1.5, element access:
97*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class... T>
98*58b9f456SAndroid Build Coastguard Worker    typename tuple_element<I, tuple<T...>>::type&
99*58b9f456SAndroid Build Coastguard Worker    get(tuple<T...>&) noexcept; // constexpr in C++14
100*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class... T>
101*58b9f456SAndroid Build Coastguard Worker    const typename tuple_element<I, tuple<T...>>::type&
102*58b9f456SAndroid Build Coastguard Worker    get(const tuple<T...>&) noexcept; // constexpr in C++14
103*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class... T>
104*58b9f456SAndroid Build Coastguard Worker    typename tuple_element<I, tuple<T...>>::type&&
105*58b9f456SAndroid Build Coastguard Worker    get(tuple<T...>&&) noexcept; // constexpr in C++14
106*58b9f456SAndroid Build Coastguard Workertemplate <size_t I, class... T>
107*58b9f456SAndroid Build Coastguard Worker    const typename tuple_element<I, tuple<T...>>::type&&
108*58b9f456SAndroid Build Coastguard Worker    get(const tuple<T...>&&) noexcept; // constexpr in C++14
109*58b9f456SAndroid Build Coastguard Worker
110*58b9f456SAndroid Build Coastguard Workertemplate <class T1, class... T>
111*58b9f456SAndroid Build Coastguard Worker    constexpr T1& get(tuple<T...>&) noexcept;  // C++14
112*58b9f456SAndroid Build Coastguard Workertemplate <class T1, class... T>
113*58b9f456SAndroid Build Coastguard Worker    constexpr const T1& get(const tuple<T...>&) noexcept;   // C++14
114*58b9f456SAndroid Build Coastguard Workertemplate <class T1, class... T>
115*58b9f456SAndroid Build Coastguard Worker    constexpr T1&& get(tuple<T...>&&) noexcept;   // C++14
116*58b9f456SAndroid Build Coastguard Workertemplate <class T1, class... T>
117*58b9f456SAndroid Build Coastguard Worker    constexpr const T1&& get(const tuple<T...>&&) noexcept;   // C++14
118*58b9f456SAndroid Build Coastguard Worker
119*58b9f456SAndroid Build Coastguard Worker// 20.4.1.6, relational operators:
120*58b9f456SAndroid Build Coastguard Workertemplate<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
121*58b9f456SAndroid Build Coastguard Workertemplate<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&);  // constexpr in C++14
122*58b9f456SAndroid Build Coastguard Workertemplate<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
123*58b9f456SAndroid Build Coastguard Workertemplate<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&);  // constexpr in C++14
124*58b9f456SAndroid Build Coastguard Workertemplate<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
125*58b9f456SAndroid Build Coastguard Workertemplate<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
126*58b9f456SAndroid Build Coastguard Worker
127*58b9f456SAndroid Build Coastguard Workertemplate <class... Types, class Alloc>
128*58b9f456SAndroid Build Coastguard Worker  struct uses_allocator<tuple<Types...>, Alloc>;
129*58b9f456SAndroid Build Coastguard Worker
130*58b9f456SAndroid Build Coastguard Workertemplate <class... Types>
131*58b9f456SAndroid Build Coastguard Worker  void
132*58b9f456SAndroid Build Coastguard Worker  swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
133*58b9f456SAndroid Build Coastguard Worker
134*58b9f456SAndroid Build Coastguard Worker}  // std
135*58b9f456SAndroid Build Coastguard Worker
136*58b9f456SAndroid Build Coastguard Worker*/
137*58b9f456SAndroid Build Coastguard Worker
138*58b9f456SAndroid Build Coastguard Worker#include <__config>
139*58b9f456SAndroid Build Coastguard Worker#include <__tuple>
140*58b9f456SAndroid Build Coastguard Worker#include <cstddef>
141*58b9f456SAndroid Build Coastguard Worker#include <type_traits>
142*58b9f456SAndroid Build Coastguard Worker#include <__functional_base>
143*58b9f456SAndroid Build Coastguard Worker#include <utility>
144*58b9f456SAndroid Build Coastguard Worker#include <version>
145*58b9f456SAndroid Build Coastguard Worker
146*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
147*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
148*58b9f456SAndroid Build Coastguard Worker#endif
149*58b9f456SAndroid Build Coastguard Worker
150*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
151*58b9f456SAndroid Build Coastguard Worker
152*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CXX03_LANG
153*58b9f456SAndroid Build Coastguard Worker
154*58b9f456SAndroid Build Coastguard Worker
155*58b9f456SAndroid Build Coastguard Worker// __tuple_leaf
156*58b9f456SAndroid Build Coastguard Worker
157*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class _Hp,
158*58b9f456SAndroid Build Coastguard Worker          bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
159*58b9f456SAndroid Build Coastguard Worker         >
160*58b9f456SAndroid Build Coastguard Workerclass __tuple_leaf;
161*58b9f456SAndroid Build Coastguard Worker
162*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class _Hp, bool _Ep>
163*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
164*58b9f456SAndroid Build Coastguard Workervoid swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
165*58b9f456SAndroid Build Coastguard Worker    _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
166*58b9f456SAndroid Build Coastguard Worker{
167*58b9f456SAndroid Build Coastguard Worker    swap(__x.get(), __y.get());
168*58b9f456SAndroid Build Coastguard Worker}
169*58b9f456SAndroid Build Coastguard Worker
170*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class _Hp, bool>
171*58b9f456SAndroid Build Coastguard Workerclass __tuple_leaf
172*58b9f456SAndroid Build Coastguard Worker{
173*58b9f456SAndroid Build Coastguard Worker    _Hp __value_;
174*58b9f456SAndroid Build Coastguard Worker
175*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
176*58b9f456SAndroid Build Coastguard Worker    static constexpr bool __can_bind_reference() {
177*58b9f456SAndroid Build Coastguard Worker#if __has_keyword(__reference_binds_to_temporary)
178*58b9f456SAndroid Build Coastguard Worker      return !__reference_binds_to_temporary(_Hp, _Tp);
179*58b9f456SAndroid Build Coastguard Worker#else
180*58b9f456SAndroid Build Coastguard Worker      return true;
181*58b9f456SAndroid Build Coastguard Worker#endif
182*58b9f456SAndroid Build Coastguard Worker    }
183*58b9f456SAndroid Build Coastguard Worker
184*58b9f456SAndroid Build Coastguard Worker    __tuple_leaf& operator=(const __tuple_leaf&);
185*58b9f456SAndroid Build Coastguard Workerpublic:
186*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
187*58b9f456SAndroid Build Coastguard Worker             _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_()
188*58b9f456SAndroid Build Coastguard Worker       {static_assert(!is_reference<_Hp>::value,
189*58b9f456SAndroid Build Coastguard Worker              "Attempted to default construct a reference element in a tuple");}
190*58b9f456SAndroid Build Coastguard Worker
191*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc>
192*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
193*58b9f456SAndroid Build Coastguard Worker        __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
194*58b9f456SAndroid Build Coastguard Worker            : __value_()
195*58b9f456SAndroid Build Coastguard Worker        {static_assert(!is_reference<_Hp>::value,
196*58b9f456SAndroid Build Coastguard Worker              "Attempted to default construct a reference element in a tuple");}
197*58b9f456SAndroid Build Coastguard Worker
198*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc>
199*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
200*58b9f456SAndroid Build Coastguard Worker        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
201*58b9f456SAndroid Build Coastguard Worker            : __value_(allocator_arg_t(), __a)
202*58b9f456SAndroid Build Coastguard Worker        {static_assert(!is_reference<_Hp>::value,
203*58b9f456SAndroid Build Coastguard Worker              "Attempted to default construct a reference element in a tuple");}
204*58b9f456SAndroid Build Coastguard Worker
205*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc>
206*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
207*58b9f456SAndroid Build Coastguard Worker        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
208*58b9f456SAndroid Build Coastguard Worker            : __value_(__a)
209*58b9f456SAndroid Build Coastguard Worker        {static_assert(!is_reference<_Hp>::value,
210*58b9f456SAndroid Build Coastguard Worker              "Attempted to default construct a reference element in a tuple");}
211*58b9f456SAndroid Build Coastguard Worker
212*58b9f456SAndroid Build Coastguard Worker    template <class _Tp,
213*58b9f456SAndroid Build Coastguard Worker              class = typename enable_if<
214*58b9f456SAndroid Build Coastguard Worker                  __lazy_and<
215*58b9f456SAndroid Build Coastguard Worker                      __lazy_not<is_same<typename __uncvref<_Tp>::type, __tuple_leaf>>
216*58b9f456SAndroid Build Coastguard Worker                    , is_constructible<_Hp, _Tp>
217*58b9f456SAndroid Build Coastguard Worker                    >::value
218*58b9f456SAndroid Build Coastguard Worker                >::type
219*58b9f456SAndroid Build Coastguard Worker            >
220*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
221*58b9f456SAndroid Build Coastguard Worker        explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
222*58b9f456SAndroid Build Coastguard Worker            : __value_(_VSTD::forward<_Tp>(__t))
223*58b9f456SAndroid Build Coastguard Worker        {static_assert(__can_bind_reference<_Tp&&>(),
224*58b9f456SAndroid Build Coastguard Worker       "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
225*58b9f456SAndroid Build Coastguard Worker
226*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class _Alloc>
227*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
228*58b9f456SAndroid Build Coastguard Worker        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
229*58b9f456SAndroid Build Coastguard Worker            : __value_(_VSTD::forward<_Tp>(__t))
230*58b9f456SAndroid Build Coastguard Worker        {static_assert(__can_bind_reference<_Tp&&>(),
231*58b9f456SAndroid Build Coastguard Worker       "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
232*58b9f456SAndroid Build Coastguard Worker
233*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class _Alloc>
234*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
235*58b9f456SAndroid Build Coastguard Worker        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
236*58b9f456SAndroid Build Coastguard Worker            : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
237*58b9f456SAndroid Build Coastguard Worker        {static_assert(!is_reference<_Hp>::value,
238*58b9f456SAndroid Build Coastguard Worker            "Attempted to uses-allocator construct a reference element in a tuple");}
239*58b9f456SAndroid Build Coastguard Worker
240*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class _Alloc>
241*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
242*58b9f456SAndroid Build Coastguard Worker        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
243*58b9f456SAndroid Build Coastguard Worker            : __value_(_VSTD::forward<_Tp>(__t), __a)
244*58b9f456SAndroid Build Coastguard Worker        {static_assert(!is_reference<_Hp>::value,
245*58b9f456SAndroid Build Coastguard Worker           "Attempted to uses-allocator construct a reference element in a tuple");}
246*58b9f456SAndroid Build Coastguard Worker
247*58b9f456SAndroid Build Coastguard Worker    __tuple_leaf(const __tuple_leaf& __t) = default;
248*58b9f456SAndroid Build Coastguard Worker    __tuple_leaf(__tuple_leaf&& __t) = default;
249*58b9f456SAndroid Build Coastguard Worker
250*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
251*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
252*58b9f456SAndroid Build Coastguard Worker        __tuple_leaf&
253*58b9f456SAndroid Build Coastguard Worker        operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
254*58b9f456SAndroid Build Coastguard Worker        {
255*58b9f456SAndroid Build Coastguard Worker            __value_ = _VSTD::forward<_Tp>(__t);
256*58b9f456SAndroid Build Coastguard Worker            return *this;
257*58b9f456SAndroid Build Coastguard Worker        }
258*58b9f456SAndroid Build Coastguard Worker
259*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
260*58b9f456SAndroid Build Coastguard Worker    int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
261*58b9f456SAndroid Build Coastguard Worker    {
262*58b9f456SAndroid Build Coastguard Worker        _VSTD::swap(*this, __t);
263*58b9f456SAndroid Build Coastguard Worker        return 0;
264*58b9f456SAndroid Build Coastguard Worker    }
265*58b9f456SAndroid Build Coastguard Worker
266*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11       _Hp& get()       _NOEXCEPT {return __value_;}
267*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;}
268*58b9f456SAndroid Build Coastguard Worker};
269*58b9f456SAndroid Build Coastguard Worker
270*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class _Hp>
271*58b9f456SAndroid Build Coastguard Workerclass __tuple_leaf<_Ip, _Hp, true>
272*58b9f456SAndroid Build Coastguard Worker    : private _Hp
273*58b9f456SAndroid Build Coastguard Worker{
274*58b9f456SAndroid Build Coastguard Worker
275*58b9f456SAndroid Build Coastguard Worker    __tuple_leaf& operator=(const __tuple_leaf&);
276*58b9f456SAndroid Build Coastguard Workerpublic:
277*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
278*58b9f456SAndroid Build Coastguard Worker             _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
279*58b9f456SAndroid Build Coastguard Worker
280*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc>
281*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
282*58b9f456SAndroid Build Coastguard Worker        __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
283*58b9f456SAndroid Build Coastguard Worker
284*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc>
285*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
286*58b9f456SAndroid Build Coastguard Worker        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
287*58b9f456SAndroid Build Coastguard Worker            : _Hp(allocator_arg_t(), __a) {}
288*58b9f456SAndroid Build Coastguard Worker
289*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc>
290*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
291*58b9f456SAndroid Build Coastguard Worker        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
292*58b9f456SAndroid Build Coastguard Worker            : _Hp(__a) {}
293*58b9f456SAndroid Build Coastguard Worker
294*58b9f456SAndroid Build Coastguard Worker    template <class _Tp,
295*58b9f456SAndroid Build Coastguard Worker              class = typename enable_if<
296*58b9f456SAndroid Build Coastguard Worker                  __lazy_and<
297*58b9f456SAndroid Build Coastguard Worker                        __lazy_not<is_same<typename __uncvref<_Tp>::type, __tuple_leaf>>
298*58b9f456SAndroid Build Coastguard Worker                      , is_constructible<_Hp, _Tp>
299*58b9f456SAndroid Build Coastguard Worker                    >::value
300*58b9f456SAndroid Build Coastguard Worker                >::type
301*58b9f456SAndroid Build Coastguard Worker            >
302*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
303*58b9f456SAndroid Build Coastguard Worker        explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
304*58b9f456SAndroid Build Coastguard Worker            : _Hp(_VSTD::forward<_Tp>(__t)) {}
305*58b9f456SAndroid Build Coastguard Worker
306*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class _Alloc>
307*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
308*58b9f456SAndroid Build Coastguard Worker        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
309*58b9f456SAndroid Build Coastguard Worker            : _Hp(_VSTD::forward<_Tp>(__t)) {}
310*58b9f456SAndroid Build Coastguard Worker
311*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class _Alloc>
312*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
313*58b9f456SAndroid Build Coastguard Worker        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
314*58b9f456SAndroid Build Coastguard Worker            : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
315*58b9f456SAndroid Build Coastguard Worker
316*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class _Alloc>
317*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
318*58b9f456SAndroid Build Coastguard Worker        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
319*58b9f456SAndroid Build Coastguard Worker            : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
320*58b9f456SAndroid Build Coastguard Worker
321*58b9f456SAndroid Build Coastguard Worker    __tuple_leaf(__tuple_leaf const &) = default;
322*58b9f456SAndroid Build Coastguard Worker    __tuple_leaf(__tuple_leaf &&) = default;
323*58b9f456SAndroid Build Coastguard Worker
324*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
325*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
326*58b9f456SAndroid Build Coastguard Worker        __tuple_leaf&
327*58b9f456SAndroid Build Coastguard Worker        operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
328*58b9f456SAndroid Build Coastguard Worker        {
329*58b9f456SAndroid Build Coastguard Worker            _Hp::operator=(_VSTD::forward<_Tp>(__t));
330*58b9f456SAndroid Build Coastguard Worker            return *this;
331*58b9f456SAndroid Build Coastguard Worker        }
332*58b9f456SAndroid Build Coastguard Worker
333*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
334*58b9f456SAndroid Build Coastguard Worker    int
335*58b9f456SAndroid Build Coastguard Worker    swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
336*58b9f456SAndroid Build Coastguard Worker    {
337*58b9f456SAndroid Build Coastguard Worker        _VSTD::swap(*this, __t);
338*58b9f456SAndroid Build Coastguard Worker        return 0;
339*58b9f456SAndroid Build Coastguard Worker    }
340*58b9f456SAndroid Build Coastguard Worker
341*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11       _Hp& get()       _NOEXCEPT {return static_cast<_Hp&>(*this);}
342*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
343*58b9f456SAndroid Build Coastguard Worker};
344*58b9f456SAndroid Build Coastguard Worker
345*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp>
346*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
347*58b9f456SAndroid Build Coastguard Workervoid __swallow(_Tp&&...) _NOEXCEPT {}
348*58b9f456SAndroid Build Coastguard Worker
349*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp>
350*58b9f456SAndroid Build Coastguard Workerstruct __lazy_all : __all<_Tp::value...> {};
351*58b9f456SAndroid Build Coastguard Worker
352*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
353*58b9f456SAndroid Build Coastguard Workerstruct __all_default_constructible;
354*58b9f456SAndroid Build Coastguard Worker
355*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp>
356*58b9f456SAndroid Build Coastguard Workerstruct __all_default_constructible<__tuple_types<_Tp...>>
357*58b9f456SAndroid Build Coastguard Worker    : __all<is_default_constructible<_Tp>::value...>
358*58b9f456SAndroid Build Coastguard Worker{ };
359*58b9f456SAndroid Build Coastguard Worker
360*58b9f456SAndroid Build Coastguard Worker// __tuple_impl
361*58b9f456SAndroid Build Coastguard Worker
362*58b9f456SAndroid Build Coastguard Workertemplate<class _Indx, class ..._Tp> struct __tuple_impl;
363*58b9f456SAndroid Build Coastguard Worker
364*58b9f456SAndroid Build Coastguard Workertemplate<size_t ..._Indx, class ..._Tp>
365*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
366*58b9f456SAndroid Build Coastguard Worker    : public __tuple_leaf<_Indx, _Tp>...
367*58b9f456SAndroid Build Coastguard Worker{
368*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
369*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR __tuple_impl()
370*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
371*58b9f456SAndroid Build Coastguard Worker
372*58b9f456SAndroid Build Coastguard Worker    template <size_t ..._Uf, class ..._Tf,
373*58b9f456SAndroid Build Coastguard Worker              size_t ..._Ul, class ..._Tl, class ..._Up>
374*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
375*58b9f456SAndroid Build Coastguard Worker        explicit
376*58b9f456SAndroid Build Coastguard Worker        __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
377*58b9f456SAndroid Build Coastguard Worker                     __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
378*58b9f456SAndroid Build Coastguard Worker                     _Up&&... __u)
379*58b9f456SAndroid Build Coastguard Worker                     _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
380*58b9f456SAndroid Build Coastguard Worker                                 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
381*58b9f456SAndroid Build Coastguard Worker            __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
382*58b9f456SAndroid Build Coastguard Worker            __tuple_leaf<_Ul, _Tl>()...
383*58b9f456SAndroid Build Coastguard Worker            {}
384*58b9f456SAndroid Build Coastguard Worker
385*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc, size_t ..._Uf, class ..._Tf,
386*58b9f456SAndroid Build Coastguard Worker              size_t ..._Ul, class ..._Tl, class ..._Up>
387*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
388*58b9f456SAndroid Build Coastguard Worker        explicit
389*58b9f456SAndroid Build Coastguard Worker        __tuple_impl(allocator_arg_t, const _Alloc& __a,
390*58b9f456SAndroid Build Coastguard Worker                     __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
391*58b9f456SAndroid Build Coastguard Worker                     __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
392*58b9f456SAndroid Build Coastguard Worker                     _Up&&... __u) :
393*58b9f456SAndroid Build Coastguard Worker            __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
394*58b9f456SAndroid Build Coastguard Worker            _VSTD::forward<_Up>(__u))...,
395*58b9f456SAndroid Build Coastguard Worker            __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
396*58b9f456SAndroid Build Coastguard Worker            {}
397*58b9f456SAndroid Build Coastguard Worker
398*58b9f456SAndroid Build Coastguard Worker    template <class _Tuple,
399*58b9f456SAndroid Build Coastguard Worker              class = typename enable_if
400*58b9f456SAndroid Build Coastguard Worker                      <
401*58b9f456SAndroid Build Coastguard Worker                         __tuple_constructible<_Tuple, tuple<_Tp...> >::value
402*58b9f456SAndroid Build Coastguard Worker                      >::type
403*58b9f456SAndroid Build Coastguard Worker             >
404*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
405*58b9f456SAndroid Build Coastguard Worker        __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
406*58b9f456SAndroid Build Coastguard Worker                                       typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
407*58b9f456SAndroid Build Coastguard Worker            : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
408*58b9f456SAndroid Build Coastguard Worker                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
409*58b9f456SAndroid Build Coastguard Worker            {}
410*58b9f456SAndroid Build Coastguard Worker
411*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc, class _Tuple,
412*58b9f456SAndroid Build Coastguard Worker              class = typename enable_if
413*58b9f456SAndroid Build Coastguard Worker                      <
414*58b9f456SAndroid Build Coastguard Worker                         __tuple_constructible<_Tuple, tuple<_Tp...> >::value
415*58b9f456SAndroid Build Coastguard Worker                      >::type
416*58b9f456SAndroid Build Coastguard Worker             >
417*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
418*58b9f456SAndroid Build Coastguard Worker        __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
419*58b9f456SAndroid Build Coastguard Worker            : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
420*58b9f456SAndroid Build Coastguard Worker                                       typename __make_tuple_types<_Tuple>::type>::type>(), __a,
421*58b9f456SAndroid Build Coastguard Worker                                       _VSTD::forward<typename tuple_element<_Indx,
422*58b9f456SAndroid Build Coastguard Worker                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
423*58b9f456SAndroid Build Coastguard Worker            {}
424*58b9f456SAndroid Build Coastguard Worker
425*58b9f456SAndroid Build Coastguard Worker    template <class _Tuple>
426*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
427*58b9f456SAndroid Build Coastguard Worker        typename enable_if
428*58b9f456SAndroid Build Coastguard Worker        <
429*58b9f456SAndroid Build Coastguard Worker            __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
430*58b9f456SAndroid Build Coastguard Worker            __tuple_impl&
431*58b9f456SAndroid Build Coastguard Worker        >::type
432*58b9f456SAndroid Build Coastguard Worker        operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
433*58b9f456SAndroid Build Coastguard Worker                                       typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
434*58b9f456SAndroid Build Coastguard Worker        {
435*58b9f456SAndroid Build Coastguard Worker            __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
436*58b9f456SAndroid Build Coastguard Worker                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
437*58b9f456SAndroid Build Coastguard Worker            return *this;
438*58b9f456SAndroid Build Coastguard Worker        }
439*58b9f456SAndroid Build Coastguard Worker
440*58b9f456SAndroid Build Coastguard Worker    __tuple_impl(const __tuple_impl&) = default;
441*58b9f456SAndroid Build Coastguard Worker    __tuple_impl(__tuple_impl&&) = default;
442*58b9f456SAndroid Build Coastguard Worker
443*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
444*58b9f456SAndroid Build Coastguard Worker    __tuple_impl&
445*58b9f456SAndroid Build Coastguard Worker    operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
446*58b9f456SAndroid Build Coastguard Worker    {
447*58b9f456SAndroid Build Coastguard Worker        __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
448*58b9f456SAndroid Build Coastguard Worker        return *this;
449*58b9f456SAndroid Build Coastguard Worker    }
450*58b9f456SAndroid Build Coastguard Worker
451*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
452*58b9f456SAndroid Build Coastguard Worker    __tuple_impl&
453*58b9f456SAndroid Build Coastguard Worker    operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
454*58b9f456SAndroid Build Coastguard Worker    {
455*58b9f456SAndroid Build Coastguard Worker        __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
456*58b9f456SAndroid Build Coastguard Worker        return *this;
457*58b9f456SAndroid Build Coastguard Worker    }
458*58b9f456SAndroid Build Coastguard Worker
459*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
460*58b9f456SAndroid Build Coastguard Worker    void swap(__tuple_impl& __t)
461*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
462*58b9f456SAndroid Build Coastguard Worker    {
463*58b9f456SAndroid Build Coastguard Worker        __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
464*58b9f456SAndroid Build Coastguard Worker    }
465*58b9f456SAndroid Build Coastguard Worker};
466*58b9f456SAndroid Build Coastguard Worker
467*58b9f456SAndroid Build Coastguard Worker
468*58b9f456SAndroid Build Coastguard Worker
469*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp>
470*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS tuple
471*58b9f456SAndroid Build Coastguard Worker{
472*58b9f456SAndroid Build Coastguard Worker    typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
473*58b9f456SAndroid Build Coastguard Worker
474*58b9f456SAndroid Build Coastguard Worker    _BaseT __base_;
475*58b9f456SAndroid Build Coastguard Worker
476*58b9f456SAndroid Build Coastguard Worker#if defined(_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION)
477*58b9f456SAndroid Build Coastguard Worker    static constexpr bool _EnableImplicitReducedArityExtension = true;
478*58b9f456SAndroid Build Coastguard Worker#else
479*58b9f456SAndroid Build Coastguard Worker    static constexpr bool _EnableImplicitReducedArityExtension = false;
480*58b9f456SAndroid Build Coastguard Worker#endif
481*58b9f456SAndroid Build Coastguard Worker
482*58b9f456SAndroid Build Coastguard Worker    template <class ..._Args>
483*58b9f456SAndroid Build Coastguard Worker    struct _PackExpandsToThisTuple : false_type {};
484*58b9f456SAndroid Build Coastguard Worker
485*58b9f456SAndroid Build Coastguard Worker    template <class _Arg>
486*58b9f456SAndroid Build Coastguard Worker    struct _PackExpandsToThisTuple<_Arg>
487*58b9f456SAndroid Build Coastguard Worker        : is_same<typename __uncvref<_Arg>::type, tuple> {};
488*58b9f456SAndroid Build Coastguard Worker
489*58b9f456SAndroid Build Coastguard Worker    template <bool _MaybeEnable, class _Dummy = void>
490*58b9f456SAndroid Build Coastguard Worker    struct _CheckArgsConstructor : __check_tuple_constructor_fail {};
491*58b9f456SAndroid Build Coastguard Worker
492*58b9f456SAndroid Build Coastguard Worker    template <class _Dummy>
493*58b9f456SAndroid Build Coastguard Worker    struct _CheckArgsConstructor<true, _Dummy>
494*58b9f456SAndroid Build Coastguard Worker    {
495*58b9f456SAndroid Build Coastguard Worker        template <class ..._Args>
496*58b9f456SAndroid Build Coastguard Worker        static constexpr bool __enable_default() {
497*58b9f456SAndroid Build Coastguard Worker            return __all<is_default_constructible<_Args>::value...>::value;
498*58b9f456SAndroid Build Coastguard Worker        }
499*58b9f456SAndroid Build Coastguard Worker
500*58b9f456SAndroid Build Coastguard Worker        template <class ..._Args>
501*58b9f456SAndroid Build Coastguard Worker        static constexpr bool __enable_explicit() {
502*58b9f456SAndroid Build Coastguard Worker            return
503*58b9f456SAndroid Build Coastguard Worker                __tuple_constructible<
504*58b9f456SAndroid Build Coastguard Worker                    tuple<_Args...>,
505*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple,
506*58b9f456SAndroid Build Coastguard Worker                             sizeof...(_Args) < sizeof...(_Tp) ?
507*58b9f456SAndroid Build Coastguard Worker                                 sizeof...(_Args) :
508*58b9f456SAndroid Build Coastguard Worker                                 sizeof...(_Tp)>::type
509*58b9f456SAndroid Build Coastguard Worker                >::value &&
510*58b9f456SAndroid Build Coastguard Worker                !__tuple_convertible<
511*58b9f456SAndroid Build Coastguard Worker                    tuple<_Args...>,
512*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple,
513*58b9f456SAndroid Build Coastguard Worker                             sizeof...(_Args) < sizeof...(_Tp) ?
514*58b9f456SAndroid Build Coastguard Worker                                 sizeof...(_Args) :
515*58b9f456SAndroid Build Coastguard Worker                                 sizeof...(_Tp)>::type
516*58b9f456SAndroid Build Coastguard Worker                >::value &&
517*58b9f456SAndroid Build Coastguard Worker                __all_default_constructible<
518*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Tp),
519*58b9f456SAndroid Build Coastguard Worker                             sizeof...(_Args) < sizeof...(_Tp) ?
520*58b9f456SAndroid Build Coastguard Worker                                 sizeof...(_Args) :
521*58b9f456SAndroid Build Coastguard Worker                                 sizeof...(_Tp)>::type
522*58b9f456SAndroid Build Coastguard Worker                >::value;
523*58b9f456SAndroid Build Coastguard Worker        }
524*58b9f456SAndroid Build Coastguard Worker
525*58b9f456SAndroid Build Coastguard Worker        template <class ..._Args>
526*58b9f456SAndroid Build Coastguard Worker        static constexpr bool __enable_implicit() {
527*58b9f456SAndroid Build Coastguard Worker            return
528*58b9f456SAndroid Build Coastguard Worker                __tuple_convertible<
529*58b9f456SAndroid Build Coastguard Worker                    tuple<_Args...>,
530*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple,
531*58b9f456SAndroid Build Coastguard Worker                             sizeof...(_Args) < sizeof...(_Tp) ?
532*58b9f456SAndroid Build Coastguard Worker                                 sizeof...(_Args) :
533*58b9f456SAndroid Build Coastguard Worker                                 sizeof...(_Tp)>::type
534*58b9f456SAndroid Build Coastguard Worker                >::value &&
535*58b9f456SAndroid Build Coastguard Worker                __all_default_constructible<
536*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Tp),
537*58b9f456SAndroid Build Coastguard Worker                             sizeof...(_Args) < sizeof...(_Tp) ?
538*58b9f456SAndroid Build Coastguard Worker                                 sizeof...(_Args) :
539*58b9f456SAndroid Build Coastguard Worker                                 sizeof...(_Tp)>::type
540*58b9f456SAndroid Build Coastguard Worker                >::value;
541*58b9f456SAndroid Build Coastguard Worker        }
542*58b9f456SAndroid Build Coastguard Worker    };
543*58b9f456SAndroid Build Coastguard Worker
544*58b9f456SAndroid Build Coastguard Worker    template <bool _MaybeEnable,
545*58b9f456SAndroid Build Coastguard Worker              bool = sizeof...(_Tp) == 1,
546*58b9f456SAndroid Build Coastguard Worker              class _Dummy = void>
547*58b9f456SAndroid Build Coastguard Worker    struct _CheckTupleLikeConstructor : __check_tuple_constructor_fail {};
548*58b9f456SAndroid Build Coastguard Worker
549*58b9f456SAndroid Build Coastguard Worker    template <class _Dummy>
550*58b9f456SAndroid Build Coastguard Worker    struct _CheckTupleLikeConstructor<true, false, _Dummy>
551*58b9f456SAndroid Build Coastguard Worker    {
552*58b9f456SAndroid Build Coastguard Worker        template <class _Tuple>
553*58b9f456SAndroid Build Coastguard Worker        static constexpr bool __enable_implicit() {
554*58b9f456SAndroid Build Coastguard Worker            return __tuple_convertible<_Tuple, tuple>::value;
555*58b9f456SAndroid Build Coastguard Worker        }
556*58b9f456SAndroid Build Coastguard Worker
557*58b9f456SAndroid Build Coastguard Worker        template <class _Tuple>
558*58b9f456SAndroid Build Coastguard Worker        static constexpr bool __enable_explicit() {
559*58b9f456SAndroid Build Coastguard Worker            return __tuple_constructible<_Tuple, tuple>::value
560*58b9f456SAndroid Build Coastguard Worker               && !__tuple_convertible<_Tuple, tuple>::value;
561*58b9f456SAndroid Build Coastguard Worker        }
562*58b9f456SAndroid Build Coastguard Worker    };
563*58b9f456SAndroid Build Coastguard Worker
564*58b9f456SAndroid Build Coastguard Worker    template <class _Dummy>
565*58b9f456SAndroid Build Coastguard Worker    struct _CheckTupleLikeConstructor<true, true, _Dummy>
566*58b9f456SAndroid Build Coastguard Worker    {
567*58b9f456SAndroid Build Coastguard Worker        // This trait is used to disable the tuple-like constructor when
568*58b9f456SAndroid Build Coastguard Worker        // the UTypes... constructor should be selected instead.
569*58b9f456SAndroid Build Coastguard Worker        // See LWG issue #2549.
570*58b9f456SAndroid Build Coastguard Worker        template <class _Tuple>
571*58b9f456SAndroid Build Coastguard Worker        using _PreferTupleLikeConstructor = __lazy_or<
572*58b9f456SAndroid Build Coastguard Worker            // Don't attempt the two checks below if the tuple we are given
573*58b9f456SAndroid Build Coastguard Worker            // has the same type as this tuple.
574*58b9f456SAndroid Build Coastguard Worker            is_same<typename __uncvref<_Tuple>::type, tuple>,
575*58b9f456SAndroid Build Coastguard Worker            __lazy_and<
576*58b9f456SAndroid Build Coastguard Worker                __lazy_not<is_constructible<_Tp..., _Tuple>>,
577*58b9f456SAndroid Build Coastguard Worker                __lazy_not<is_convertible<_Tuple, _Tp...>>
578*58b9f456SAndroid Build Coastguard Worker            >
579*58b9f456SAndroid Build Coastguard Worker        >;
580*58b9f456SAndroid Build Coastguard Worker
581*58b9f456SAndroid Build Coastguard Worker        template <class _Tuple>
582*58b9f456SAndroid Build Coastguard Worker        static constexpr bool __enable_implicit() {
583*58b9f456SAndroid Build Coastguard Worker            return __lazy_and<
584*58b9f456SAndroid Build Coastguard Worker                __tuple_convertible<_Tuple, tuple>,
585*58b9f456SAndroid Build Coastguard Worker                _PreferTupleLikeConstructor<_Tuple>
586*58b9f456SAndroid Build Coastguard Worker            >::value;
587*58b9f456SAndroid Build Coastguard Worker        }
588*58b9f456SAndroid Build Coastguard Worker
589*58b9f456SAndroid Build Coastguard Worker        template <class _Tuple>
590*58b9f456SAndroid Build Coastguard Worker        static constexpr bool __enable_explicit() {
591*58b9f456SAndroid Build Coastguard Worker            return __lazy_and<
592*58b9f456SAndroid Build Coastguard Worker                __tuple_constructible<_Tuple, tuple>,
593*58b9f456SAndroid Build Coastguard Worker                _PreferTupleLikeConstructor<_Tuple>,
594*58b9f456SAndroid Build Coastguard Worker                __lazy_not<__tuple_convertible<_Tuple, tuple>>
595*58b9f456SAndroid Build Coastguard Worker            >::value;
596*58b9f456SAndroid Build Coastguard Worker        }
597*58b9f456SAndroid Build Coastguard Worker    };
598*58b9f456SAndroid Build Coastguard Worker
599*58b9f456SAndroid Build Coastguard Worker    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
600*58b9f456SAndroid Build Coastguard Worker        typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
601*58b9f456SAndroid Build Coastguard Worker    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
602*58b9f456SAndroid Build Coastguard Worker        const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
603*58b9f456SAndroid Build Coastguard Worker    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
604*58b9f456SAndroid Build Coastguard Worker        typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
605*58b9f456SAndroid Build Coastguard Worker    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
606*58b9f456SAndroid Build Coastguard Worker        const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
607*58b9f456SAndroid Build Coastguard Workerpublic:
608*58b9f456SAndroid Build Coastguard Worker
609*58b9f456SAndroid Build Coastguard Worker    template <bool _Dummy = true, class = typename enable_if<
610*58b9f456SAndroid Build Coastguard Worker        _CheckArgsConstructor<_Dummy>::template __enable_default<_Tp...>()
611*58b9f456SAndroid Build Coastguard Worker    >::type>
612*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
613*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR tuple()
614*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
615*58b9f456SAndroid Build Coastguard Worker
616*58b9f456SAndroid Build Coastguard Worker    tuple(tuple const&) = default;
617*58b9f456SAndroid Build Coastguard Worker    tuple(tuple&&) = default;
618*58b9f456SAndroid Build Coastguard Worker
619*58b9f456SAndroid Build Coastguard Worker    template <class _AllocArgT, class _Alloc, bool _Dummy = true, class = typename enable_if<
620*58b9f456SAndroid Build Coastguard Worker        __lazy_and<
621*58b9f456SAndroid Build Coastguard Worker            is_same<allocator_arg_t, _AllocArgT>,
622*58b9f456SAndroid Build Coastguard Worker            __lazy_all<__dependent_type<is_default_constructible<_Tp>, _Dummy>...>
623*58b9f456SAndroid Build Coastguard Worker       >::value
624*58b9f456SAndroid Build Coastguard Worker    >::type>
625*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
626*58b9f456SAndroid Build Coastguard Worker    tuple(_AllocArgT, _Alloc const& __a)
627*58b9f456SAndroid Build Coastguard Worker      : __base_(allocator_arg_t(), __a,
628*58b9f456SAndroid Build Coastguard Worker                    __tuple_indices<>(), __tuple_types<>(),
629*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
630*58b9f456SAndroid Build Coastguard Worker                    __tuple_types<_Tp...>()) {}
631*58b9f456SAndroid Build Coastguard Worker
632*58b9f456SAndroid Build Coastguard Worker    template <bool _Dummy = true,
633*58b9f456SAndroid Build Coastguard Worker              typename enable_if
634*58b9f456SAndroid Build Coastguard Worker                      <
635*58b9f456SAndroid Build Coastguard Worker                         _CheckArgsConstructor<
636*58b9f456SAndroid Build Coastguard Worker                            _Dummy
637*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_implicit<_Tp const&...>(),
638*58b9f456SAndroid Build Coastguard Worker                         bool
639*58b9f456SAndroid Build Coastguard Worker                      >::type = false
640*58b9f456SAndroid Build Coastguard Worker        >
641*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
642*58b9f456SAndroid Build Coastguard Worker    tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
643*58b9f456SAndroid Build Coastguard Worker        : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
644*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
645*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_indices<0>::type(),
646*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_types<tuple, 0>::type(),
647*58b9f456SAndroid Build Coastguard Worker                __t...
648*58b9f456SAndroid Build Coastguard Worker               ) {}
649*58b9f456SAndroid Build Coastguard Worker
650*58b9f456SAndroid Build Coastguard Worker    template <bool _Dummy = true,
651*58b9f456SAndroid Build Coastguard Worker              typename enable_if
652*58b9f456SAndroid Build Coastguard Worker                      <
653*58b9f456SAndroid Build Coastguard Worker                         _CheckArgsConstructor<
654*58b9f456SAndroid Build Coastguard Worker                            _Dummy
655*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_explicit<_Tp const&...>(),
656*58b9f456SAndroid Build Coastguard Worker                         bool
657*58b9f456SAndroid Build Coastguard Worker                      >::type = false
658*58b9f456SAndroid Build Coastguard Worker        >
659*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
660*58b9f456SAndroid Build Coastguard Worker    explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
661*58b9f456SAndroid Build Coastguard Worker        : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
662*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
663*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_indices<0>::type(),
664*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_types<tuple, 0>::type(),
665*58b9f456SAndroid Build Coastguard Worker                __t...
666*58b9f456SAndroid Build Coastguard Worker               ) {}
667*58b9f456SAndroid Build Coastguard Worker
668*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc, bool _Dummy = true,
669*58b9f456SAndroid Build Coastguard Worker              typename enable_if
670*58b9f456SAndroid Build Coastguard Worker                      <
671*58b9f456SAndroid Build Coastguard Worker                         _CheckArgsConstructor<
672*58b9f456SAndroid Build Coastguard Worker                            _Dummy
673*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_implicit<_Tp const&...>(),
674*58b9f456SAndroid Build Coastguard Worker                         bool
675*58b9f456SAndroid Build Coastguard Worker                      >::type = false
676*58b9f456SAndroid Build Coastguard Worker        >
677*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_INLINE_VISIBILITY
678*58b9f456SAndroid Build Coastguard Worker      tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
679*58b9f456SAndroid Build Coastguard Worker        : __base_(allocator_arg_t(), __a,
680*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_indices<sizeof...(_Tp)>::type(),
681*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
682*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_indices<0>::type(),
683*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_types<tuple, 0>::type(),
684*58b9f456SAndroid Build Coastguard Worker                __t...
685*58b9f456SAndroid Build Coastguard Worker               ) {}
686*58b9f456SAndroid Build Coastguard Worker
687*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc, bool _Dummy = true,
688*58b9f456SAndroid Build Coastguard Worker              typename enable_if
689*58b9f456SAndroid Build Coastguard Worker                      <
690*58b9f456SAndroid Build Coastguard Worker                         _CheckArgsConstructor<
691*58b9f456SAndroid Build Coastguard Worker                            _Dummy
692*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_explicit<_Tp const&...>(),
693*58b9f456SAndroid Build Coastguard Worker                         bool
694*58b9f456SAndroid Build Coastguard Worker                      >::type = false
695*58b9f456SAndroid Build Coastguard Worker        >
696*58b9f456SAndroid Build Coastguard Worker      _LIBCPP_INLINE_VISIBILITY
697*58b9f456SAndroid Build Coastguard Worker      explicit
698*58b9f456SAndroid Build Coastguard Worker      tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
699*58b9f456SAndroid Build Coastguard Worker        : __base_(allocator_arg_t(), __a,
700*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_indices<sizeof...(_Tp)>::type(),
701*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
702*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_indices<0>::type(),
703*58b9f456SAndroid Build Coastguard Worker                typename __make_tuple_types<tuple, 0>::type(),
704*58b9f456SAndroid Build Coastguard Worker                __t...
705*58b9f456SAndroid Build Coastguard Worker               ) {}
706*58b9f456SAndroid Build Coastguard Worker
707*58b9f456SAndroid Build Coastguard Worker    template <class ..._Up,
708*58b9f456SAndroid Build Coastguard Worker              bool _PackIsTuple = _PackExpandsToThisTuple<_Up...>::value,
709*58b9f456SAndroid Build Coastguard Worker              typename enable_if
710*58b9f456SAndroid Build Coastguard Worker                      <
711*58b9f456SAndroid Build Coastguard Worker                         _CheckArgsConstructor<
712*58b9f456SAndroid Build Coastguard Worker                             sizeof...(_Up) == sizeof...(_Tp)
713*58b9f456SAndroid Build Coastguard Worker                             && !_PackIsTuple
714*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_implicit<_Up...>() ||
715*58b9f456SAndroid Build Coastguard Worker                        _CheckArgsConstructor<
716*58b9f456SAndroid Build Coastguard Worker                            _EnableImplicitReducedArityExtension
717*58b9f456SAndroid Build Coastguard Worker                            && sizeof...(_Up) < sizeof...(_Tp)
718*58b9f456SAndroid Build Coastguard Worker                            && !_PackIsTuple
719*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_implicit<_Up...>(),
720*58b9f456SAndroid Build Coastguard Worker                         bool
721*58b9f456SAndroid Build Coastguard Worker                      >::type = false
722*58b9f456SAndroid Build Coastguard Worker             >
723*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
724*58b9f456SAndroid Build Coastguard Worker        tuple(_Up&&... __u)
725*58b9f456SAndroid Build Coastguard Worker            _NOEXCEPT_((
726*58b9f456SAndroid Build Coastguard Worker                is_nothrow_constructible<_BaseT,
727*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_indices<sizeof...(_Up)>::type,
728*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
729*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
730*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
731*58b9f456SAndroid Build Coastguard Worker                    _Up...
732*58b9f456SAndroid Build Coastguard Worker                >::value
733*58b9f456SAndroid Build Coastguard Worker            ))
734*58b9f456SAndroid Build Coastguard Worker            : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
735*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
736*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
737*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
738*58b9f456SAndroid Build Coastguard Worker                    _VSTD::forward<_Up>(__u)...) {}
739*58b9f456SAndroid Build Coastguard Worker
740*58b9f456SAndroid Build Coastguard Worker    template <class ..._Up,
741*58b9f456SAndroid Build Coastguard Worker              typename enable_if
742*58b9f456SAndroid Build Coastguard Worker                      <
743*58b9f456SAndroid Build Coastguard Worker                         _CheckArgsConstructor<
744*58b9f456SAndroid Build Coastguard Worker                             sizeof...(_Up) <= sizeof...(_Tp)
745*58b9f456SAndroid Build Coastguard Worker                             && !_PackExpandsToThisTuple<_Up...>::value
746*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_explicit<_Up...>() ||
747*58b9f456SAndroid Build Coastguard Worker                         _CheckArgsConstructor<
748*58b9f456SAndroid Build Coastguard Worker                            !_EnableImplicitReducedArityExtension
749*58b9f456SAndroid Build Coastguard Worker                            && sizeof...(_Up) < sizeof...(_Tp)
750*58b9f456SAndroid Build Coastguard Worker                            && !_PackExpandsToThisTuple<_Up...>::value
751*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_implicit<_Up...>(),
752*58b9f456SAndroid Build Coastguard Worker                         bool
753*58b9f456SAndroid Build Coastguard Worker                      >::type = false
754*58b9f456SAndroid Build Coastguard Worker             >
755*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
756*58b9f456SAndroid Build Coastguard Worker        explicit
757*58b9f456SAndroid Build Coastguard Worker        tuple(_Up&&... __u)
758*58b9f456SAndroid Build Coastguard Worker            _NOEXCEPT_((
759*58b9f456SAndroid Build Coastguard Worker                is_nothrow_constructible<_BaseT,
760*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_indices<sizeof...(_Up)>::type,
761*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
762*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
763*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
764*58b9f456SAndroid Build Coastguard Worker                    _Up...
765*58b9f456SAndroid Build Coastguard Worker                >::value
766*58b9f456SAndroid Build Coastguard Worker            ))
767*58b9f456SAndroid Build Coastguard Worker            : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
768*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
769*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
770*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
771*58b9f456SAndroid Build Coastguard Worker                    _VSTD::forward<_Up>(__u)...) {}
772*58b9f456SAndroid Build Coastguard Worker
773*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc, class ..._Up,
774*58b9f456SAndroid Build Coastguard Worker              typename enable_if
775*58b9f456SAndroid Build Coastguard Worker                      <
776*58b9f456SAndroid Build Coastguard Worker                         _CheckArgsConstructor<
777*58b9f456SAndroid Build Coastguard Worker                             sizeof...(_Up) == sizeof...(_Tp) &&
778*58b9f456SAndroid Build Coastguard Worker                             !_PackExpandsToThisTuple<_Up...>::value
779*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_implicit<_Up...>(),
780*58b9f456SAndroid Build Coastguard Worker                         bool
781*58b9f456SAndroid Build Coastguard Worker                      >::type = false
782*58b9f456SAndroid Build Coastguard Worker             >
783*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
784*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
785*58b9f456SAndroid Build Coastguard Worker            : __base_(allocator_arg_t(), __a,
786*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_indices<sizeof...(_Up)>::type(),
787*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
788*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
789*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
790*58b9f456SAndroid Build Coastguard Worker                    _VSTD::forward<_Up>(__u)...) {}
791*58b9f456SAndroid Build Coastguard Worker
792*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc, class ..._Up,
793*58b9f456SAndroid Build Coastguard Worker              typename enable_if
794*58b9f456SAndroid Build Coastguard Worker                      <
795*58b9f456SAndroid Build Coastguard Worker                         _CheckArgsConstructor<
796*58b9f456SAndroid Build Coastguard Worker                             sizeof...(_Up) == sizeof...(_Tp) &&
797*58b9f456SAndroid Build Coastguard Worker                             !_PackExpandsToThisTuple<_Up...>::value
798*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_explicit<_Up...>(),
799*58b9f456SAndroid Build Coastguard Worker                         bool
800*58b9f456SAndroid Build Coastguard Worker                      >::type = false
801*58b9f456SAndroid Build Coastguard Worker             >
802*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
803*58b9f456SAndroid Build Coastguard Worker        explicit
804*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
805*58b9f456SAndroid Build Coastguard Worker            : __base_(allocator_arg_t(), __a,
806*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_indices<sizeof...(_Up)>::type(),
807*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
808*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
809*58b9f456SAndroid Build Coastguard Worker                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
810*58b9f456SAndroid Build Coastguard Worker                    _VSTD::forward<_Up>(__u)...) {}
811*58b9f456SAndroid Build Coastguard Worker
812*58b9f456SAndroid Build Coastguard Worker    template <class _Tuple,
813*58b9f456SAndroid Build Coastguard Worker              typename enable_if
814*58b9f456SAndroid Build Coastguard Worker                      <
815*58b9f456SAndroid Build Coastguard Worker                         _CheckTupleLikeConstructor<
816*58b9f456SAndroid Build Coastguard Worker                             __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
817*58b9f456SAndroid Build Coastguard Worker                             && !_PackExpandsToThisTuple<_Tuple>::value
818*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_implicit<_Tuple>(),
819*58b9f456SAndroid Build Coastguard Worker                         bool
820*58b9f456SAndroid Build Coastguard Worker                      >::type = false
821*58b9f456SAndroid Build Coastguard Worker             >
822*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
823*58b9f456SAndroid Build Coastguard Worker        tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
824*58b9f456SAndroid Build Coastguard Worker            : __base_(_VSTD::forward<_Tuple>(__t)) {}
825*58b9f456SAndroid Build Coastguard Worker
826*58b9f456SAndroid Build Coastguard Worker    template <class _Tuple,
827*58b9f456SAndroid Build Coastguard Worker              typename enable_if
828*58b9f456SAndroid Build Coastguard Worker                      <
829*58b9f456SAndroid Build Coastguard Worker                         _CheckTupleLikeConstructor<
830*58b9f456SAndroid Build Coastguard Worker                             __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
831*58b9f456SAndroid Build Coastguard Worker                             && !_PackExpandsToThisTuple<_Tuple>::value
832*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_explicit<_Tuple>(),
833*58b9f456SAndroid Build Coastguard Worker                         bool
834*58b9f456SAndroid Build Coastguard Worker                      >::type = false
835*58b9f456SAndroid Build Coastguard Worker             >
836*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
837*58b9f456SAndroid Build Coastguard Worker        explicit
838*58b9f456SAndroid Build Coastguard Worker        tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
839*58b9f456SAndroid Build Coastguard Worker            : __base_(_VSTD::forward<_Tuple>(__t)) {}
840*58b9f456SAndroid Build Coastguard Worker
841*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc, class _Tuple,
842*58b9f456SAndroid Build Coastguard Worker              typename enable_if
843*58b9f456SAndroid Build Coastguard Worker                      <
844*58b9f456SAndroid Build Coastguard Worker                         _CheckTupleLikeConstructor<
845*58b9f456SAndroid Build Coastguard Worker                             __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
846*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_implicit<_Tuple>(),
847*58b9f456SAndroid Build Coastguard Worker                         bool
848*58b9f456SAndroid Build Coastguard Worker                      >::type = false
849*58b9f456SAndroid Build Coastguard Worker             >
850*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
851*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
852*58b9f456SAndroid Build Coastguard Worker            : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
853*58b9f456SAndroid Build Coastguard Worker
854*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc, class _Tuple,
855*58b9f456SAndroid Build Coastguard Worker              typename enable_if
856*58b9f456SAndroid Build Coastguard Worker                      <
857*58b9f456SAndroid Build Coastguard Worker                         _CheckTupleLikeConstructor<
858*58b9f456SAndroid Build Coastguard Worker                             __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
859*58b9f456SAndroid Build Coastguard Worker                         >::template __enable_explicit<_Tuple>(),
860*58b9f456SAndroid Build Coastguard Worker                         bool
861*58b9f456SAndroid Build Coastguard Worker                      >::type = false
862*58b9f456SAndroid Build Coastguard Worker             >
863*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
864*58b9f456SAndroid Build Coastguard Worker        explicit
865*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
866*58b9f456SAndroid Build Coastguard Worker            : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
867*58b9f456SAndroid Build Coastguard Worker
868*58b9f456SAndroid Build Coastguard Worker    using _CanCopyAssign = __all<is_copy_assignable<_Tp>::value...>;
869*58b9f456SAndroid Build Coastguard Worker    using _CanMoveAssign = __all<is_move_assignable<_Tp>::value...>;
870*58b9f456SAndroid Build Coastguard Worker
871*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
872*58b9f456SAndroid Build Coastguard Worker    tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, __nat>::type const& __t)
873*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
874*58b9f456SAndroid Build Coastguard Worker    {
875*58b9f456SAndroid Build Coastguard Worker        __base_.operator=(__t.__base_);
876*58b9f456SAndroid Build Coastguard Worker        return *this;
877*58b9f456SAndroid Build Coastguard Worker    }
878*58b9f456SAndroid Build Coastguard Worker
879*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
880*58b9f456SAndroid Build Coastguard Worker    tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, __nat>::type&& __t)
881*58b9f456SAndroid Build Coastguard Worker        _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
882*58b9f456SAndroid Build Coastguard Worker    {
883*58b9f456SAndroid Build Coastguard Worker        __base_.operator=(static_cast<_BaseT&&>(__t.__base_));
884*58b9f456SAndroid Build Coastguard Worker        return *this;
885*58b9f456SAndroid Build Coastguard Worker    }
886*58b9f456SAndroid Build Coastguard Worker
887*58b9f456SAndroid Build Coastguard Worker    template <class _Tuple,
888*58b9f456SAndroid Build Coastguard Worker              class = typename enable_if
889*58b9f456SAndroid Build Coastguard Worker                      <
890*58b9f456SAndroid Build Coastguard Worker                         __tuple_assignable<_Tuple, tuple>::value
891*58b9f456SAndroid Build Coastguard Worker                      >::type
892*58b9f456SAndroid Build Coastguard Worker             >
893*58b9f456SAndroid Build Coastguard Worker        _LIBCPP_INLINE_VISIBILITY
894*58b9f456SAndroid Build Coastguard Worker        tuple&
895*58b9f456SAndroid Build Coastguard Worker        operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<_BaseT&, _Tuple>::value))
896*58b9f456SAndroid Build Coastguard Worker        {
897*58b9f456SAndroid Build Coastguard Worker            __base_.operator=(_VSTD::forward<_Tuple>(__t));
898*58b9f456SAndroid Build Coastguard Worker            return *this;
899*58b9f456SAndroid Build Coastguard Worker        }
900*58b9f456SAndroid Build Coastguard Worker
901*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
902*58b9f456SAndroid Build Coastguard Worker    void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
903*58b9f456SAndroid Build Coastguard Worker        {__base_.swap(__t.__base_);}
904*58b9f456SAndroid Build Coastguard Worker};
905*58b9f456SAndroid Build Coastguard Worker
906*58b9f456SAndroid Build Coastguard Workertemplate <>
907*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS tuple<>
908*58b9f456SAndroid Build Coastguard Worker{
909*58b9f456SAndroid Build Coastguard Workerpublic:
910*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
911*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
912*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc>
913*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
914*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
915*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc>
916*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
917*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
918*58b9f456SAndroid Build Coastguard Worker    template <class _Up>
919*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
920*58b9f456SAndroid Build Coastguard Worker        tuple(array<_Up, 0>) _NOEXCEPT {}
921*58b9f456SAndroid Build Coastguard Worker    template <class _Alloc, class _Up>
922*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
923*58b9f456SAndroid Build Coastguard Worker        tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
924*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY
925*58b9f456SAndroid Build Coastguard Worker    void swap(tuple&) _NOEXCEPT {}
926*58b9f456SAndroid Build Coastguard Worker};
927*58b9f456SAndroid Build Coastguard Worker
928*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
929*58b9f456SAndroid Build Coastguard Worker// NOTE: These are not yet standardized, but are required to simulate the
930*58b9f456SAndroid Build Coastguard Worker// implicit deduction guide that should be generated had libc++ declared the
931*58b9f456SAndroid Build Coastguard Worker// tuple-like constructors "correctly"
932*58b9f456SAndroid Build Coastguard Workertemplate <class _Alloc, class ..._Args>
933*58b9f456SAndroid Build Coastguard Workertuple(allocator_arg_t, const _Alloc&, tuple<_Args...> const&) -> tuple<_Args...>;
934*58b9f456SAndroid Build Coastguard Workertemplate <class _Alloc, class ..._Args>
935*58b9f456SAndroid Build Coastguard Workertuple(allocator_arg_t, const _Alloc&, tuple<_Args...>&&) -> tuple<_Args...>;
936*58b9f456SAndroid Build Coastguard Worker#endif
937*58b9f456SAndroid Build Coastguard Worker
938*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp>
939*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
940*58b9f456SAndroid Build Coastguard Workertypename enable_if
941*58b9f456SAndroid Build Coastguard Worker<
942*58b9f456SAndroid Build Coastguard Worker    __all<__is_swappable<_Tp>::value...>::value,
943*58b9f456SAndroid Build Coastguard Worker    void
944*58b9f456SAndroid Build Coastguard Worker>::type
945*58b9f456SAndroid Build Coastguard Workerswap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
946*58b9f456SAndroid Build Coastguard Worker                 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
947*58b9f456SAndroid Build Coastguard Worker    {__t.swap(__u);}
948*58b9f456SAndroid Build Coastguard Worker
949*58b9f456SAndroid Build Coastguard Worker// get
950*58b9f456SAndroid Build Coastguard Worker
951*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class ..._Tp>
952*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
953*58b9f456SAndroid Build Coastguard Workertypename tuple_element<_Ip, tuple<_Tp...> >::type&
954*58b9f456SAndroid Build Coastguard Workerget(tuple<_Tp...>& __t) _NOEXCEPT
955*58b9f456SAndroid Build Coastguard Worker{
956*58b9f456SAndroid Build Coastguard Worker    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
957*58b9f456SAndroid Build Coastguard Worker    return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
958*58b9f456SAndroid Build Coastguard Worker}
959*58b9f456SAndroid Build Coastguard Worker
960*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class ..._Tp>
961*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
962*58b9f456SAndroid Build Coastguard Workerconst typename tuple_element<_Ip, tuple<_Tp...> >::type&
963*58b9f456SAndroid Build Coastguard Workerget(const tuple<_Tp...>& __t) _NOEXCEPT
964*58b9f456SAndroid Build Coastguard Worker{
965*58b9f456SAndroid Build Coastguard Worker    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
966*58b9f456SAndroid Build Coastguard Worker    return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
967*58b9f456SAndroid Build Coastguard Worker}
968*58b9f456SAndroid Build Coastguard Worker
969*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class ..._Tp>
970*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
971*58b9f456SAndroid Build Coastguard Workertypename tuple_element<_Ip, tuple<_Tp...> >::type&&
972*58b9f456SAndroid Build Coastguard Workerget(tuple<_Tp...>&& __t) _NOEXCEPT
973*58b9f456SAndroid Build Coastguard Worker{
974*58b9f456SAndroid Build Coastguard Worker    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
975*58b9f456SAndroid Build Coastguard Worker    return static_cast<type&&>(
976*58b9f456SAndroid Build Coastguard Worker             static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
977*58b9f456SAndroid Build Coastguard Worker}
978*58b9f456SAndroid Build Coastguard Worker
979*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip, class ..._Tp>
980*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
981*58b9f456SAndroid Build Coastguard Workerconst typename tuple_element<_Ip, tuple<_Tp...> >::type&&
982*58b9f456SAndroid Build Coastguard Workerget(const tuple<_Tp...>&& __t) _NOEXCEPT
983*58b9f456SAndroid Build Coastguard Worker{
984*58b9f456SAndroid Build Coastguard Worker    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
985*58b9f456SAndroid Build Coastguard Worker    return static_cast<const type&&>(
986*58b9f456SAndroid Build Coastguard Worker             static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
987*58b9f456SAndroid Build Coastguard Worker}
988*58b9f456SAndroid Build Coastguard Worker
989*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11
990*58b9f456SAndroid Build Coastguard Worker
991*58b9f456SAndroid Build Coastguard Workernamespace __find_detail {
992*58b9f456SAndroid Build Coastguard Worker
993*58b9f456SAndroid Build Coastguard Workerstatic constexpr size_t __not_found = -1;
994*58b9f456SAndroid Build Coastguard Workerstatic constexpr size_t __ambiguous = __not_found - 1;
995*58b9f456SAndroid Build Coastguard Worker
996*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
997*58b9f456SAndroid Build Coastguard Workerconstexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
998*58b9f456SAndroid Build Coastguard Worker    return !__matches ? __res :
999*58b9f456SAndroid Build Coastguard Worker        (__res == __not_found ? __curr_i : __ambiguous);
1000*58b9f456SAndroid Build Coastguard Worker}
1001*58b9f456SAndroid Build Coastguard Worker
1002*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Nx>
1003*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1004*58b9f456SAndroid Build Coastguard Workerconstexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
1005*58b9f456SAndroid Build Coastguard Worker  return __i == _Nx ? __not_found :
1006*58b9f456SAndroid Build Coastguard Worker      __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]);
1007*58b9f456SAndroid Build Coastguard Worker}
1008*58b9f456SAndroid Build Coastguard Worker
1009*58b9f456SAndroid Build Coastguard Workertemplate <class _T1, class ..._Args>
1010*58b9f456SAndroid Build Coastguard Workerstruct __find_exactly_one_checked {
1011*58b9f456SAndroid Build Coastguard Worker    static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
1012*58b9f456SAndroid Build Coastguard Worker    static constexpr size_t value = __find_detail::__find_idx(0, __matches);
1013*58b9f456SAndroid Build Coastguard Worker    static_assert(value != __not_found, "type not found in type list" );
1014*58b9f456SAndroid Build Coastguard Worker    static_assert(value != __ambiguous, "type occurs more than once in type list");
1015*58b9f456SAndroid Build Coastguard Worker};
1016*58b9f456SAndroid Build Coastguard Worker
1017*58b9f456SAndroid Build Coastguard Workertemplate <class _T1>
1018*58b9f456SAndroid Build Coastguard Workerstruct __find_exactly_one_checked<_T1> {
1019*58b9f456SAndroid Build Coastguard Worker    static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
1020*58b9f456SAndroid Build Coastguard Worker};
1021*58b9f456SAndroid Build Coastguard Worker
1022*58b9f456SAndroid Build Coastguard Worker} // namespace __find_detail;
1023*58b9f456SAndroid Build Coastguard Worker
1024*58b9f456SAndroid Build Coastguard Workertemplate <typename _T1, typename... _Args>
1025*58b9f456SAndroid Build Coastguard Workerstruct __find_exactly_one_t
1026*58b9f456SAndroid Build Coastguard Worker    : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
1027*58b9f456SAndroid Build Coastguard Worker};
1028*58b9f456SAndroid Build Coastguard Worker
1029*58b9f456SAndroid Build Coastguard Workertemplate <class _T1, class... _Args>
1030*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1031*58b9f456SAndroid Build Coastguard Workerconstexpr _T1& get(tuple<_Args...>& __tup) noexcept
1032*58b9f456SAndroid Build Coastguard Worker{
1033*58b9f456SAndroid Build Coastguard Worker    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1034*58b9f456SAndroid Build Coastguard Worker}
1035*58b9f456SAndroid Build Coastguard Worker
1036*58b9f456SAndroid Build Coastguard Workertemplate <class _T1, class... _Args>
1037*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1038*58b9f456SAndroid Build Coastguard Workerconstexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
1039*58b9f456SAndroid Build Coastguard Worker{
1040*58b9f456SAndroid Build Coastguard Worker    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
1041*58b9f456SAndroid Build Coastguard Worker}
1042*58b9f456SAndroid Build Coastguard Worker
1043*58b9f456SAndroid Build Coastguard Workertemplate <class _T1, class... _Args>
1044*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1045*58b9f456SAndroid Build Coastguard Workerconstexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
1046*58b9f456SAndroid Build Coastguard Worker{
1047*58b9f456SAndroid Build Coastguard Worker    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1048*58b9f456SAndroid Build Coastguard Worker}
1049*58b9f456SAndroid Build Coastguard Worker
1050*58b9f456SAndroid Build Coastguard Workertemplate <class _T1, class... _Args>
1051*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1052*58b9f456SAndroid Build Coastguard Workerconstexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
1053*58b9f456SAndroid Build Coastguard Worker{
1054*58b9f456SAndroid Build Coastguard Worker    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
1055*58b9f456SAndroid Build Coastguard Worker}
1056*58b9f456SAndroid Build Coastguard Worker
1057*58b9f456SAndroid Build Coastguard Worker#endif
1058*58b9f456SAndroid Build Coastguard Worker
1059*58b9f456SAndroid Build Coastguard Worker// tie
1060*58b9f456SAndroid Build Coastguard Worker
1061*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp>
1062*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1063*58b9f456SAndroid Build Coastguard Workertuple<_Tp&...>
1064*58b9f456SAndroid Build Coastguard Workertie(_Tp&... __t) _NOEXCEPT
1065*58b9f456SAndroid Build Coastguard Worker{
1066*58b9f456SAndroid Build Coastguard Worker    return tuple<_Tp&...>(__t...);
1067*58b9f456SAndroid Build Coastguard Worker}
1068*58b9f456SAndroid Build Coastguard Worker
1069*58b9f456SAndroid Build Coastguard Workertemplate <class _Up>
1070*58b9f456SAndroid Build Coastguard Workerstruct __ignore_t
1071*58b9f456SAndroid Build Coastguard Worker{
1072*58b9f456SAndroid Build Coastguard Worker    template <class _Tp>
1073*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1074*58b9f456SAndroid Build Coastguard Worker    const __ignore_t& operator=(_Tp&&) const {return *this;}
1075*58b9f456SAndroid Build Coastguard Worker};
1076*58b9f456SAndroid Build Coastguard Worker
1077*58b9f456SAndroid Build Coastguard Workernamespace {
1078*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VAR constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
1079*58b9f456SAndroid Build Coastguard Worker}
1080*58b9f456SAndroid Build Coastguard Worker
1081*58b9f456SAndroid Build Coastguard Workertemplate <class... _Tp>
1082*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1083*58b9f456SAndroid Build Coastguard Workertuple<typename __unwrap_ref_decay<_Tp>::type...>
1084*58b9f456SAndroid Build Coastguard Workermake_tuple(_Tp&&... __t)
1085*58b9f456SAndroid Build Coastguard Worker{
1086*58b9f456SAndroid Build Coastguard Worker    return tuple<typename __unwrap_ref_decay<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
1087*58b9f456SAndroid Build Coastguard Worker}
1088*58b9f456SAndroid Build Coastguard Worker
1089*58b9f456SAndroid Build Coastguard Workertemplate <class... _Tp>
1090*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1091*58b9f456SAndroid Build Coastguard Workertuple<_Tp&&...>
1092*58b9f456SAndroid Build Coastguard Workerforward_as_tuple(_Tp&&... __t) _NOEXCEPT
1093*58b9f456SAndroid Build Coastguard Worker{
1094*58b9f456SAndroid Build Coastguard Worker    return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
1095*58b9f456SAndroid Build Coastguard Worker}
1096*58b9f456SAndroid Build Coastguard Worker
1097*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip>
1098*58b9f456SAndroid Build Coastguard Workerstruct __tuple_equal
1099*58b9f456SAndroid Build Coastguard Worker{
1100*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class _Up>
1101*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1102*58b9f456SAndroid Build Coastguard Worker    bool operator()(const _Tp& __x, const _Up& __y)
1103*58b9f456SAndroid Build Coastguard Worker    {
1104*58b9f456SAndroid Build Coastguard Worker        return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
1105*58b9f456SAndroid Build Coastguard Worker    }
1106*58b9f456SAndroid Build Coastguard Worker};
1107*58b9f456SAndroid Build Coastguard Worker
1108*58b9f456SAndroid Build Coastguard Workertemplate <>
1109*58b9f456SAndroid Build Coastguard Workerstruct __tuple_equal<0>
1110*58b9f456SAndroid Build Coastguard Worker{
1111*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class _Up>
1112*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1113*58b9f456SAndroid Build Coastguard Worker    bool operator()(const _Tp&, const _Up&)
1114*58b9f456SAndroid Build Coastguard Worker    {
1115*58b9f456SAndroid Build Coastguard Worker        return true;
1116*58b9f456SAndroid Build Coastguard Worker    }
1117*58b9f456SAndroid Build Coastguard Worker};
1118*58b9f456SAndroid Build Coastguard Worker
1119*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp, class ..._Up>
1120*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1121*58b9f456SAndroid Build Coastguard Workerbool
1122*58b9f456SAndroid Build Coastguard Workeroperator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1123*58b9f456SAndroid Build Coastguard Worker{
1124*58b9f456SAndroid Build Coastguard Worker    return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
1125*58b9f456SAndroid Build Coastguard Worker}
1126*58b9f456SAndroid Build Coastguard Worker
1127*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp, class ..._Up>
1128*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1129*58b9f456SAndroid Build Coastguard Workerbool
1130*58b9f456SAndroid Build Coastguard Workeroperator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1131*58b9f456SAndroid Build Coastguard Worker{
1132*58b9f456SAndroid Build Coastguard Worker    return !(__x == __y);
1133*58b9f456SAndroid Build Coastguard Worker}
1134*58b9f456SAndroid Build Coastguard Worker
1135*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Ip>
1136*58b9f456SAndroid Build Coastguard Workerstruct __tuple_less
1137*58b9f456SAndroid Build Coastguard Worker{
1138*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class _Up>
1139*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1140*58b9f456SAndroid Build Coastguard Worker    bool operator()(const _Tp& __x, const _Up& __y)
1141*58b9f456SAndroid Build Coastguard Worker    {
1142*58b9f456SAndroid Build Coastguard Worker        const size_t __idx = tuple_size<_Tp>::value - _Ip;
1143*58b9f456SAndroid Build Coastguard Worker        if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
1144*58b9f456SAndroid Build Coastguard Worker            return true;
1145*58b9f456SAndroid Build Coastguard Worker        if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
1146*58b9f456SAndroid Build Coastguard Worker            return false;
1147*58b9f456SAndroid Build Coastguard Worker        return __tuple_less<_Ip-1>()(__x, __y);
1148*58b9f456SAndroid Build Coastguard Worker    }
1149*58b9f456SAndroid Build Coastguard Worker};
1150*58b9f456SAndroid Build Coastguard Worker
1151*58b9f456SAndroid Build Coastguard Workertemplate <>
1152*58b9f456SAndroid Build Coastguard Workerstruct __tuple_less<0>
1153*58b9f456SAndroid Build Coastguard Worker{
1154*58b9f456SAndroid Build Coastguard Worker    template <class _Tp, class _Up>
1155*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1156*58b9f456SAndroid Build Coastguard Worker    bool operator()(const _Tp&, const _Up&)
1157*58b9f456SAndroid Build Coastguard Worker    {
1158*58b9f456SAndroid Build Coastguard Worker        return false;
1159*58b9f456SAndroid Build Coastguard Worker    }
1160*58b9f456SAndroid Build Coastguard Worker};
1161*58b9f456SAndroid Build Coastguard Worker
1162*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp, class ..._Up>
1163*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1164*58b9f456SAndroid Build Coastguard Workerbool
1165*58b9f456SAndroid Build Coastguard Workeroperator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1166*58b9f456SAndroid Build Coastguard Worker{
1167*58b9f456SAndroid Build Coastguard Worker    return __tuple_less<sizeof...(_Tp)>()(__x, __y);
1168*58b9f456SAndroid Build Coastguard Worker}
1169*58b9f456SAndroid Build Coastguard Worker
1170*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp, class ..._Up>
1171*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1172*58b9f456SAndroid Build Coastguard Workerbool
1173*58b9f456SAndroid Build Coastguard Workeroperator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1174*58b9f456SAndroid Build Coastguard Worker{
1175*58b9f456SAndroid Build Coastguard Worker    return __y < __x;
1176*58b9f456SAndroid Build Coastguard Worker}
1177*58b9f456SAndroid Build Coastguard Worker
1178*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp, class ..._Up>
1179*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1180*58b9f456SAndroid Build Coastguard Workerbool
1181*58b9f456SAndroid Build Coastguard Workeroperator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1182*58b9f456SAndroid Build Coastguard Worker{
1183*58b9f456SAndroid Build Coastguard Worker    return !(__x < __y);
1184*58b9f456SAndroid Build Coastguard Worker}
1185*58b9f456SAndroid Build Coastguard Worker
1186*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp, class ..._Up>
1187*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1188*58b9f456SAndroid Build Coastguard Workerbool
1189*58b9f456SAndroid Build Coastguard Workeroperator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1190*58b9f456SAndroid Build Coastguard Worker{
1191*58b9f456SAndroid Build Coastguard Worker    return !(__y < __x);
1192*58b9f456SAndroid Build Coastguard Worker}
1193*58b9f456SAndroid Build Coastguard Worker
1194*58b9f456SAndroid Build Coastguard Worker// tuple_cat
1195*58b9f456SAndroid Build Coastguard Worker
1196*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Up> struct __tuple_cat_type;
1197*58b9f456SAndroid Build Coastguard Worker
1198*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Ttypes, class ..._Utypes>
1199*58b9f456SAndroid Build Coastguard Workerstruct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
1200*58b9f456SAndroid Build Coastguard Worker{
1201*58b9f456SAndroid Build Coastguard Worker    typedef tuple<_Ttypes..., _Utypes...> type;
1202*58b9f456SAndroid Build Coastguard Worker};
1203*58b9f456SAndroid Build Coastguard Worker
1204*58b9f456SAndroid Build Coastguard Workertemplate <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
1205*58b9f456SAndroid Build Coastguard Workerstruct __tuple_cat_return_1
1206*58b9f456SAndroid Build Coastguard Worker{
1207*58b9f456SAndroid Build Coastguard Worker};
1208*58b9f456SAndroid Build Coastguard Worker
1209*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Types, class _Tuple0>
1210*58b9f456SAndroid Build Coastguard Workerstruct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
1211*58b9f456SAndroid Build Coastguard Worker{
1212*58b9f456SAndroid Build Coastguard Worker    typedef typename __tuple_cat_type<tuple<_Types...>,
1213*58b9f456SAndroid Build Coastguard Worker            typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
1214*58b9f456SAndroid Build Coastguard Worker                                                                           type;
1215*58b9f456SAndroid Build Coastguard Worker};
1216*58b9f456SAndroid Build Coastguard Worker
1217*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
1218*58b9f456SAndroid Build Coastguard Workerstruct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
1219*58b9f456SAndroid Build Coastguard Worker    : public __tuple_cat_return_1<
1220*58b9f456SAndroid Build Coastguard Worker                 typename __tuple_cat_type<
1221*58b9f456SAndroid Build Coastguard Worker                     tuple<_Types...>,
1222*58b9f456SAndroid Build Coastguard Worker                     typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
1223*58b9f456SAndroid Build Coastguard Worker                 >::type,
1224*58b9f456SAndroid Build Coastguard Worker                 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
1225*58b9f456SAndroid Build Coastguard Worker                 _Tuple1, _Tuples...>
1226*58b9f456SAndroid Build Coastguard Worker{
1227*58b9f456SAndroid Build Coastguard Worker};
1228*58b9f456SAndroid Build Coastguard Worker
1229*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tuples> struct __tuple_cat_return;
1230*58b9f456SAndroid Build Coastguard Worker
1231*58b9f456SAndroid Build Coastguard Workertemplate <class _Tuple0, class ..._Tuples>
1232*58b9f456SAndroid Build Coastguard Workerstruct __tuple_cat_return<_Tuple0, _Tuples...>
1233*58b9f456SAndroid Build Coastguard Worker    : public __tuple_cat_return_1<tuple<>,
1234*58b9f456SAndroid Build Coastguard Worker         __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
1235*58b9f456SAndroid Build Coastguard Worker                                                                     _Tuples...>
1236*58b9f456SAndroid Build Coastguard Worker{
1237*58b9f456SAndroid Build Coastguard Worker};
1238*58b9f456SAndroid Build Coastguard Worker
1239*58b9f456SAndroid Build Coastguard Workertemplate <>
1240*58b9f456SAndroid Build Coastguard Workerstruct __tuple_cat_return<>
1241*58b9f456SAndroid Build Coastguard Worker{
1242*58b9f456SAndroid Build Coastguard Worker    typedef tuple<> type;
1243*58b9f456SAndroid Build Coastguard Worker};
1244*58b9f456SAndroid Build Coastguard Worker
1245*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1246*58b9f456SAndroid Build Coastguard Workertuple<>
1247*58b9f456SAndroid Build Coastguard Workertuple_cat()
1248*58b9f456SAndroid Build Coastguard Worker{
1249*58b9f456SAndroid Build Coastguard Worker    return tuple<>();
1250*58b9f456SAndroid Build Coastguard Worker}
1251*58b9f456SAndroid Build Coastguard Worker
1252*58b9f456SAndroid Build Coastguard Workertemplate <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
1253*58b9f456SAndroid Build Coastguard Workerstruct __tuple_cat_return_ref_imp;
1254*58b9f456SAndroid Build Coastguard Worker
1255*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Types, size_t ..._I0, class _Tuple0>
1256*58b9f456SAndroid Build Coastguard Workerstruct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
1257*58b9f456SAndroid Build Coastguard Worker{
1258*58b9f456SAndroid Build Coastguard Worker    typedef typename remove_reference<_Tuple0>::type _T0;
1259*58b9f456SAndroid Build Coastguard Worker    typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1260*58b9f456SAndroid Build Coastguard Worker                          typename tuple_element<_I0, _T0>::type>::type&&...> type;
1261*58b9f456SAndroid Build Coastguard Worker};
1262*58b9f456SAndroid Build Coastguard Worker
1263*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
1264*58b9f456SAndroid Build Coastguard Workerstruct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1265*58b9f456SAndroid Build Coastguard Worker                                  _Tuple0, _Tuple1, _Tuples...>
1266*58b9f456SAndroid Build Coastguard Worker    : public __tuple_cat_return_ref_imp<
1267*58b9f456SAndroid Build Coastguard Worker         tuple<_Types..., typename __apply_cv<_Tuple0,
1268*58b9f456SAndroid Build Coastguard Worker               typename tuple_element<_I0,
1269*58b9f456SAndroid Build Coastguard Worker                  typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1270*58b9f456SAndroid Build Coastguard Worker         typename __make_tuple_indices<tuple_size<typename
1271*58b9f456SAndroid Build Coastguard Worker                                 remove_reference<_Tuple1>::type>::value>::type,
1272*58b9f456SAndroid Build Coastguard Worker         _Tuple1, _Tuples...>
1273*58b9f456SAndroid Build Coastguard Worker{
1274*58b9f456SAndroid Build Coastguard Worker};
1275*58b9f456SAndroid Build Coastguard Worker
1276*58b9f456SAndroid Build Coastguard Workertemplate <class _Tuple0, class ..._Tuples>
1277*58b9f456SAndroid Build Coastguard Workerstruct __tuple_cat_return_ref
1278*58b9f456SAndroid Build Coastguard Worker    : public __tuple_cat_return_ref_imp<tuple<>,
1279*58b9f456SAndroid Build Coastguard Worker               typename __make_tuple_indices<
1280*58b9f456SAndroid Build Coastguard Worker                        tuple_size<typename remove_reference<_Tuple0>::type>::value
1281*58b9f456SAndroid Build Coastguard Worker               >::type, _Tuple0, _Tuples...>
1282*58b9f456SAndroid Build Coastguard Worker{
1283*58b9f456SAndroid Build Coastguard Worker};
1284*58b9f456SAndroid Build Coastguard Worker
1285*58b9f456SAndroid Build Coastguard Workertemplate <class _Types, class _I0, class _J0>
1286*58b9f456SAndroid Build Coastguard Workerstruct __tuple_cat;
1287*58b9f456SAndroid Build Coastguard Worker
1288*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Types, size_t ..._I0, size_t ..._J0>
1289*58b9f456SAndroid Build Coastguard Workerstruct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
1290*58b9f456SAndroid Build Coastguard Worker{
1291*58b9f456SAndroid Build Coastguard Worker    template <class _Tuple0>
1292*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1293*58b9f456SAndroid Build Coastguard Worker    typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1294*58b9f456SAndroid Build Coastguard Worker    operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1295*58b9f456SAndroid Build Coastguard Worker    {
1296*58b9f456SAndroid Build Coastguard Worker        return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1297*58b9f456SAndroid Build Coastguard Worker                                      _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
1298*58b9f456SAndroid Build Coastguard Worker    }
1299*58b9f456SAndroid Build Coastguard Worker
1300*58b9f456SAndroid Build Coastguard Worker    template <class _Tuple0, class _Tuple1, class ..._Tuples>
1301*58b9f456SAndroid Build Coastguard Worker    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1302*58b9f456SAndroid Build Coastguard Worker    typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1303*58b9f456SAndroid Build Coastguard Worker    operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1304*58b9f456SAndroid Build Coastguard Worker    {
1305*58b9f456SAndroid Build Coastguard Worker        typedef typename remove_reference<_Tuple0>::type _T0;
1306*58b9f456SAndroid Build Coastguard Worker        typedef typename remove_reference<_Tuple1>::type _T1;
1307*58b9f456SAndroid Build Coastguard Worker        return __tuple_cat<
1308*58b9f456SAndroid Build Coastguard Worker           tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
1309*58b9f456SAndroid Build Coastguard Worker           typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
1310*58b9f456SAndroid Build Coastguard Worker           typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
1311*58b9f456SAndroid Build Coastguard Worker                           (forward_as_tuple(
1312*58b9f456SAndroid Build Coastguard Worker                              _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1313*58b9f456SAndroid Build Coastguard Worker                              _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
1314*58b9f456SAndroid Build Coastguard Worker                            ),
1315*58b9f456SAndroid Build Coastguard Worker                            _VSTD::forward<_Tuple1>(__t1),
1316*58b9f456SAndroid Build Coastguard Worker                            _VSTD::forward<_Tuples>(__tpls)...);
1317*58b9f456SAndroid Build Coastguard Worker    }
1318*58b9f456SAndroid Build Coastguard Worker};
1319*58b9f456SAndroid Build Coastguard Worker
1320*58b9f456SAndroid Build Coastguard Workertemplate <class _Tuple0, class... _Tuples>
1321*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1322*58b9f456SAndroid Build Coastguard Workertypename __tuple_cat_return<_Tuple0, _Tuples...>::type
1323*58b9f456SAndroid Build Coastguard Workertuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1324*58b9f456SAndroid Build Coastguard Worker{
1325*58b9f456SAndroid Build Coastguard Worker    typedef typename remove_reference<_Tuple0>::type _T0;
1326*58b9f456SAndroid Build Coastguard Worker    return __tuple_cat<tuple<>, __tuple_indices<>,
1327*58b9f456SAndroid Build Coastguard Worker                  typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
1328*58b9f456SAndroid Build Coastguard Worker                  (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
1329*58b9f456SAndroid Build Coastguard Worker                                            _VSTD::forward<_Tuples>(__tpls)...);
1330*58b9f456SAndroid Build Coastguard Worker}
1331*58b9f456SAndroid Build Coastguard Worker
1332*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Tp, class _Alloc>
1333*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
1334*58b9f456SAndroid Build Coastguard Worker    : true_type {};
1335*58b9f456SAndroid Build Coastguard Worker
1336*58b9f456SAndroid Build Coastguard Workertemplate <class _T1, class _T2>
1337*58b9f456SAndroid Build Coastguard Workertemplate <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1338*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1339*58b9f456SAndroid Build Coastguard Workerpair<_T1, _T2>::pair(piecewise_construct_t,
1340*58b9f456SAndroid Build Coastguard Worker                     tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1341*58b9f456SAndroid Build Coastguard Worker                     __tuple_indices<_I1...>, __tuple_indices<_I2...>)
1342*58b9f456SAndroid Build Coastguard Worker    :  first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
1343*58b9f456SAndroid Build Coastguard Worker      second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
1344*58b9f456SAndroid Build Coastguard Worker{
1345*58b9f456SAndroid Build Coastguard Worker}
1346*58b9f456SAndroid Build Coastguard Worker
1347*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
1348*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
1349*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
1350*58b9f456SAndroid Build Coastguard Worker
1351*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
1352*58b9f456SAndroid Build Coastguard Worker
1353*58b9f456SAndroid Build Coastguard Workertemplate <class _Fn, class _Tuple, size_t ..._Id>
1354*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1355*58b9f456SAndroid Build Coastguard Workerconstexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
1356*58b9f456SAndroid Build Coastguard Worker                                            __tuple_indices<_Id...>)
1357*58b9f456SAndroid Build Coastguard Worker_LIBCPP_NOEXCEPT_RETURN(
1358*58b9f456SAndroid Build Coastguard Worker    _VSTD::__invoke_constexpr(
1359*58b9f456SAndroid Build Coastguard Worker        _VSTD::forward<_Fn>(__f),
1360*58b9f456SAndroid Build Coastguard Worker        _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...)
1361*58b9f456SAndroid Build Coastguard Worker)
1362*58b9f456SAndroid Build Coastguard Worker
1363*58b9f456SAndroid Build Coastguard Workertemplate <class _Fn, class _Tuple>
1364*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1365*58b9f456SAndroid Build Coastguard Workerconstexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
1366*58b9f456SAndroid Build Coastguard Worker_LIBCPP_NOEXCEPT_RETURN(
1367*58b9f456SAndroid Build Coastguard Worker    _VSTD::__apply_tuple_impl(
1368*58b9f456SAndroid Build Coastguard Worker        _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
1369*58b9f456SAndroid Build Coastguard Worker        typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
1370*58b9f456SAndroid Build Coastguard Worker)
1371*58b9f456SAndroid Build Coastguard Worker
1372*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Tuple, size_t... _Idx>
1373*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1374*58b9f456SAndroid Build Coastguard Workerconstexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
1375*58b9f456SAndroid Build Coastguard Worker_LIBCPP_NOEXCEPT_RETURN(
1376*58b9f456SAndroid Build Coastguard Worker    _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...)
1377*58b9f456SAndroid Build Coastguard Worker)
1378*58b9f456SAndroid Build Coastguard Worker
1379*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp, class _Tuple>
1380*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
1381*58b9f456SAndroid Build Coastguard Workerconstexpr _Tp make_from_tuple(_Tuple&& __t)
1382*58b9f456SAndroid Build Coastguard Worker_LIBCPP_NOEXCEPT_RETURN(
1383*58b9f456SAndroid Build Coastguard Worker    _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
1384*58b9f456SAndroid Build Coastguard Worker        typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
1385*58b9f456SAndroid Build Coastguard Worker)
1386*58b9f456SAndroid Build Coastguard Worker
1387*58b9f456SAndroid Build Coastguard Worker#undef _LIBCPP_NOEXCEPT_RETURN
1388*58b9f456SAndroid Build Coastguard Worker
1389*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_STD_VER > 14
1390*58b9f456SAndroid Build Coastguard Worker
1391*58b9f456SAndroid Build Coastguard Worker#endif // !defined(_LIBCPP_CXX03_LANG)
1392*58b9f456SAndroid Build Coastguard Worker
1393*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
1394*58b9f456SAndroid Build Coastguard Worker
1395*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_TUPLE
1396