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