xref: /minix3/external/bsd/libc++/dist/libcxx/include/tuple (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
14684ddb6SLionel Sambuc// -*- C++ -*-
24684ddb6SLionel Sambuc//===--------------------------- tuple ------------------------------------===//
34684ddb6SLionel Sambuc//
44684ddb6SLionel Sambuc//                     The LLVM Compiler Infrastructure
54684ddb6SLionel Sambuc//
64684ddb6SLionel Sambuc// This file is distributed under the University of Illinois Open Source
74684ddb6SLionel Sambuc// License. See LICENSE.TXT for details.
84684ddb6SLionel Sambuc//
94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===//
104684ddb6SLionel Sambuc
114684ddb6SLionel Sambuc#ifndef _LIBCPP_TUPLE
124684ddb6SLionel Sambuc#define _LIBCPP_TUPLE
134684ddb6SLionel Sambuc
144684ddb6SLionel Sambuc/*
154684ddb6SLionel Sambuc    tuple synopsis
164684ddb6SLionel Sambuc
174684ddb6SLionel Sambucnamespace std
184684ddb6SLionel Sambuc{
194684ddb6SLionel Sambuc
204684ddb6SLionel Sambuctemplate <class... T>
214684ddb6SLionel Sambucclass tuple {
224684ddb6SLionel Sambucpublic:
234684ddb6SLionel Sambuc    constexpr tuple();
244684ddb6SLionel Sambuc    explicit tuple(const T&...);  // constexpr in C++14
254684ddb6SLionel Sambuc    template <class... U>
264684ddb6SLionel Sambuc        explicit tuple(U&&...);  // constexpr in C++14
274684ddb6SLionel Sambuc    tuple(const tuple&) = default;
284684ddb6SLionel Sambuc    tuple(tuple&&) = default;
294684ddb6SLionel Sambuc    template <class... U>
304684ddb6SLionel Sambuc        tuple(const tuple<U...>&);  // constexpr in C++14
314684ddb6SLionel Sambuc    template <class... U>
324684ddb6SLionel Sambuc        tuple(tuple<U...>&&);  // constexpr in C++14
334684ddb6SLionel Sambuc    template <class U1, class U2>
344684ddb6SLionel Sambuc        tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
354684ddb6SLionel Sambuc    template <class U1, class U2>
364684ddb6SLionel Sambuc        tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2  // constexpr in C++14
374684ddb6SLionel Sambuc
384684ddb6SLionel Sambuc    // allocator-extended constructors
394684ddb6SLionel Sambuc    template <class Alloc>
404684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a);
414684ddb6SLionel Sambuc    template <class Alloc>
424684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, const T&...);
434684ddb6SLionel Sambuc    template <class Alloc, class... U>
444684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, U&&...);
454684ddb6SLionel Sambuc    template <class Alloc>
464684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, const tuple&);
474684ddb6SLionel Sambuc    template <class Alloc>
484684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, tuple&&);
494684ddb6SLionel Sambuc    template <class Alloc, class... U>
504684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
514684ddb6SLionel Sambuc    template <class Alloc, class... U>
524684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
534684ddb6SLionel Sambuc    template <class Alloc, class U1, class U2>
544684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
554684ddb6SLionel Sambuc    template <class Alloc, class U1, class U2>
564684ddb6SLionel Sambuc        tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
574684ddb6SLionel Sambuc
584684ddb6SLionel Sambuc    tuple& operator=(const tuple&);
594684ddb6SLionel Sambuc    tuple&
604684ddb6SLionel Sambuc        operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
614684ddb6SLionel Sambuc    template <class... U>
624684ddb6SLionel Sambuc        tuple& operator=(const tuple<U...>&);
634684ddb6SLionel Sambuc    template <class... U>
644684ddb6SLionel Sambuc        tuple& operator=(tuple<U...>&&);
654684ddb6SLionel Sambuc    template <class U1, class U2>
664684ddb6SLionel Sambuc        tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
674684ddb6SLionel Sambuc    template <class U1, class U2>
684684ddb6SLionel Sambuc        tuple& operator=(pair<U1, U2>&&); //iffsizeof...(T) == 2
694684ddb6SLionel Sambuc
704684ddb6SLionel Sambuc    void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
714684ddb6SLionel Sambuc};
724684ddb6SLionel Sambuc
734684ddb6SLionel Sambucconst unspecified ignore;
744684ddb6SLionel Sambuc
754684ddb6SLionel Sambuctemplate <class... T> tuple<V...>  make_tuple(T&&...); // constexpr in C++14
764684ddb6SLionel Sambuctemplate <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
77*0a6a1f1dSLionel Sambuctemplate <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
784684ddb6SLionel Sambuctemplate <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
794684ddb6SLionel Sambuc
804684ddb6SLionel Sambuc// 20.4.1.4, tuple helper classes:
814684ddb6SLionel Sambuctemplate <class T> class tuple_size; // undefined
824684ddb6SLionel Sambuctemplate <class... T> class tuple_size<tuple<T...>>;
834684ddb6SLionel Sambuctemplate <intsize_t I, class T> class tuple_element; // undefined
844684ddb6SLionel Sambuctemplate <intsize_t I, class... T> class tuple_element<I, tuple<T...>>;
85*0a6a1f1dSLionel Sambuctemplate <size_t _Ip, class ..._Tp>
86*0a6a1f1dSLionel Sambuc  using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // C++14
874684ddb6SLionel Sambuc
884684ddb6SLionel Sambuc// 20.4.1.5, element access:
894684ddb6SLionel Sambuctemplate <intsize_t I, class... T>
904684ddb6SLionel Sambuc    typename tuple_element<I, tuple<T...>>::type&
914684ddb6SLionel Sambuc    get(tuple<T...>&) noexcept; // constexpr in C++14
924684ddb6SLionel Sambuctemplate <intsize_t I, class... T>
93*0a6a1f1dSLionel Sambuc    typename const tuple_element<I, tuple<T...>>::type &
944684ddb6SLionel Sambuc    get(const tuple<T...>&) noexcept; // constexpr in C++14
954684ddb6SLionel Sambuctemplate <intsize_t I, class... T>
964684ddb6SLionel Sambuc    typename tuple_element<I, tuple<T...>>::type&&
974684ddb6SLionel Sambuc    get(tuple<T...>&&) noexcept; // constexpr in C++14
984684ddb6SLionel Sambuc
994684ddb6SLionel Sambuctemplate <class T1, class... T>
1004684ddb6SLionel Sambuc    constexpr T1& get(tuple<T...>&) noexcept;  // C++14
1014684ddb6SLionel Sambuctemplate <class T1, class... T>
1024684ddb6SLionel Sambuc    constexpr T1 const& get(const tuple<T...>&) noexcept;   // C++14
1034684ddb6SLionel Sambuctemplate <class T1, class... T>
1044684ddb6SLionel Sambuc    constexpr T1&& get(tuple<T...>&&) noexcept;   // C++14
1054684ddb6SLionel Sambuc
1064684ddb6SLionel Sambuc// 20.4.1.6, relational operators:
1074684ddb6SLionel Sambuctemplate<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
1084684ddb6SLionel Sambuctemplate<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&);  // constexpr in C++14
1094684ddb6SLionel Sambuctemplate<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
1104684ddb6SLionel Sambuctemplate<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&);  // constexpr in C++14
1114684ddb6SLionel Sambuctemplate<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
1124684ddb6SLionel Sambuctemplate<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
1134684ddb6SLionel Sambuc
1144684ddb6SLionel Sambuctemplate <class... Types, class Alloc>
1154684ddb6SLionel Sambuc  struct uses_allocator<tuple<Types...>, Alloc>;
1164684ddb6SLionel Sambuc
1174684ddb6SLionel Sambuctemplate <class... Types>
1184684ddb6SLionel Sambuc  void
1194684ddb6SLionel Sambuc  swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
1204684ddb6SLionel Sambuc
1214684ddb6SLionel Sambuc}  // std
1224684ddb6SLionel Sambuc
1234684ddb6SLionel Sambuc*/
1244684ddb6SLionel Sambuc
1254684ddb6SLionel Sambuc#include <__config>
1264684ddb6SLionel Sambuc#include <__tuple>
1274684ddb6SLionel Sambuc#include <cstddef>
1284684ddb6SLionel Sambuc#include <type_traits>
1294684ddb6SLionel Sambuc#include <__functional_base>
1304684ddb6SLionel Sambuc#include <utility>
1314684ddb6SLionel Sambuc
1324684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1334684ddb6SLionel Sambuc#pragma GCC system_header
1344684ddb6SLionel Sambuc#endif
1354684ddb6SLionel Sambuc
1364684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD
1374684ddb6SLionel Sambuc
1384684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS
1394684ddb6SLionel Sambuc
1404684ddb6SLionel Sambuc// tuple_size
1414684ddb6SLionel Sambuc
1424684ddb6SLionel Sambuctemplate <class ..._Tp>
1434684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY tuple_size<tuple<_Tp...> >
1444684ddb6SLionel Sambuc    : public integral_constant<size_t, sizeof...(_Tp)>
1454684ddb6SLionel Sambuc{
1464684ddb6SLionel Sambuc};
1474684ddb6SLionel Sambuc
1484684ddb6SLionel Sambuc// tuple_element
1494684ddb6SLionel Sambuc
1504684ddb6SLionel Sambuctemplate <size_t _Ip, class ..._Tp>
1514684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> >
1524684ddb6SLionel Sambuc{
1534684ddb6SLionel Sambucpublic:
1544684ddb6SLionel Sambuc    typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
1554684ddb6SLionel Sambuc};
1564684ddb6SLionel Sambuc
157*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER > 11
158*0a6a1f1dSLionel Sambuctemplate <size_t _Ip, class ..._Tp>
159*0a6a1f1dSLionel Sambucusing tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
160*0a6a1f1dSLionel Sambuc#endif
161*0a6a1f1dSLionel Sambuc
1624684ddb6SLionel Sambuc// __tuple_leaf
1634684ddb6SLionel Sambuc
164*0a6a1f1dSLionel Sambuctemplate <size_t _Ip, class _Hp,
165*0a6a1f1dSLionel Sambuc          bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
1664684ddb6SLionel Sambuc         >
1674684ddb6SLionel Sambucclass __tuple_leaf;
1684684ddb6SLionel Sambuc
1694684ddb6SLionel Sambuctemplate <size_t _Ip, class _Hp, bool _Ep>
1704684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1714684ddb6SLionel Sambucvoid swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
1724684ddb6SLionel Sambuc    _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
1734684ddb6SLionel Sambuc{
1744684ddb6SLionel Sambuc    swap(__x.get(), __y.get());
1754684ddb6SLionel Sambuc}
1764684ddb6SLionel Sambuc
1774684ddb6SLionel Sambuctemplate <size_t _Ip, class _Hp, bool>
1784684ddb6SLionel Sambucclass __tuple_leaf
1794684ddb6SLionel Sambuc{
1804684ddb6SLionel Sambuc    _Hp value;
1814684ddb6SLionel Sambuc
1824684ddb6SLionel Sambuc    __tuple_leaf& operator=(const __tuple_leaf&);
1834684ddb6SLionel Sambucpublic:
1844684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
1854684ddb6SLionel Sambuc             _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value()
1864684ddb6SLionel Sambuc       {static_assert(!is_reference<_Hp>::value,
1874684ddb6SLionel Sambuc              "Attempted to default construct a reference element in a tuple");}
1884684ddb6SLionel Sambuc
1894684ddb6SLionel Sambuc    template <class _Alloc>
1904684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
1914684ddb6SLionel Sambuc        __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
1924684ddb6SLionel Sambuc            : value()
1934684ddb6SLionel Sambuc        {static_assert(!is_reference<_Hp>::value,
1944684ddb6SLionel Sambuc              "Attempted to default construct a reference element in a tuple");}
1954684ddb6SLionel Sambuc
1964684ddb6SLionel Sambuc    template <class _Alloc>
1974684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
1984684ddb6SLionel Sambuc        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
1994684ddb6SLionel Sambuc            : value(allocator_arg_t(), __a)
2004684ddb6SLionel Sambuc        {static_assert(!is_reference<_Hp>::value,
2014684ddb6SLionel Sambuc              "Attempted to default construct a reference element in a tuple");}
2024684ddb6SLionel Sambuc
2034684ddb6SLionel Sambuc    template <class _Alloc>
2044684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
2054684ddb6SLionel Sambuc        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
2064684ddb6SLionel Sambuc            : value(__a)
2074684ddb6SLionel Sambuc        {static_assert(!is_reference<_Hp>::value,
2084684ddb6SLionel Sambuc              "Attempted to default construct a reference element in a tuple");}
2094684ddb6SLionel Sambuc
2104684ddb6SLionel Sambuc    template <class _Tp,
211*0a6a1f1dSLionel Sambuc              class = typename enable_if<
212*0a6a1f1dSLionel Sambuc                  __lazy_and<
213*0a6a1f1dSLionel Sambuc                      __lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
214*0a6a1f1dSLionel Sambuc                    , is_constructible<_Hp, _Tp>
215*0a6a1f1dSLionel Sambuc                    >::value
216*0a6a1f1dSLionel Sambuc                >::type
217*0a6a1f1dSLionel Sambuc            >
2184684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
2194684ddb6SLionel Sambuc        explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
2204684ddb6SLionel Sambuc            : value(_VSTD::forward<_Tp>(__t))
2214684ddb6SLionel Sambuc        {static_assert(!is_reference<_Hp>::value ||
2224684ddb6SLionel Sambuc                       (is_lvalue_reference<_Hp>::value &&
2234684ddb6SLionel Sambuc                        (is_lvalue_reference<_Tp>::value ||
2244684ddb6SLionel Sambuc                         is_same<typename remove_reference<_Tp>::type,
2254684ddb6SLionel Sambuc                                 reference_wrapper<
2264684ddb6SLionel Sambuc                                    typename remove_reference<_Hp>::type
2274684ddb6SLionel Sambuc                                 >
2284684ddb6SLionel Sambuc                                >::value)) ||
2294684ddb6SLionel Sambuc                        (is_rvalue_reference<_Hp>::value &&
2304684ddb6SLionel Sambuc                         !is_lvalue_reference<_Tp>::value),
2314684ddb6SLionel Sambuc       "Attempted to construct a reference element in a tuple with an rvalue");}
2324684ddb6SLionel Sambuc
2334684ddb6SLionel Sambuc    template <class _Tp, class _Alloc>
2344684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
2354684ddb6SLionel Sambuc        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
2364684ddb6SLionel Sambuc            : value(_VSTD::forward<_Tp>(__t))
2374684ddb6SLionel Sambuc        {static_assert(!is_lvalue_reference<_Hp>::value ||
2384684ddb6SLionel Sambuc                       (is_lvalue_reference<_Hp>::value &&
2394684ddb6SLionel Sambuc                        (is_lvalue_reference<_Tp>::value ||
2404684ddb6SLionel Sambuc                         is_same<typename remove_reference<_Tp>::type,
2414684ddb6SLionel Sambuc                                 reference_wrapper<
2424684ddb6SLionel Sambuc                                    typename remove_reference<_Hp>::type
2434684ddb6SLionel Sambuc                                 >
2444684ddb6SLionel Sambuc                                >::value)),
2454684ddb6SLionel Sambuc       "Attempted to construct a reference element in a tuple with an rvalue");}
2464684ddb6SLionel Sambuc
2474684ddb6SLionel Sambuc    template <class _Tp, class _Alloc>
2484684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
2494684ddb6SLionel Sambuc        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
2504684ddb6SLionel Sambuc            : value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
2514684ddb6SLionel Sambuc        {static_assert(!is_lvalue_reference<_Hp>::value ||
2524684ddb6SLionel Sambuc                       (is_lvalue_reference<_Hp>::value &&
2534684ddb6SLionel Sambuc                        (is_lvalue_reference<_Tp>::value ||
2544684ddb6SLionel Sambuc                         is_same<typename remove_reference<_Tp>::type,
2554684ddb6SLionel Sambuc                                 reference_wrapper<
2564684ddb6SLionel Sambuc                                    typename remove_reference<_Hp>::type
2574684ddb6SLionel Sambuc                                 >
2584684ddb6SLionel Sambuc                                >::value)),
2594684ddb6SLionel Sambuc       "Attempted to construct a reference element in a tuple with an rvalue");}
2604684ddb6SLionel Sambuc
2614684ddb6SLionel Sambuc    template <class _Tp, class _Alloc>
2624684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
2634684ddb6SLionel Sambuc        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
2644684ddb6SLionel Sambuc            : value(_VSTD::forward<_Tp>(__t), __a)
2654684ddb6SLionel Sambuc        {static_assert(!is_lvalue_reference<_Hp>::value ||
2664684ddb6SLionel Sambuc                       (is_lvalue_reference<_Hp>::value &&
2674684ddb6SLionel Sambuc                        (is_lvalue_reference<_Tp>::value ||
2684684ddb6SLionel Sambuc                         is_same<typename remove_reference<_Tp>::type,
2694684ddb6SLionel Sambuc                                 reference_wrapper<
2704684ddb6SLionel Sambuc                                    typename remove_reference<_Hp>::type
2714684ddb6SLionel Sambuc                                 >
2724684ddb6SLionel Sambuc                                >::value)),
2734684ddb6SLionel Sambuc       "Attempted to construct a reference element in a tuple with an rvalue");}
2744684ddb6SLionel Sambuc
275*0a6a1f1dSLionel Sambuc    __tuple_leaf(const __tuple_leaf& __t) = default;
276*0a6a1f1dSLionel Sambuc    __tuple_leaf(__tuple_leaf&& __t) = default;
2774684ddb6SLionel Sambuc
2784684ddb6SLionel Sambuc    template <class _Tp>
2794684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
2804684ddb6SLionel Sambuc        __tuple_leaf&
2814684ddb6SLionel Sambuc        operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
2824684ddb6SLionel Sambuc        {
2834684ddb6SLionel Sambuc            value = _VSTD::forward<_Tp>(__t);
2844684ddb6SLionel Sambuc            return *this;
2854684ddb6SLionel Sambuc        }
2864684ddb6SLionel Sambuc
2874684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2884684ddb6SLionel Sambuc    int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
2894684ddb6SLionel Sambuc    {
2904684ddb6SLionel Sambuc        _VSTD::swap(*this, __t);
2914684ddb6SLionel Sambuc        return 0;
2924684ddb6SLionel Sambuc    }
2934684ddb6SLionel Sambuc
2944684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11       _Hp& get()       _NOEXCEPT {return value;}
2954684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return value;}
2964684ddb6SLionel Sambuc};
2974684ddb6SLionel Sambuc
2984684ddb6SLionel Sambuctemplate <size_t _Ip, class _Hp>
2994684ddb6SLionel Sambucclass __tuple_leaf<_Ip, _Hp, true>
3004684ddb6SLionel Sambuc    : private _Hp
3014684ddb6SLionel Sambuc{
3024684ddb6SLionel Sambuc
3034684ddb6SLionel Sambuc    __tuple_leaf& operator=(const __tuple_leaf&);
3044684ddb6SLionel Sambucpublic:
3054684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
3064684ddb6SLionel Sambuc             _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
3074684ddb6SLionel Sambuc
3084684ddb6SLionel Sambuc    template <class _Alloc>
3094684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
3104684ddb6SLionel Sambuc        __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
3114684ddb6SLionel Sambuc
3124684ddb6SLionel Sambuc    template <class _Alloc>
3134684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
3144684ddb6SLionel Sambuc        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
3154684ddb6SLionel Sambuc            : _Hp(allocator_arg_t(), __a) {}
3164684ddb6SLionel Sambuc
3174684ddb6SLionel Sambuc    template <class _Alloc>
3184684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
3194684ddb6SLionel Sambuc        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
3204684ddb6SLionel Sambuc            : _Hp(__a) {}
3214684ddb6SLionel Sambuc
3224684ddb6SLionel Sambuc    template <class _Tp,
323*0a6a1f1dSLionel Sambuc              class = typename enable_if<
324*0a6a1f1dSLionel Sambuc                  __lazy_and<
325*0a6a1f1dSLionel Sambuc                        __lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
326*0a6a1f1dSLionel Sambuc                      , is_constructible<_Hp, _Tp>
327*0a6a1f1dSLionel Sambuc                    >::value
328*0a6a1f1dSLionel Sambuc                >::type
329*0a6a1f1dSLionel Sambuc            >
3304684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
3314684ddb6SLionel Sambuc        explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
3324684ddb6SLionel Sambuc            : _Hp(_VSTD::forward<_Tp>(__t)) {}
3334684ddb6SLionel Sambuc
3344684ddb6SLionel Sambuc    template <class _Tp, class _Alloc>
3354684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
3364684ddb6SLionel Sambuc        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
3374684ddb6SLionel Sambuc            : _Hp(_VSTD::forward<_Tp>(__t)) {}
3384684ddb6SLionel Sambuc
3394684ddb6SLionel Sambuc    template <class _Tp, class _Alloc>
3404684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
3414684ddb6SLionel Sambuc        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
3424684ddb6SLionel Sambuc            : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
3434684ddb6SLionel Sambuc
3444684ddb6SLionel Sambuc    template <class _Tp, class _Alloc>
3454684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
3464684ddb6SLionel Sambuc        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
3474684ddb6SLionel Sambuc            : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
3484684ddb6SLionel Sambuc
349*0a6a1f1dSLionel Sambuc    __tuple_leaf(__tuple_leaf const &) = default;
350*0a6a1f1dSLionel Sambuc    __tuple_leaf(__tuple_leaf &&) = default;
351*0a6a1f1dSLionel Sambuc
3524684ddb6SLionel Sambuc    template <class _Tp>
3534684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
3544684ddb6SLionel Sambuc        __tuple_leaf&
3554684ddb6SLionel Sambuc        operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
3564684ddb6SLionel Sambuc        {
3574684ddb6SLionel Sambuc            _Hp::operator=(_VSTD::forward<_Tp>(__t));
3584684ddb6SLionel Sambuc            return *this;
3594684ddb6SLionel Sambuc        }
3604684ddb6SLionel Sambuc
3614684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
3624684ddb6SLionel Sambuc    int
3634684ddb6SLionel Sambuc    swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
3644684ddb6SLionel Sambuc    {
3654684ddb6SLionel Sambuc        _VSTD::swap(*this, __t);
3664684ddb6SLionel Sambuc        return 0;
3674684ddb6SLionel Sambuc    }
3684684ddb6SLionel Sambuc
3694684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11       _Hp& get()       _NOEXCEPT {return static_cast<_Hp&>(*this);}
3704684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
3714684ddb6SLionel Sambuc};
3724684ddb6SLionel Sambuc
3734684ddb6SLionel Sambuctemplate <class ..._Tp>
3744684ddb6SLionel Sambuc_LIBCPP_INLINE_VISIBILITY
3754684ddb6SLionel Sambucvoid __swallow(_Tp&&...) _NOEXCEPT {}
3764684ddb6SLionel Sambuc
377*0a6a1f1dSLionel Sambuctemplate <bool ..._Pred>
378*0a6a1f1dSLionel Sambucstruct __all
379*0a6a1f1dSLionel Sambuc    : is_same<__all<_Pred...>, __all<(_Pred, true)...>>
380*0a6a1f1dSLionel Sambuc{ };
3814684ddb6SLionel Sambuc
382*0a6a1f1dSLionel Sambuctemplate <class _Tp>
383*0a6a1f1dSLionel Sambucstruct __all_default_constructible;
3844684ddb6SLionel Sambuc
385*0a6a1f1dSLionel Sambuctemplate <class ..._Tp>
386*0a6a1f1dSLionel Sambucstruct __all_default_constructible<__tuple_types<_Tp...>>
387*0a6a1f1dSLionel Sambuc    : __all<is_default_constructible<_Tp>::value...>
388*0a6a1f1dSLionel Sambuc{ };
3894684ddb6SLionel Sambuc
3904684ddb6SLionel Sambuc// __tuple_impl
3914684ddb6SLionel Sambuc
3924684ddb6SLionel Sambuctemplate<class _Indx, class ..._Tp> struct __tuple_impl;
3934684ddb6SLionel Sambuc
3944684ddb6SLionel Sambuctemplate<size_t ..._Indx, class ..._Tp>
3954684ddb6SLionel Sambucstruct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
3964684ddb6SLionel Sambuc    : public __tuple_leaf<_Indx, _Tp>...
3974684ddb6SLionel Sambuc{
3984684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
3994684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR __tuple_impl()
4004684ddb6SLionel Sambuc        _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
4014684ddb6SLionel Sambuc
4024684ddb6SLionel Sambuc    template <size_t ..._Uf, class ..._Tf,
4034684ddb6SLionel Sambuc              size_t ..._Ul, class ..._Tl, class ..._Up>
4044684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
4054684ddb6SLionel Sambuc        explicit
4064684ddb6SLionel Sambuc        __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
4074684ddb6SLionel Sambuc                     __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
4084684ddb6SLionel Sambuc                     _Up&&... __u)
4094684ddb6SLionel Sambuc                     _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
4104684ddb6SLionel Sambuc                                 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
4114684ddb6SLionel Sambuc            __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
4124684ddb6SLionel Sambuc            __tuple_leaf<_Ul, _Tl>()...
4134684ddb6SLionel Sambuc            {}
4144684ddb6SLionel Sambuc
4154684ddb6SLionel Sambuc    template <class _Alloc, size_t ..._Uf, class ..._Tf,
4164684ddb6SLionel Sambuc              size_t ..._Ul, class ..._Tl, class ..._Up>
4174684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
4184684ddb6SLionel Sambuc        explicit
4194684ddb6SLionel Sambuc        __tuple_impl(allocator_arg_t, const _Alloc& __a,
4204684ddb6SLionel Sambuc                     __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
4214684ddb6SLionel Sambuc                     __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
4224684ddb6SLionel Sambuc                     _Up&&... __u) :
4234684ddb6SLionel Sambuc            __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
4244684ddb6SLionel Sambuc            _VSTD::forward<_Up>(__u))...,
4254684ddb6SLionel Sambuc            __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
4264684ddb6SLionel Sambuc            {}
4274684ddb6SLionel Sambuc
4284684ddb6SLionel Sambuc    template <class _Tuple,
4294684ddb6SLionel Sambuc              class = typename enable_if
4304684ddb6SLionel Sambuc                      <
4314684ddb6SLionel Sambuc                         __tuple_constructible<_Tuple, tuple<_Tp...> >::value
4324684ddb6SLionel Sambuc                      >::type
4334684ddb6SLionel Sambuc             >
4344684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
4354684ddb6SLionel Sambuc        __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
4364684ddb6SLionel Sambuc                                       typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
4374684ddb6SLionel Sambuc            : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
4384684ddb6SLionel Sambuc                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
4394684ddb6SLionel Sambuc            {}
4404684ddb6SLionel Sambuc
4414684ddb6SLionel Sambuc    template <class _Alloc, class _Tuple,
4424684ddb6SLionel Sambuc              class = typename enable_if
4434684ddb6SLionel Sambuc                      <
4444684ddb6SLionel Sambuc                         __tuple_convertible<_Tuple, tuple<_Tp...> >::value
4454684ddb6SLionel Sambuc                      >::type
4464684ddb6SLionel Sambuc             >
4474684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
4484684ddb6SLionel Sambuc        __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
4494684ddb6SLionel Sambuc            : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
4504684ddb6SLionel Sambuc                                       typename __make_tuple_types<_Tuple>::type>::type>(), __a,
4514684ddb6SLionel Sambuc                                       _VSTD::forward<typename tuple_element<_Indx,
4524684ddb6SLionel Sambuc                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
4534684ddb6SLionel Sambuc            {}
4544684ddb6SLionel Sambuc
4554684ddb6SLionel Sambuc    template <class _Tuple>
4564684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
4574684ddb6SLionel Sambuc        typename enable_if
4584684ddb6SLionel Sambuc        <
4594684ddb6SLionel Sambuc            __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
4604684ddb6SLionel Sambuc            __tuple_impl&
4614684ddb6SLionel Sambuc        >::type
4624684ddb6SLionel Sambuc        operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
4634684ddb6SLionel Sambuc                                       typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
4644684ddb6SLionel Sambuc        {
4654684ddb6SLionel Sambuc            __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
4664684ddb6SLionel Sambuc                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
4674684ddb6SLionel Sambuc            return *this;
4684684ddb6SLionel Sambuc        }
4694684ddb6SLionel Sambuc
4704684ddb6SLionel Sambuc    __tuple_impl(const __tuple_impl&) = default;
4714684ddb6SLionel Sambuc    __tuple_impl(__tuple_impl&&) = default;
4724684ddb6SLionel Sambuc
4734684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
4744684ddb6SLionel Sambuc    __tuple_impl&
4754684ddb6SLionel Sambuc    operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
4764684ddb6SLionel Sambuc    {
4774684ddb6SLionel Sambuc        __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
4784684ddb6SLionel Sambuc        return *this;
4794684ddb6SLionel Sambuc    }
4804684ddb6SLionel Sambuc
4814684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
4824684ddb6SLionel Sambuc    __tuple_impl&
4834684ddb6SLionel Sambuc    operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
4844684ddb6SLionel Sambuc    {
4854684ddb6SLionel Sambuc        __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
4864684ddb6SLionel Sambuc        return *this;
4874684ddb6SLionel Sambuc    }
4884684ddb6SLionel Sambuc
4894684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
4904684ddb6SLionel Sambuc    void swap(__tuple_impl& __t)
4914684ddb6SLionel Sambuc        _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
4924684ddb6SLionel Sambuc    {
4934684ddb6SLionel Sambuc        __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
4944684ddb6SLionel Sambuc    }
4954684ddb6SLionel Sambuc};
4964684ddb6SLionel Sambuc
4974684ddb6SLionel Sambuctemplate <class ..._Tp>
4984684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY tuple
4994684ddb6SLionel Sambuc{
5004684ddb6SLionel Sambuc    typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
5014684ddb6SLionel Sambuc
5024684ddb6SLionel Sambuc    base base_;
5034684ddb6SLionel Sambuc
5044684ddb6SLionel Sambuc    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
5054684ddb6SLionel Sambuc        typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
5064684ddb6SLionel Sambuc    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
5074684ddb6SLionel Sambuc        const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
5084684ddb6SLionel Sambuc    template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
5094684ddb6SLionel Sambuc        typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
5104684ddb6SLionel Sambucpublic:
5114684ddb6SLionel Sambuc
512*0a6a1f1dSLionel Sambuc    template <bool _Dummy = true, class = typename enable_if<
513*0a6a1f1dSLionel Sambuc        __all<__dependent_type<is_default_constructible<_Tp>, _Dummy>::value...>::value
514*0a6a1f1dSLionel Sambuc    >::type>
5154684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
5164684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR tuple()
5174684ddb6SLionel Sambuc        _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
5184684ddb6SLionel Sambuc
5194684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
5204684ddb6SLionel Sambuc    explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
5214684ddb6SLionel Sambuc        : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
5224684ddb6SLionel Sambuc                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
5234684ddb6SLionel Sambuc                typename __make_tuple_indices<0>::type(),
5244684ddb6SLionel Sambuc                typename __make_tuple_types<tuple, 0>::type(),
5254684ddb6SLionel Sambuc                __t...
5264684ddb6SLionel Sambuc               ) {}
5274684ddb6SLionel Sambuc
5284684ddb6SLionel Sambuc    template <class _Alloc>
5294684ddb6SLionel Sambuc      _LIBCPP_INLINE_VISIBILITY
5304684ddb6SLionel Sambuc      tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
5314684ddb6SLionel Sambuc        : base_(allocator_arg_t(), __a,
5324684ddb6SLionel Sambuc                typename __make_tuple_indices<sizeof...(_Tp)>::type(),
5334684ddb6SLionel Sambuc                typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
5344684ddb6SLionel Sambuc                typename __make_tuple_indices<0>::type(),
5354684ddb6SLionel Sambuc                typename __make_tuple_types<tuple, 0>::type(),
5364684ddb6SLionel Sambuc                __t...
5374684ddb6SLionel Sambuc               ) {}
5384684ddb6SLionel Sambuc
5394684ddb6SLionel Sambuc    template <class ..._Up,
5404684ddb6SLionel Sambuc              typename enable_if
5414684ddb6SLionel Sambuc                      <
5424684ddb6SLionel Sambuc                         sizeof...(_Up) <= sizeof...(_Tp) &&
5434684ddb6SLionel Sambuc                         __tuple_convertible
5444684ddb6SLionel Sambuc                         <
5454684ddb6SLionel Sambuc                            tuple<_Up...>,
5464684ddb6SLionel Sambuc                            typename __make_tuple_types<tuple,
5474684ddb6SLionel Sambuc                                     sizeof...(_Up) < sizeof...(_Tp) ?
5484684ddb6SLionel Sambuc                                        sizeof...(_Up) :
5494684ddb6SLionel Sambuc                                        sizeof...(_Tp)>::type
550*0a6a1f1dSLionel Sambuc                         >::value &&
551*0a6a1f1dSLionel Sambuc                         __all_default_constructible<
552*0a6a1f1dSLionel Sambuc                            typename __make_tuple_types<tuple, sizeof...(_Tp),
553*0a6a1f1dSLionel Sambuc                                sizeof...(_Up) < sizeof...(_Tp) ?
554*0a6a1f1dSLionel Sambuc                                    sizeof...(_Up) :
555*0a6a1f1dSLionel Sambuc                                    sizeof...(_Tp)>::type
5564684ddb6SLionel Sambuc                         >::value,
5574684ddb6SLionel Sambuc                         bool
5584684ddb6SLionel Sambuc                      >::type = false
5594684ddb6SLionel Sambuc             >
5604684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
5614684ddb6SLionel Sambuc        tuple(_Up&&... __u)
5624684ddb6SLionel Sambuc            _NOEXCEPT_((
563*0a6a1f1dSLionel Sambuc                is_nothrow_constructible<base,
5644684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Up)>::type,
5654684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
5664684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
5674684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
5684684ddb6SLionel Sambuc                    _Up...
5694684ddb6SLionel Sambuc                >::value
5704684ddb6SLionel Sambuc            ))
5714684ddb6SLionel Sambuc            : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
5724684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
5734684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
5744684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
5754684ddb6SLionel Sambuc                    _VSTD::forward<_Up>(__u)...) {}
5764684ddb6SLionel Sambuc
5774684ddb6SLionel Sambuc    template <class ..._Up,
5784684ddb6SLionel Sambuc              typename enable_if
5794684ddb6SLionel Sambuc                      <
5804684ddb6SLionel Sambuc                         sizeof...(_Up) <= sizeof...(_Tp) &&
5814684ddb6SLionel Sambuc                         __tuple_constructible
5824684ddb6SLionel Sambuc                         <
5834684ddb6SLionel Sambuc                            tuple<_Up...>,
5844684ddb6SLionel Sambuc                            typename __make_tuple_types<tuple,
5854684ddb6SLionel Sambuc                                     sizeof...(_Up) < sizeof...(_Tp) ?
5864684ddb6SLionel Sambuc                                        sizeof...(_Up) :
5874684ddb6SLionel Sambuc                                        sizeof...(_Tp)>::type
5884684ddb6SLionel Sambuc                         >::value &&
5894684ddb6SLionel Sambuc                         !__tuple_convertible
5904684ddb6SLionel Sambuc                         <
5914684ddb6SLionel Sambuc                            tuple<_Up...>,
5924684ddb6SLionel Sambuc                            typename __make_tuple_types<tuple,
5934684ddb6SLionel Sambuc                                     sizeof...(_Up) < sizeof...(_Tp) ?
5944684ddb6SLionel Sambuc                                        sizeof...(_Up) :
5954684ddb6SLionel Sambuc                                        sizeof...(_Tp)>::type
596*0a6a1f1dSLionel Sambuc                         >::value &&
597*0a6a1f1dSLionel Sambuc                         __all_default_constructible<
598*0a6a1f1dSLionel Sambuc                            typename __make_tuple_types<tuple, sizeof...(_Tp),
599*0a6a1f1dSLionel Sambuc                                sizeof...(_Up) < sizeof...(_Tp) ?
600*0a6a1f1dSLionel Sambuc                                    sizeof...(_Up) :
601*0a6a1f1dSLionel Sambuc                                    sizeof...(_Tp)>::type
6024684ddb6SLionel Sambuc                         >::value,
6034684ddb6SLionel Sambuc                         bool
6044684ddb6SLionel Sambuc                      >::type =false
6054684ddb6SLionel Sambuc             >
6064684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
6074684ddb6SLionel Sambuc        explicit
6084684ddb6SLionel Sambuc        tuple(_Up&&... __u)
6094684ddb6SLionel Sambuc            _NOEXCEPT_((
610*0a6a1f1dSLionel Sambuc                is_nothrow_constructible<base,
6114684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Up)>::type,
6124684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
6134684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
6144684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
6154684ddb6SLionel Sambuc                    _Up...
6164684ddb6SLionel Sambuc                >::value
6174684ddb6SLionel Sambuc            ))
6184684ddb6SLionel Sambuc            : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
6194684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
6204684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
6214684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
6224684ddb6SLionel Sambuc                    _VSTD::forward<_Up>(__u)...) {}
6234684ddb6SLionel Sambuc
6244684ddb6SLionel Sambuc    template <class _Alloc, class ..._Up,
6254684ddb6SLionel Sambuc              class = typename enable_if
6264684ddb6SLionel Sambuc                      <
6274684ddb6SLionel Sambuc                         sizeof...(_Up) <= sizeof...(_Tp) &&
6284684ddb6SLionel Sambuc                         __tuple_convertible
6294684ddb6SLionel Sambuc                         <
6304684ddb6SLionel Sambuc                            tuple<_Up...>,
6314684ddb6SLionel Sambuc                            typename __make_tuple_types<tuple,
6324684ddb6SLionel Sambuc                                     sizeof...(_Up) < sizeof...(_Tp) ?
6334684ddb6SLionel Sambuc                                        sizeof...(_Up) :
6344684ddb6SLionel Sambuc                                        sizeof...(_Tp)>::type
635*0a6a1f1dSLionel Sambuc                         >::value &&
636*0a6a1f1dSLionel Sambuc                         __all_default_constructible<
637*0a6a1f1dSLionel Sambuc                            typename __make_tuple_types<tuple, sizeof...(_Tp),
638*0a6a1f1dSLionel Sambuc                                sizeof...(_Up) < sizeof...(_Tp) ?
639*0a6a1f1dSLionel Sambuc                                    sizeof...(_Up) :
640*0a6a1f1dSLionel Sambuc                                    sizeof...(_Tp)>::type
6414684ddb6SLionel Sambuc                         >::value
6424684ddb6SLionel Sambuc                      >::type
6434684ddb6SLionel Sambuc             >
6444684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
6454684ddb6SLionel Sambuc        tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
6464684ddb6SLionel Sambuc            : base_(allocator_arg_t(), __a,
6474684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Up)>::type(),
6484684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
6494684ddb6SLionel Sambuc                    typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
6504684ddb6SLionel Sambuc                    typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
6514684ddb6SLionel Sambuc                    _VSTD::forward<_Up>(__u)...) {}
6524684ddb6SLionel Sambuc
6534684ddb6SLionel Sambuc    template <class _Tuple,
6544684ddb6SLionel Sambuc              typename enable_if
6554684ddb6SLionel Sambuc                      <
6564684ddb6SLionel Sambuc                         __tuple_convertible<_Tuple, tuple>::value,
6574684ddb6SLionel Sambuc                         bool
6584684ddb6SLionel Sambuc                      >::type = false
6594684ddb6SLionel Sambuc             >
6604684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
6614684ddb6SLionel Sambuc        tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
6624684ddb6SLionel Sambuc            : base_(_VSTD::forward<_Tuple>(__t)) {}
6634684ddb6SLionel Sambuc
6644684ddb6SLionel Sambuc    template <class _Tuple,
6654684ddb6SLionel Sambuc              typename enable_if
6664684ddb6SLionel Sambuc                      <
6674684ddb6SLionel Sambuc                         __tuple_constructible<_Tuple, tuple>::value &&
6684684ddb6SLionel Sambuc                         !__tuple_convertible<_Tuple, tuple>::value,
6694684ddb6SLionel Sambuc                         bool
6704684ddb6SLionel Sambuc                      >::type = false
6714684ddb6SLionel Sambuc             >
6724684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
6734684ddb6SLionel Sambuc        explicit
6744684ddb6SLionel Sambuc        tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
6754684ddb6SLionel Sambuc            : base_(_VSTD::forward<_Tuple>(__t)) {}
6764684ddb6SLionel Sambuc
6774684ddb6SLionel Sambuc    template <class _Alloc, class _Tuple,
6784684ddb6SLionel Sambuc              class = typename enable_if
6794684ddb6SLionel Sambuc                      <
6804684ddb6SLionel Sambuc                         __tuple_convertible<_Tuple, tuple>::value
6814684ddb6SLionel Sambuc                      >::type
6824684ddb6SLionel Sambuc             >
6834684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
6844684ddb6SLionel Sambuc        tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
6854684ddb6SLionel Sambuc            : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
6864684ddb6SLionel Sambuc
6874684ddb6SLionel Sambuc    template <class _Tuple,
6884684ddb6SLionel Sambuc              class = typename enable_if
6894684ddb6SLionel Sambuc                      <
6904684ddb6SLionel Sambuc                         __tuple_assignable<_Tuple, tuple>::value
6914684ddb6SLionel Sambuc                      >::type
6924684ddb6SLionel Sambuc             >
6934684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
6944684ddb6SLionel Sambuc        tuple&
6954684ddb6SLionel Sambuc        operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value))
6964684ddb6SLionel Sambuc        {
6974684ddb6SLionel Sambuc            base_.operator=(_VSTD::forward<_Tuple>(__t));
6984684ddb6SLionel Sambuc            return *this;
6994684ddb6SLionel Sambuc        }
7004684ddb6SLionel Sambuc
7014684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
7024684ddb6SLionel Sambuc    void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
7034684ddb6SLionel Sambuc        {base_.swap(__t.base_);}
7044684ddb6SLionel Sambuc};
7054684ddb6SLionel Sambuc
7064684ddb6SLionel Sambuctemplate <>
7074684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY tuple<>
7084684ddb6SLionel Sambuc{
7094684ddb6SLionel Sambucpublic:
7104684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
7114684ddb6SLionel Sambuc    _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
7124684ddb6SLionel Sambuc    template <class _Alloc>
7134684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
7144684ddb6SLionel Sambuc        tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
7154684ddb6SLionel Sambuc    template <class _Alloc>
7164684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
7174684ddb6SLionel Sambuc        tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
7184684ddb6SLionel Sambuc    template <class _Up>
7194684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
7204684ddb6SLionel Sambuc        tuple(array<_Up, 0>) _NOEXCEPT {}
7214684ddb6SLionel Sambuc    template <class _Alloc, class _Up>
7224684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
7234684ddb6SLionel Sambuc        tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
7244684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
7254684ddb6SLionel Sambuc    void swap(tuple&) _NOEXCEPT {}
7264684ddb6SLionel Sambuc};
7274684ddb6SLionel Sambuc
7284684ddb6SLionel Sambuctemplate <class ..._Tp>
7294684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
7304684ddb6SLionel Sambuctypename enable_if
7314684ddb6SLionel Sambuc<
7324684ddb6SLionel Sambuc    __all<__is_swappable<_Tp>::value...>::value,
7334684ddb6SLionel Sambuc    void
7344684ddb6SLionel Sambuc>::type
7354684ddb6SLionel Sambucswap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
7364684ddb6SLionel Sambuc                 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
7374684ddb6SLionel Sambuc    {__t.swap(__u);}
7384684ddb6SLionel Sambuc
7394684ddb6SLionel Sambuc// get
7404684ddb6SLionel Sambuc
7414684ddb6SLionel Sambuctemplate <size_t _Ip, class ..._Tp>
7424684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
7434684ddb6SLionel Sambuctypename tuple_element<_Ip, tuple<_Tp...> >::type&
7444684ddb6SLionel Sambucget(tuple<_Tp...>& __t) _NOEXCEPT
7454684ddb6SLionel Sambuc{
7464684ddb6SLionel Sambuc    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
7474684ddb6SLionel Sambuc    return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get();
7484684ddb6SLionel Sambuc}
7494684ddb6SLionel Sambuc
7504684ddb6SLionel Sambuctemplate <size_t _Ip, class ..._Tp>
7514684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
7524684ddb6SLionel Sambucconst typename tuple_element<_Ip, tuple<_Tp...> >::type&
7534684ddb6SLionel Sambucget(const tuple<_Tp...>& __t) _NOEXCEPT
7544684ddb6SLionel Sambuc{
7554684ddb6SLionel Sambuc    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
7564684ddb6SLionel Sambuc    return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
7574684ddb6SLionel Sambuc}
7584684ddb6SLionel Sambuc
7594684ddb6SLionel Sambuctemplate <size_t _Ip, class ..._Tp>
7604684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
7614684ddb6SLionel Sambuctypename tuple_element<_Ip, tuple<_Tp...> >::type&&
7624684ddb6SLionel Sambucget(tuple<_Tp...>&& __t) _NOEXCEPT
7634684ddb6SLionel Sambuc{
7644684ddb6SLionel Sambuc    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
7654684ddb6SLionel Sambuc    return static_cast<type&&>(
7664684ddb6SLionel Sambuc             static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
7674684ddb6SLionel Sambuc}
7684684ddb6SLionel Sambuc
7694684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11
7704684ddb6SLionel Sambuc// get by type
7714684ddb6SLionel Sambuctemplate <typename _T1, size_t _Idx, typename... _Args>
7724684ddb6SLionel Sambucstruct __find_exactly_one_t_helper;
7734684ddb6SLionel Sambuc
7744684ddb6SLionel Sambuc// -- find exactly one
7754684ddb6SLionel Sambuctemplate <typename _T1, size_t _Idx, typename... _Args>
7764684ddb6SLionel Sambucstruct __find_exactly_one_t_checker {
7774684ddb6SLionel Sambuc    static constexpr size_t value = _Idx;
7784684ddb6SLionel Sambuc//  Check the rest of the list to make sure there's only one
7794684ddb6SLionel Sambuc    static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" );
7804684ddb6SLionel Sambuc    };
7814684ddb6SLionel Sambuc
7824684ddb6SLionel Sambuc
7834684ddb6SLionel Sambuctemplate <typename _T1, size_t _Idx>
7844684ddb6SLionel Sambucstruct __find_exactly_one_t_helper <_T1, _Idx> {
7854684ddb6SLionel Sambuc    static constexpr size_t value = -1;
7864684ddb6SLionel Sambuc    };
7874684ddb6SLionel Sambuc
7884684ddb6SLionel Sambuctemplate <typename _T1, size_t _Idx, typename _Head, typename... _Args>
7894684ddb6SLionel Sambucstruct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> {
7904684ddb6SLionel Sambuc    static constexpr size_t value =
7914684ddb6SLionel Sambuc        std::conditional<
7924684ddb6SLionel Sambuc            std::is_same<_T1, _Head>::value,
7934684ddb6SLionel Sambuc            __find_exactly_one_t_checker<_T1, _Idx,   _Args...>,
7944684ddb6SLionel Sambuc            __find_exactly_one_t_helper <_T1, _Idx+1, _Args...>
7954684ddb6SLionel Sambuc        >::type::value;
7964684ddb6SLionel Sambuc    };
7974684ddb6SLionel Sambuc
7984684ddb6SLionel Sambuctemplate <typename _T1, typename... _Args>
7994684ddb6SLionel Sambucstruct __find_exactly_one_t {
8004684ddb6SLionel Sambuc    static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value;
8014684ddb6SLionel Sambuc    static_assert ( value != -1, "type not found in type list" );
8024684ddb6SLionel Sambuc    };
8034684ddb6SLionel Sambuc
8044684ddb6SLionel Sambuctemplate <class _T1, class... _Args>
8054684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
8064684ddb6SLionel Sambucconstexpr _T1& get(tuple<_Args...>& __tup) noexcept
8074684ddb6SLionel Sambuc{
8084684ddb6SLionel Sambuc    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
8094684ddb6SLionel Sambuc}
8104684ddb6SLionel Sambuc
8114684ddb6SLionel Sambuctemplate <class _T1, class... _Args>
8124684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
8134684ddb6SLionel Sambucconstexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
8144684ddb6SLionel Sambuc{
8154684ddb6SLionel Sambuc    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
8164684ddb6SLionel Sambuc}
8174684ddb6SLionel Sambuc
8184684ddb6SLionel Sambuctemplate <class _T1, class... _Args>
8194684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
8204684ddb6SLionel Sambucconstexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
8214684ddb6SLionel Sambuc{
8224684ddb6SLionel Sambuc    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
8234684ddb6SLionel Sambuc}
8244684ddb6SLionel Sambuc
8254684ddb6SLionel Sambuc#endif
8264684ddb6SLionel Sambuc
8274684ddb6SLionel Sambuc// tie
8284684ddb6SLionel Sambuc
8294684ddb6SLionel Sambuctemplate <class ..._Tp>
830*0a6a1f1dSLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8314684ddb6SLionel Sambuctuple<_Tp&...>
8324684ddb6SLionel Sambuctie(_Tp&... __t) _NOEXCEPT
8334684ddb6SLionel Sambuc{
8344684ddb6SLionel Sambuc    return tuple<_Tp&...>(__t...);
8354684ddb6SLionel Sambuc}
8364684ddb6SLionel Sambuc
8374684ddb6SLionel Sambuctemplate <class _Up>
8384684ddb6SLionel Sambucstruct __ignore_t
8394684ddb6SLionel Sambuc{
8404684ddb6SLionel Sambuc    template <class _Tp>
8414684ddb6SLionel Sambuc        _LIBCPP_INLINE_VISIBILITY
8424684ddb6SLionel Sambuc        const __ignore_t& operator=(_Tp&&) const {return *this;}
8434684ddb6SLionel Sambuc};
8444684ddb6SLionel Sambuc
8454684ddb6SLionel Sambucnamespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
8464684ddb6SLionel Sambuc
8474684ddb6SLionel Sambuctemplate <class _Tp>
848*0a6a1f1dSLionel Sambucstruct __make_tuple_return_impl
8494684ddb6SLionel Sambuc{
8504684ddb6SLionel Sambuc    typedef _Tp type;
8514684ddb6SLionel Sambuc};
8524684ddb6SLionel Sambuc
8534684ddb6SLionel Sambuctemplate <class _Tp>
854*0a6a1f1dSLionel Sambucstruct __make_tuple_return_impl<reference_wrapper<_Tp> >
8554684ddb6SLionel Sambuc{
8564684ddb6SLionel Sambuc    typedef _Tp& type;
8574684ddb6SLionel Sambuc};
8584684ddb6SLionel Sambuc
8594684ddb6SLionel Sambuctemplate <class _Tp>
8604684ddb6SLionel Sambucstruct __make_tuple_return
8614684ddb6SLionel Sambuc{
862*0a6a1f1dSLionel Sambuc    typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
8634684ddb6SLionel Sambuc};
8644684ddb6SLionel Sambuc
8654684ddb6SLionel Sambuctemplate <class... _Tp>
8664684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8674684ddb6SLionel Sambuctuple<typename __make_tuple_return<_Tp>::type...>
8684684ddb6SLionel Sambucmake_tuple(_Tp&&... __t)
8694684ddb6SLionel Sambuc{
8704684ddb6SLionel Sambuc    return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
8714684ddb6SLionel Sambuc}
8724684ddb6SLionel Sambuc
8734684ddb6SLionel Sambuctemplate <class... _Tp>
8744684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8754684ddb6SLionel Sambuctuple<_Tp&&...>
8764684ddb6SLionel Sambucforward_as_tuple(_Tp&&... __t) _NOEXCEPT
8774684ddb6SLionel Sambuc{
8784684ddb6SLionel Sambuc    return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
8794684ddb6SLionel Sambuc}
8804684ddb6SLionel Sambuc
8814684ddb6SLionel Sambuctemplate <size_t _Ip>
8824684ddb6SLionel Sambucstruct __tuple_equal
8834684ddb6SLionel Sambuc{
8844684ddb6SLionel Sambuc    template <class _Tp, class _Up>
8854684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8864684ddb6SLionel Sambuc    bool operator()(const _Tp& __x, const _Up& __y)
8874684ddb6SLionel Sambuc    {
888*0a6a1f1dSLionel Sambuc        return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
8894684ddb6SLionel Sambuc    }
8904684ddb6SLionel Sambuc};
8914684ddb6SLionel Sambuc
8924684ddb6SLionel Sambuctemplate <>
8934684ddb6SLionel Sambucstruct __tuple_equal<0>
8944684ddb6SLionel Sambuc{
8954684ddb6SLionel Sambuc    template <class _Tp, class _Up>
8964684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
8974684ddb6SLionel Sambuc    bool operator()(const _Tp&, const _Up&)
8984684ddb6SLionel Sambuc    {
8994684ddb6SLionel Sambuc        return true;
9004684ddb6SLionel Sambuc    }
9014684ddb6SLionel Sambuc};
9024684ddb6SLionel Sambuc
9034684ddb6SLionel Sambuctemplate <class ..._Tp, class ..._Up>
9044684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
9054684ddb6SLionel Sambucbool
9064684ddb6SLionel Sambucoperator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
9074684ddb6SLionel Sambuc{
9084684ddb6SLionel Sambuc    return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
9094684ddb6SLionel Sambuc}
9104684ddb6SLionel Sambuc
9114684ddb6SLionel Sambuctemplate <class ..._Tp, class ..._Up>
9124684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
9134684ddb6SLionel Sambucbool
9144684ddb6SLionel Sambucoperator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
9154684ddb6SLionel Sambuc{
9164684ddb6SLionel Sambuc    return !(__x == __y);
9174684ddb6SLionel Sambuc}
9184684ddb6SLionel Sambuc
9194684ddb6SLionel Sambuctemplate <size_t _Ip>
9204684ddb6SLionel Sambucstruct __tuple_less
9214684ddb6SLionel Sambuc{
9224684ddb6SLionel Sambuc    template <class _Tp, class _Up>
9234684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
9244684ddb6SLionel Sambuc    bool operator()(const _Tp& __x, const _Up& __y)
9254684ddb6SLionel Sambuc    {
926*0a6a1f1dSLionel Sambuc        const size_t __idx = tuple_size<_Tp>::value - _Ip;
927*0a6a1f1dSLionel Sambuc        if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
928*0a6a1f1dSLionel Sambuc            return true;
929*0a6a1f1dSLionel Sambuc        if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
930*0a6a1f1dSLionel Sambuc            return false;
931*0a6a1f1dSLionel Sambuc        return __tuple_less<_Ip-1>()(__x, __y);
9324684ddb6SLionel Sambuc    }
9334684ddb6SLionel Sambuc};
9344684ddb6SLionel Sambuc
9354684ddb6SLionel Sambuctemplate <>
9364684ddb6SLionel Sambucstruct __tuple_less<0>
9374684ddb6SLionel Sambuc{
9384684ddb6SLionel Sambuc    template <class _Tp, class _Up>
9394684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
9404684ddb6SLionel Sambuc    bool operator()(const _Tp&, const _Up&)
9414684ddb6SLionel Sambuc    {
9424684ddb6SLionel Sambuc        return false;
9434684ddb6SLionel Sambuc    }
9444684ddb6SLionel Sambuc};
9454684ddb6SLionel Sambuc
9464684ddb6SLionel Sambuctemplate <class ..._Tp, class ..._Up>
9474684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
9484684ddb6SLionel Sambucbool
9494684ddb6SLionel Sambucoperator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
9504684ddb6SLionel Sambuc{
9514684ddb6SLionel Sambuc    return __tuple_less<sizeof...(_Tp)>()(__x, __y);
9524684ddb6SLionel Sambuc}
9534684ddb6SLionel Sambuc
9544684ddb6SLionel Sambuctemplate <class ..._Tp, class ..._Up>
9554684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
9564684ddb6SLionel Sambucbool
9574684ddb6SLionel Sambucoperator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
9584684ddb6SLionel Sambuc{
9594684ddb6SLionel Sambuc    return __y < __x;
9604684ddb6SLionel Sambuc}
9614684ddb6SLionel Sambuc
9624684ddb6SLionel Sambuctemplate <class ..._Tp, class ..._Up>
9634684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
9644684ddb6SLionel Sambucbool
9654684ddb6SLionel Sambucoperator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
9664684ddb6SLionel Sambuc{
9674684ddb6SLionel Sambuc    return !(__x < __y);
9684684ddb6SLionel Sambuc}
9694684ddb6SLionel Sambuc
9704684ddb6SLionel Sambuctemplate <class ..._Tp, class ..._Up>
9714684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
9724684ddb6SLionel Sambucbool
9734684ddb6SLionel Sambucoperator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
9744684ddb6SLionel Sambuc{
9754684ddb6SLionel Sambuc    return !(__y < __x);
9764684ddb6SLionel Sambuc}
9774684ddb6SLionel Sambuc
9784684ddb6SLionel Sambuc// tuple_cat
9794684ddb6SLionel Sambuc
9804684ddb6SLionel Sambuctemplate <class _Tp, class _Up> struct __tuple_cat_type;
9814684ddb6SLionel Sambuc
9824684ddb6SLionel Sambuctemplate <class ..._Ttypes, class ..._Utypes>
9834684ddb6SLionel Sambucstruct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
9844684ddb6SLionel Sambuc{
9854684ddb6SLionel Sambuc    typedef tuple<_Ttypes..., _Utypes...> type;
9864684ddb6SLionel Sambuc};
9874684ddb6SLionel Sambuc
9884684ddb6SLionel Sambuctemplate <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
9894684ddb6SLionel Sambucstruct __tuple_cat_return_1
9904684ddb6SLionel Sambuc{
9914684ddb6SLionel Sambuc};
9924684ddb6SLionel Sambuc
9934684ddb6SLionel Sambuctemplate <class ..._Types, class _Tuple0>
9944684ddb6SLionel Sambucstruct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
9954684ddb6SLionel Sambuc{
9964684ddb6SLionel Sambuc    typedef typename __tuple_cat_type<tuple<_Types...>,
9974684ddb6SLionel Sambuc            typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
9984684ddb6SLionel Sambuc                                                                           type;
9994684ddb6SLionel Sambuc};
10004684ddb6SLionel Sambuc
10014684ddb6SLionel Sambuctemplate <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
10024684ddb6SLionel Sambucstruct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
10034684ddb6SLionel Sambuc    : public __tuple_cat_return_1<
10044684ddb6SLionel Sambuc                 typename __tuple_cat_type<
10054684ddb6SLionel Sambuc                     tuple<_Types...>,
10064684ddb6SLionel Sambuc                     typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
10074684ddb6SLionel Sambuc                 >::type,
10084684ddb6SLionel Sambuc                 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
10094684ddb6SLionel Sambuc                 _Tuple1, _Tuples...>
10104684ddb6SLionel Sambuc{
10114684ddb6SLionel Sambuc};
10124684ddb6SLionel Sambuc
10134684ddb6SLionel Sambuctemplate <class ..._Tuples> struct __tuple_cat_return;
10144684ddb6SLionel Sambuc
10154684ddb6SLionel Sambuctemplate <class _Tuple0, class ..._Tuples>
10164684ddb6SLionel Sambucstruct __tuple_cat_return<_Tuple0, _Tuples...>
10174684ddb6SLionel Sambuc    : public __tuple_cat_return_1<tuple<>,
10184684ddb6SLionel Sambuc         __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
10194684ddb6SLionel Sambuc                                                                     _Tuples...>
10204684ddb6SLionel Sambuc{
10214684ddb6SLionel Sambuc};
10224684ddb6SLionel Sambuc
10234684ddb6SLionel Sambuctemplate <>
10244684ddb6SLionel Sambucstruct __tuple_cat_return<>
10254684ddb6SLionel Sambuc{
10264684ddb6SLionel Sambuc    typedef tuple<> type;
10274684ddb6SLionel Sambuc};
10284684ddb6SLionel Sambuc
10294684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
10304684ddb6SLionel Sambuctuple<>
10314684ddb6SLionel Sambuctuple_cat()
10324684ddb6SLionel Sambuc{
10334684ddb6SLionel Sambuc    return tuple<>();
10344684ddb6SLionel Sambuc}
10354684ddb6SLionel Sambuc
10364684ddb6SLionel Sambuctemplate <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
10374684ddb6SLionel Sambucstruct __tuple_cat_return_ref_imp;
10384684ddb6SLionel Sambuc
10394684ddb6SLionel Sambuctemplate <class ..._Types, size_t ..._I0, class _Tuple0>
10404684ddb6SLionel Sambucstruct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
10414684ddb6SLionel Sambuc{
10424684ddb6SLionel Sambuc    typedef typename remove_reference<_Tuple0>::type _T0;
10434684ddb6SLionel Sambuc    typedef tuple<_Types..., typename __apply_cv<_Tuple0,
10444684ddb6SLionel Sambuc                          typename tuple_element<_I0, _T0>::type>::type&&...> type;
10454684ddb6SLionel Sambuc};
10464684ddb6SLionel Sambuc
10474684ddb6SLionel Sambuctemplate <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
10484684ddb6SLionel Sambucstruct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
10494684ddb6SLionel Sambuc                                  _Tuple0, _Tuple1, _Tuples...>
10504684ddb6SLionel Sambuc    : public __tuple_cat_return_ref_imp<
10514684ddb6SLionel Sambuc         tuple<_Types..., typename __apply_cv<_Tuple0,
10524684ddb6SLionel Sambuc               typename tuple_element<_I0,
10534684ddb6SLionel Sambuc                  typename remove_reference<_Tuple0>::type>::type>::type&&...>,
10544684ddb6SLionel Sambuc         typename __make_tuple_indices<tuple_size<typename
10554684ddb6SLionel Sambuc                                 remove_reference<_Tuple1>::type>::value>::type,
10564684ddb6SLionel Sambuc         _Tuple1, _Tuples...>
10574684ddb6SLionel Sambuc{
10584684ddb6SLionel Sambuc};
10594684ddb6SLionel Sambuc
10604684ddb6SLionel Sambuctemplate <class _Tuple0, class ..._Tuples>
10614684ddb6SLionel Sambucstruct __tuple_cat_return_ref
10624684ddb6SLionel Sambuc    : public __tuple_cat_return_ref_imp<tuple<>,
10634684ddb6SLionel Sambuc               typename __make_tuple_indices<
10644684ddb6SLionel Sambuc                        tuple_size<typename remove_reference<_Tuple0>::type>::value
10654684ddb6SLionel Sambuc               >::type, _Tuple0, _Tuples...>
10664684ddb6SLionel Sambuc{
10674684ddb6SLionel Sambuc};
10684684ddb6SLionel Sambuc
10694684ddb6SLionel Sambuctemplate <class _Types, class _I0, class _J0>
10704684ddb6SLionel Sambucstruct __tuple_cat;
10714684ddb6SLionel Sambuc
10724684ddb6SLionel Sambuctemplate <class ..._Types, size_t ..._I0, size_t ..._J0>
10734684ddb6SLionel Sambucstruct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
10744684ddb6SLionel Sambuc{
10754684ddb6SLionel Sambuc    template <class _Tuple0>
10764684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
10774684ddb6SLionel Sambuc    typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
10784684ddb6SLionel Sambuc    operator()(tuple<_Types...> __t, _Tuple0&& __t0)
10794684ddb6SLionel Sambuc    {
1080*0a6a1f1dSLionel Sambuc        return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1081*0a6a1f1dSLionel Sambuc                                      _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
10824684ddb6SLionel Sambuc    }
10834684ddb6SLionel Sambuc
10844684ddb6SLionel Sambuc    template <class _Tuple0, class _Tuple1, class ..._Tuples>
10854684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
10864684ddb6SLionel Sambuc    typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
10874684ddb6SLionel Sambuc    operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
10884684ddb6SLionel Sambuc    {
10894684ddb6SLionel Sambuc        typedef typename remove_reference<_Tuple0>::type _T0;
10904684ddb6SLionel Sambuc        typedef typename remove_reference<_Tuple1>::type _T1;
10914684ddb6SLionel Sambuc        return __tuple_cat<
10924684ddb6SLionel Sambuc           tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
10934684ddb6SLionel Sambuc           typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
10944684ddb6SLionel Sambuc           typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
10954684ddb6SLionel Sambuc                           (forward_as_tuple(
1096*0a6a1f1dSLionel Sambuc                              _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
1097*0a6a1f1dSLionel Sambuc                              _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
10984684ddb6SLionel Sambuc                            ),
10994684ddb6SLionel Sambuc                            _VSTD::forward<_Tuple1>(__t1),
11004684ddb6SLionel Sambuc                            _VSTD::forward<_Tuples>(__tpls)...);
11014684ddb6SLionel Sambuc    }
11024684ddb6SLionel Sambuc};
11034684ddb6SLionel Sambuc
11044684ddb6SLionel Sambuctemplate <class _Tuple0, class... _Tuples>
11054684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
11064684ddb6SLionel Sambuctypename __tuple_cat_return<_Tuple0, _Tuples...>::type
11074684ddb6SLionel Sambuctuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
11084684ddb6SLionel Sambuc{
11094684ddb6SLionel Sambuc    typedef typename remove_reference<_Tuple0>::type _T0;
11104684ddb6SLionel Sambuc    return __tuple_cat<tuple<>, __tuple_indices<>,
11114684ddb6SLionel Sambuc                  typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
11124684ddb6SLionel Sambuc                  (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
11134684ddb6SLionel Sambuc                                            _VSTD::forward<_Tuples>(__tpls)...);
11144684ddb6SLionel Sambuc}
11154684ddb6SLionel Sambuc
11164684ddb6SLionel Sambuctemplate <class ..._Tp, class _Alloc>
11174684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc>
11184684ddb6SLionel Sambuc    : true_type {};
11194684ddb6SLionel Sambuc
11204684ddb6SLionel Sambuctemplate <class _T1, class _T2>
11214684ddb6SLionel Sambuctemplate <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
11224684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
11234684ddb6SLionel Sambucpair<_T1, _T2>::pair(piecewise_construct_t,
11244684ddb6SLionel Sambuc                     tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
11254684ddb6SLionel Sambuc                     __tuple_indices<_I1...>, __tuple_indices<_I2...>)
1126*0a6a1f1dSLionel Sambuc    :  first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
1127*0a6a1f1dSLionel Sambuc      second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
11284684ddb6SLionel Sambuc{
11294684ddb6SLionel Sambuc}
11304684ddb6SLionel Sambuc
11314684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_VARIADICS
11324684ddb6SLionel Sambuc
11334684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD
11344684ddb6SLionel Sambuc
11354684ddb6SLionel Sambuc#endif  // _LIBCPP_TUPLE
1136