13e519524SHoward Hinnant// -*- C++ -*- 23e519524SHoward Hinnant//===--------------------------- tuple ------------------------------------===// 33e519524SHoward Hinnant// 45b08a8a4SHoward Hinnant// The LLVM Compiler Infrastructure 53e519524SHoward Hinnant// 63e519524SHoward Hinnant// This file is distributed under the University of Illinois Open Source 73e519524SHoward Hinnant// License. See LICENSE.TXT for details. 83e519524SHoward Hinnant// 93e519524SHoward Hinnant//===----------------------------------------------------------------------===// 103e519524SHoward Hinnant 113e519524SHoward Hinnant#ifndef _LIBCPP_TUPLE 123e519524SHoward Hinnant#define _LIBCPP_TUPLE 133e519524SHoward Hinnant 143e519524SHoward Hinnant/* 153e519524SHoward Hinnant tuple synopsis 163e519524SHoward Hinnant 173e519524SHoward Hinnantnamespace std 183e519524SHoward Hinnant{ 193e519524SHoward Hinnant 203e519524SHoward Hinnanttemplate <class... T> 213e519524SHoward Hinnantclass tuple { 223e519524SHoward Hinnantpublic: 233e519524SHoward Hinnant constexpr tuple(); 2475eff748SMarshall Clow explicit tuple(const T&...); // constexpr in C++14 253e519524SHoward Hinnant template <class... U> 2675eff748SMarshall Clow explicit tuple(U&&...); // constexpr in C++14 273e519524SHoward Hinnant tuple(const tuple&) = default; 2827d0a2a7SHoward Hinnant tuple(tuple&&) = default; 293e519524SHoward Hinnant template <class... U> 3075eff748SMarshall Clow tuple(const tuple<U...>&); // constexpr in C++14 313e519524SHoward Hinnant template <class... U> 3275eff748SMarshall Clow tuple(tuple<U...>&&); // constexpr in C++14 333e519524SHoward Hinnant template <class U1, class U2> 3475eff748SMarshall Clow tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14 353e519524SHoward Hinnant template <class U1, class U2> 3675eff748SMarshall Clow tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14 373e519524SHoward Hinnant 383e519524SHoward Hinnant // allocator-extended constructors 393e519524SHoward Hinnant template <class Alloc> 403e519524SHoward Hinnant tuple(allocator_arg_t, const Alloc& a); 413e519524SHoward Hinnant template <class Alloc> 423e519524SHoward Hinnant tuple(allocator_arg_t, const Alloc& a, const T&...); 433e519524SHoward Hinnant template <class Alloc, class... U> 443e519524SHoward Hinnant tuple(allocator_arg_t, const Alloc& a, U&&...); 453e519524SHoward Hinnant template <class Alloc> 463e519524SHoward Hinnant tuple(allocator_arg_t, const Alloc& a, const tuple&); 473e519524SHoward Hinnant template <class Alloc> 483e519524SHoward Hinnant tuple(allocator_arg_t, const Alloc& a, tuple&&); 493e519524SHoward Hinnant template <class Alloc, class... U> 503e519524SHoward Hinnant tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&); 513e519524SHoward Hinnant template <class Alloc, class... U> 523e519524SHoward Hinnant tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&); 533e519524SHoward Hinnant template <class Alloc, class U1, class U2> 543e519524SHoward Hinnant tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&); 553e519524SHoward Hinnant template <class Alloc, class U1, class U2> 563e519524SHoward Hinnant tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&); 573e519524SHoward Hinnant 583e519524SHoward Hinnant tuple& operator=(const tuple&); 5927d0a2a7SHoward Hinnant tuple& 6027d0a2a7SHoward Hinnant operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...)); 613e519524SHoward Hinnant template <class... U> 623e519524SHoward Hinnant tuple& operator=(const tuple<U...>&); 633e519524SHoward Hinnant template <class... U> 643e519524SHoward Hinnant tuple& operator=(tuple<U...>&&); 653e519524SHoward Hinnant template <class U1, class U2> 663e519524SHoward Hinnant tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2 673e519524SHoward Hinnant template <class U1, class U2> 683e519524SHoward Hinnant tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2 693e519524SHoward Hinnant 7027d0a2a7SHoward Hinnant void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); 713e519524SHoward Hinnant}; 723e519524SHoward Hinnant 7340a01d53SMarshall Clowinline constexpr unspecified ignore; 743e519524SHoward Hinnant 7575eff748SMarshall Clowtemplate <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14 76de9320aaSMarshall Clowtemplate <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14 770d1560e1SMarshall Clowtemplate <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14 7875eff748SMarshall Clowtemplate <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14 793e519524SHoward Hinnant 8003e29a29SEric Fiselier// [tuple.apply], calling a function with a tuple of arguments: 8103e29a29SEric Fiseliertemplate <class F, class Tuple> 8203e29a29SEric Fiselier constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17 8303e29a29SEric Fiseliertemplate <class T, class Tuple> 8403e29a29SEric Fiselier constexpr T make_from_tuple(Tuple&& t); // C++17 8503e29a29SEric Fiselier 863e519524SHoward Hinnant// 20.4.1.4, tuple helper classes: 871013fe3cSEric Fiseliertemplate <class T> class tuple_size; // undefined 883e519524SHoward Hinnanttemplate <class... T> class tuple_size<tuple<T...>>; 8903e29a29SEric Fiseliertemplate <class T> 9040a01d53SMarshall Clow inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17 91bfb3f2bfSMarshall Clowtemplate <size_t I, class T> class tuple_element; // undefined 92bfb3f2bfSMarshall Clowtemplate <size_t I, class... T> class tuple_element<I, tuple<T...>>; 93bfb3f2bfSMarshall Clowtemplate <size_t I, class T> 94bfb3f2bfSMarshall Clow using tuple_element_t = typename tuple_element <I, T>::type; // C++14 953e519524SHoward Hinnant 963e519524SHoward Hinnant// 20.4.1.5, element access: 97bfb3f2bfSMarshall Clowtemplate <size_t I, class... T> 9827d0a2a7SHoward Hinnant typename tuple_element<I, tuple<T...>>::type& 998bf1f08aSMarshall Clow get(tuple<T...>&) noexcept; // constexpr in C++14 100bfb3f2bfSMarshall Clowtemplate <size_t I, class... T> 101bfb3f2bfSMarshall Clow const typename tuple_element<I, tuple<T...>>::type& 1028bf1f08aSMarshall Clow get(const tuple<T...>&) noexcept; // constexpr in C++14 103bfb3f2bfSMarshall Clowtemplate <size_t I, class... T> 10427d0a2a7SHoward Hinnant typename tuple_element<I, tuple<T...>>::type&& 1058bf1f08aSMarshall Clow get(tuple<T...>&&) noexcept; // constexpr in C++14 106545b8861SEric Fiseliertemplate <size_t I, class... T> 107545b8861SEric Fiselier const typename tuple_element<I, tuple<T...>>::type&& 108545b8861SEric Fiselier get(const tuple<T...>&&) noexcept; // constexpr in C++14 1093e519524SHoward Hinnant 110e99520c7SMarshall Clowtemplate <class T1, class... T> 111e99520c7SMarshall Clow constexpr T1& get(tuple<T...>&) noexcept; // C++14 112e99520c7SMarshall Clowtemplate <class T1, class... T> 113bfb3f2bfSMarshall Clow constexpr const T1& get(const tuple<T...>&) noexcept; // C++14 114e99520c7SMarshall Clowtemplate <class T1, class... T> 115e99520c7SMarshall Clow constexpr T1&& get(tuple<T...>&&) noexcept; // C++14 116545b8861SEric Fiseliertemplate <class T1, class... T> 117545b8861SEric Fiselier constexpr const T1&& get(const tuple<T...>&&) noexcept; // C++14 118e99520c7SMarshall Clow 1193e519524SHoward Hinnant// 20.4.1.6, relational operators: 12075eff748SMarshall Clowtemplate<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 12175eff748SMarshall Clowtemplate<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 12275eff748SMarshall Clowtemplate<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 12375eff748SMarshall Clowtemplate<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 12475eff748SMarshall Clowtemplate<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 12575eff748SMarshall Clowtemplate<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 1263e519524SHoward Hinnant 1273e519524SHoward Hinnanttemplate <class... Types, class Alloc> 1283e519524SHoward Hinnant struct uses_allocator<tuple<Types...>, Alloc>; 1293e519524SHoward Hinnant 1303e519524SHoward Hinnanttemplate <class... Types> 13127d0a2a7SHoward Hinnant void 13227d0a2a7SHoward Hinnant swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y))); 1333e519524SHoward Hinnant 1343e519524SHoward Hinnant} // std 1353e519524SHoward Hinnant 1363e519524SHoward Hinnant*/ 1373e519524SHoward Hinnant 1383e519524SHoward Hinnant#include <__config> 1393e519524SHoward Hinnant#include <__tuple> 1403e519524SHoward Hinnant#include <cstddef> 1413e519524SHoward Hinnant#include <type_traits> 142a87b5e34SHoward Hinnant#include <__functional_base> 143a87b5e34SHoward Hinnant#include <utility> 144f56972e2SMarshall Clow#include <version> 1453e519524SHoward Hinnant 146073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1473e519524SHoward Hinnant#pragma GCC system_header 148073458b1SHoward Hinnant#endif 1493e519524SHoward Hinnant 1503e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD 1513e519524SHoward Hinnant 15229870871SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 1533e519524SHoward Hinnant 15405c8dad2SMarshall Clow 1553e519524SHoward Hinnant// __tuple_leaf 1563e519524SHoward Hinnant 157ee187e24SEric Fiseliertemplate <size_t _Ip, class _Hp, 158ee187e24SEric Fiselier bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value 15942b8bb50SHoward Hinnant > 1603e519524SHoward Hinnantclass __tuple_leaf; 1613e519524SHoward Hinnant 1623e519524SHoward Hinnanttemplate <size_t _Ip, class _Hp, bool _Ep> 163789847ddSHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 1643e519524SHoward Hinnantvoid swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y) 16527d0a2a7SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value) 1663e519524SHoward Hinnant{ 1673e519524SHoward Hinnant swap(__x.get(), __y.get()); 1683e519524SHoward Hinnant} 1693e519524SHoward Hinnant 1703e519524SHoward Hinnanttemplate <size_t _Ip, class _Hp, bool> 1713e519524SHoward Hinnantclass __tuple_leaf 1723e519524SHoward Hinnant{ 173def3c375SEric Fiselier _Hp __value_; 1743e519524SHoward Hinnant 175074f8d77SEric Fiselier template <class _Tp> 176074f8d77SEric Fiselier static constexpr bool __can_bind_reference() { 177292617e7SEric Fiselier#if __has_keyword(__reference_binds_to_temporary) 178292617e7SEric Fiselier return !__reference_binds_to_temporary(_Hp, _Tp); 179b1539e0aSEric Fiselier#else 180b1539e0aSEric Fiselier return true; 181292617e7SEric Fiselier#endif 182074f8d77SEric Fiselier } 183074f8d77SEric Fiselier 1843e519524SHoward Hinnant __tuple_leaf& operator=(const __tuple_leaf&); 1853e519524SHoward Hinnantpublic: 186a0f4c45cSHoward Hinnant _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf() 187def3c375SEric Fiselier _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_() 1883e519524SHoward Hinnant {static_assert(!is_reference<_Hp>::value, 1893e519524SHoward Hinnant "Attempted to default construct a reference element in a tuple");} 1903e519524SHoward Hinnant 1913e519524SHoward Hinnant template <class _Alloc> 1923e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 1933e519524SHoward Hinnant __tuple_leaf(integral_constant<int, 0>, const _Alloc&) 194def3c375SEric Fiselier : __value_() 1953e519524SHoward Hinnant {static_assert(!is_reference<_Hp>::value, 1963e519524SHoward Hinnant "Attempted to default construct a reference element in a tuple");} 1973e519524SHoward Hinnant 1983e519524SHoward Hinnant template <class _Alloc> 1993e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2003e519524SHoward Hinnant __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a) 201def3c375SEric Fiselier : __value_(allocator_arg_t(), __a) 2023e519524SHoward Hinnant {static_assert(!is_reference<_Hp>::value, 2033e519524SHoward Hinnant "Attempted to default construct a reference element in a tuple");} 2043e519524SHoward Hinnant 2053e519524SHoward Hinnant template <class _Alloc> 2063e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2073e519524SHoward Hinnant __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a) 208def3c375SEric Fiselier : __value_(__a) 2093e519524SHoward Hinnant {static_assert(!is_reference<_Hp>::value, 2103e519524SHoward Hinnant "Attempted to default construct a reference element in a tuple");} 2113e519524SHoward Hinnant 21230ad985bSHoward Hinnant template <class _Tp, 213567bb79bSEric Fiselier class = typename enable_if< 214567bb79bSEric Fiselier __lazy_and< 215655c4695SMarshall Clow __lazy_not<is_same<typename __uncvref<_Tp>::type, __tuple_leaf>> 216567bb79bSEric Fiselier , is_constructible<_Hp, _Tp> 217567bb79bSEric Fiselier >::value 218567bb79bSEric Fiselier >::type 219567bb79bSEric Fiselier > 22075eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 2218a9ee148SHoward Hinnant explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) 222def3c375SEric Fiselier : __value_(_VSTD::forward<_Tp>(__t)) 223292617e7SEric Fiselier {static_assert(__can_bind_reference<_Tp&&>(), 224292617e7SEric Fiselier "Attempted construction of reference element binds to a temporary whose lifetime has ended");} 2253e519524SHoward Hinnant 2263e519524SHoward Hinnant template <class _Tp, class _Alloc> 2273e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2283e519524SHoward Hinnant explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t) 229def3c375SEric Fiselier : __value_(_VSTD::forward<_Tp>(__t)) 230292617e7SEric Fiselier {static_assert(__can_bind_reference<_Tp&&>(), 231292617e7SEric Fiselier "Attempted construction of reference element binds to a temporary whose lifetime has ended");} 2323e519524SHoward Hinnant 2333e519524SHoward Hinnant template <class _Tp, class _Alloc> 2343e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2353e519524SHoward Hinnant explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t) 236def3c375SEric Fiselier : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) 237074f8d77SEric Fiselier {static_assert(!is_reference<_Hp>::value, 238074f8d77SEric Fiselier "Attempted to uses-allocator construct a reference element in a tuple");} 2393e519524SHoward Hinnant 2403e519524SHoward Hinnant template <class _Tp, class _Alloc> 2413e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2423e519524SHoward Hinnant explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t) 243def3c375SEric Fiselier : __value_(_VSTD::forward<_Tp>(__t), __a) 244074f8d77SEric Fiselier {static_assert(!is_reference<_Hp>::value, 245074f8d77SEric Fiselier "Attempted to uses-allocator construct a reference element in a tuple");} 2463e519524SHoward Hinnant 2477546a111SMarshall Clow __tuple_leaf(const __tuple_leaf& __t) = default; 2487546a111SMarshall Clow __tuple_leaf(__tuple_leaf&& __t) = default; 2493e519524SHoward Hinnant 2503e519524SHoward Hinnant template <class _Tp> 2513e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2523e519524SHoward Hinnant __tuple_leaf& 2538a9ee148SHoward Hinnant operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value)) 2543e519524SHoward Hinnant { 255def3c375SEric Fiselier __value_ = _VSTD::forward<_Tp>(__t); 2563e519524SHoward Hinnant return *this; 2573e519524SHoward Hinnant } 2583e519524SHoward Hinnant 2593e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 26027d0a2a7SHoward Hinnant int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) 2613e519524SHoward Hinnant { 262ce48a113SHoward Hinnant _VSTD::swap(*this, __t); 2633e519524SHoward Hinnant return 0; 2643e519524SHoward Hinnant } 2653e519524SHoward Hinnant 266def3c375SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;} 267def3c375SEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;} 2683e519524SHoward Hinnant}; 2693e519524SHoward Hinnant 2703e519524SHoward Hinnanttemplate <size_t _Ip, class _Hp> 2713e519524SHoward Hinnantclass __tuple_leaf<_Ip, _Hp, true> 2723e519524SHoward Hinnant : private _Hp 2733e519524SHoward Hinnant{ 2743e519524SHoward Hinnant 2753e519524SHoward Hinnant __tuple_leaf& operator=(const __tuple_leaf&); 2763e519524SHoward Hinnantpublic: 277a0f4c45cSHoward Hinnant _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf() 278a0f4c45cSHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {} 2793e519524SHoward Hinnant 2803e519524SHoward Hinnant template <class _Alloc> 2813e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2823e519524SHoward Hinnant __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {} 2833e519524SHoward Hinnant 2843e519524SHoward Hinnant template <class _Alloc> 2853e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2863e519524SHoward Hinnant __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a) 2873e519524SHoward Hinnant : _Hp(allocator_arg_t(), __a) {} 2883e519524SHoward Hinnant 2893e519524SHoward Hinnant template <class _Alloc> 2903e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2913e519524SHoward Hinnant __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a) 2923e519524SHoward Hinnant : _Hp(__a) {} 2933e519524SHoward Hinnant 29430ad985bSHoward Hinnant template <class _Tp, 295567bb79bSEric Fiselier class = typename enable_if< 296567bb79bSEric Fiselier __lazy_and< 297655c4695SMarshall Clow __lazy_not<is_same<typename __uncvref<_Tp>::type, __tuple_leaf>> 298567bb79bSEric Fiselier , is_constructible<_Hp, _Tp> 299567bb79bSEric Fiselier >::value 300567bb79bSEric Fiselier >::type 301567bb79bSEric Fiselier > 30275eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 3038a9ee148SHoward Hinnant explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) 304ce48a113SHoward Hinnant : _Hp(_VSTD::forward<_Tp>(__t)) {} 3053e519524SHoward Hinnant 3063e519524SHoward Hinnant template <class _Tp, class _Alloc> 3073e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3083e519524SHoward Hinnant explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t) 309ce48a113SHoward Hinnant : _Hp(_VSTD::forward<_Tp>(__t)) {} 3103e519524SHoward Hinnant 3113e519524SHoward Hinnant template <class _Tp, class _Alloc> 3123e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3133e519524SHoward Hinnant explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t) 314ce48a113SHoward Hinnant : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {} 3153e519524SHoward Hinnant 3163e519524SHoward Hinnant template <class _Tp, class _Alloc> 3173e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3183e519524SHoward Hinnant explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t) 319ce48a113SHoward Hinnant : _Hp(_VSTD::forward<_Tp>(__t), __a) {} 3203e519524SHoward Hinnant 321567bb79bSEric Fiselier __tuple_leaf(__tuple_leaf const &) = default; 322567bb79bSEric Fiselier __tuple_leaf(__tuple_leaf &&) = default; 323567bb79bSEric Fiselier 3243e519524SHoward Hinnant template <class _Tp> 3253e519524SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3263e519524SHoward Hinnant __tuple_leaf& 3278a9ee148SHoward Hinnant operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value)) 3283e519524SHoward Hinnant { 329ce48a113SHoward Hinnant _Hp::operator=(_VSTD::forward<_Tp>(__t)); 3303e519524SHoward Hinnant return *this; 3313e519524SHoward Hinnant } 3323e519524SHoward Hinnant 33327d0a2a7SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 33427d0a2a7SHoward Hinnant int 33527d0a2a7SHoward Hinnant swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) 3363e519524SHoward Hinnant { 337ce48a113SHoward Hinnant _VSTD::swap(*this, __t); 3383e519524SHoward Hinnant return 0; 3393e519524SHoward Hinnant } 3403e519524SHoward Hinnant 34175eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);} 34275eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);} 3433e519524SHoward Hinnant}; 3443e519524SHoward Hinnant 345789847ddSHoward Hinnanttemplate <class ..._Tp> 346789847ddSHoward Hinnant_LIBCPP_INLINE_VISIBILITY 3478a9ee148SHoward Hinnantvoid __swallow(_Tp&&...) _NOEXCEPT {} 3483e519524SHoward Hinnant 34990fb2bafSEric Fiseliertemplate <class ..._Tp> 35090fb2bafSEric Fiselierstruct __lazy_all : __all<_Tp::value...> {}; 35190fb2bafSEric Fiselier 35214c5ec51SMarshall Clowtemplate <class _Tp> 35314c5ec51SMarshall Clowstruct __all_default_constructible; 35427d0a2a7SHoward Hinnant 35514c5ec51SMarshall Clowtemplate <class ..._Tp> 35614c5ec51SMarshall Clowstruct __all_default_constructible<__tuple_types<_Tp...>> 35714c5ec51SMarshall Clow : __all<is_default_constructible<_Tp>::value...> 35814c5ec51SMarshall Clow{ }; 35927d0a2a7SHoward Hinnant 3603e519524SHoward Hinnant// __tuple_impl 3613e519524SHoward Hinnant 3623e519524SHoward Hinnanttemplate<class _Indx, class ..._Tp> struct __tuple_impl; 3633e519524SHoward Hinnant 3643e519524SHoward Hinnanttemplate<size_t ..._Indx, class ..._Tp> 365b43f17c8SEric Fiselierstruct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...> 3663e519524SHoward Hinnant : public __tuple_leaf<_Indx, _Tp>... 3673e519524SHoward Hinnant{ 368a62ebe04SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 369a0f4c45cSHoward Hinnant _LIBCPP_CONSTEXPR __tuple_impl() 370a0f4c45cSHoward Hinnant _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {} 371a62ebe04SHoward Hinnant 3723e519524SHoward Hinnant template <size_t ..._Uf, class ..._Tf, 3733e519524SHoward Hinnant size_t ..._Ul, class ..._Tl, class ..._Up> 37475eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 3753e519524SHoward Hinnant explicit 3763e519524SHoward Hinnant __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>, 3773e519524SHoward Hinnant __tuple_indices<_Ul...>, __tuple_types<_Tl...>, 3788a9ee148SHoward Hinnant _Up&&... __u) 3798a9ee148SHoward Hinnant _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value && 3808a9ee148SHoward Hinnant __all<is_nothrow_default_constructible<_Tl>::value...>::value)) : 381ce48a113SHoward Hinnant __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))..., 3823e519524SHoward Hinnant __tuple_leaf<_Ul, _Tl>()... 3833e519524SHoward Hinnant {} 3843e519524SHoward Hinnant 3853e519524SHoward Hinnant template <class _Alloc, size_t ..._Uf, class ..._Tf, 3863e519524SHoward Hinnant size_t ..._Ul, class ..._Tl, class ..._Up> 387789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3883e519524SHoward Hinnant explicit 3893e519524SHoward Hinnant __tuple_impl(allocator_arg_t, const _Alloc& __a, 3903e519524SHoward Hinnant __tuple_indices<_Uf...>, __tuple_types<_Tf...>, 3913e519524SHoward Hinnant __tuple_indices<_Ul...>, __tuple_types<_Tl...>, 3923e519524SHoward Hinnant _Up&&... __u) : 3933e519524SHoward Hinnant __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a, 394ce48a113SHoward Hinnant _VSTD::forward<_Up>(__u))..., 3953e519524SHoward Hinnant __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)... 3963e519524SHoward Hinnant {} 3973e519524SHoward Hinnant 3983e519524SHoward Hinnant template <class _Tuple, 3993e519524SHoward Hinnant class = typename enable_if 4003e519524SHoward Hinnant < 401f3b02b17SHoward Hinnant __tuple_constructible<_Tuple, tuple<_Tp...> >::value 4023e519524SHoward Hinnant >::type 4033e519524SHoward Hinnant > 40475eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 4058a9ee148SHoward Hinnant __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx, 4068a9ee148SHoward Hinnant typename __make_tuple_types<_Tuple>::type>::type>::value...>::value)) 407ce48a113SHoward Hinnant : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx, 408ce48a113SHoward Hinnant typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))... 4093e519524SHoward Hinnant {} 4103e519524SHoward Hinnant 4113e519524SHoward Hinnant template <class _Alloc, class _Tuple, 4123e519524SHoward Hinnant class = typename enable_if 4133e519524SHoward Hinnant < 4149795699aSEric Fiselier __tuple_constructible<_Tuple, tuple<_Tp...> >::value 4153e519524SHoward Hinnant >::type 4163e519524SHoward Hinnant > 417789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 4183e519524SHoward Hinnant __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t) 4193e519524SHoward Hinnant : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx, 4203e519524SHoward Hinnant typename __make_tuple_types<_Tuple>::type>::type>(), __a, 421ce48a113SHoward Hinnant _VSTD::forward<typename tuple_element<_Indx, 422ce48a113SHoward Hinnant typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))... 4233e519524SHoward Hinnant {} 4243e519524SHoward Hinnant 4253e519524SHoward Hinnant template <class _Tuple> 426789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 4273e519524SHoward Hinnant typename enable_if 4283e519524SHoward Hinnant < 4293e519524SHoward Hinnant __tuple_assignable<_Tuple, tuple<_Tp...> >::value, 4303e519524SHoward Hinnant __tuple_impl& 4313e519524SHoward Hinnant >::type 4328a9ee148SHoward Hinnant operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx, 4338a9ee148SHoward Hinnant typename __make_tuple_types<_Tuple>::type>::type>::value...>::value)) 4343e519524SHoward Hinnant { 435ce48a113SHoward Hinnant __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx, 436ce48a113SHoward Hinnant typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...); 4373e519524SHoward Hinnant return *this; 4383e519524SHoward Hinnant } 4393e519524SHoward Hinnant 4404478b25aSHoward Hinnant __tuple_impl(const __tuple_impl&) = default; 4414478b25aSHoward Hinnant __tuple_impl(__tuple_impl&&) = default; 4424478b25aSHoward Hinnant 443789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 444fa8df7dbSHoward Hinnant __tuple_impl& 4458a9ee148SHoward Hinnant operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value)) 446fa8df7dbSHoward Hinnant { 447fa8df7dbSHoward Hinnant __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...); 448fa8df7dbSHoward Hinnant return *this; 449fa8df7dbSHoward Hinnant } 450fa8df7dbSHoward Hinnant 451fa8df7dbSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 4524478b25aSHoward Hinnant __tuple_impl& 4534478b25aSHoward Hinnant operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value)) 4544478b25aSHoward Hinnant { 4554478b25aSHoward Hinnant __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...); 4564478b25aSHoward Hinnant return *this; 4574478b25aSHoward Hinnant } 4584478b25aSHoward Hinnant 4594478b25aSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 4603e519524SHoward Hinnant void swap(__tuple_impl& __t) 46127d0a2a7SHoward Hinnant _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) 4623e519524SHoward Hinnant { 4633e519524SHoward Hinnant __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...); 4643e519524SHoward Hinnant } 4653e519524SHoward Hinnant}; 4663e519524SHoward Hinnant 46774cba642SEric Fiselier 46874cba642SEric Fiselier 4693e519524SHoward Hinnanttemplate <class ..._Tp> 470e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS tuple 4713e519524SHoward Hinnant{ 472def3c375SEric Fiselier typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT; 4733e519524SHoward Hinnant 474def3c375SEric Fiselier _BaseT __base_; 4753e519524SHoward Hinnant 476bd688258SEric Fiselier#if defined(_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION) 477bd688258SEric Fiselier static constexpr bool _EnableImplicitReducedArityExtension = true; 478bd688258SEric Fiselier#else 479bd688258SEric Fiselier static constexpr bool _EnableImplicitReducedArityExtension = false; 480bd688258SEric Fiselier#endif 481bd688258SEric Fiselier 48274cba642SEric Fiselier template <class ..._Args> 48374cba642SEric Fiselier struct _PackExpandsToThisTuple : false_type {}; 48474cba642SEric Fiselier 48574cba642SEric Fiselier template <class _Arg> 48674cba642SEric Fiselier struct _PackExpandsToThisTuple<_Arg> 48774cba642SEric Fiselier : is_same<typename __uncvref<_Arg>::type, tuple> {}; 48874cba642SEric Fiselier 48974cba642SEric Fiselier template <bool _MaybeEnable, class _Dummy = void> 49074cba642SEric Fiselier struct _CheckArgsConstructor : __check_tuple_constructor_fail {}; 49174cba642SEric Fiselier 49274cba642SEric Fiselier template <class _Dummy> 49374cba642SEric Fiselier struct _CheckArgsConstructor<true, _Dummy> 49474cba642SEric Fiselier { 49574cba642SEric Fiselier template <class ..._Args> 4964927c295SEric Fiselier static constexpr bool __enable_default() { 4974927c295SEric Fiselier return __all<is_default_constructible<_Args>::value...>::value; 4984927c295SEric Fiselier } 4994927c295SEric Fiselier 5004927c295SEric Fiselier template <class ..._Args> 50174cba642SEric Fiselier static constexpr bool __enable_explicit() { 50274cba642SEric Fiselier return 50374cba642SEric Fiselier __tuple_constructible< 50474cba642SEric Fiselier tuple<_Args...>, 50574cba642SEric Fiselier typename __make_tuple_types<tuple, 50674cba642SEric Fiselier sizeof...(_Args) < sizeof...(_Tp) ? 50774cba642SEric Fiselier sizeof...(_Args) : 50874cba642SEric Fiselier sizeof...(_Tp)>::type 50974cba642SEric Fiselier >::value && 51074cba642SEric Fiselier !__tuple_convertible< 51174cba642SEric Fiselier tuple<_Args...>, 51274cba642SEric Fiselier typename __make_tuple_types<tuple, 51374cba642SEric Fiselier sizeof...(_Args) < sizeof...(_Tp) ? 51474cba642SEric Fiselier sizeof...(_Args) : 51574cba642SEric Fiselier sizeof...(_Tp)>::type 51674cba642SEric Fiselier >::value && 51774cba642SEric Fiselier __all_default_constructible< 51874cba642SEric Fiselier typename __make_tuple_types<tuple, sizeof...(_Tp), 51974cba642SEric Fiselier sizeof...(_Args) < sizeof...(_Tp) ? 52074cba642SEric Fiselier sizeof...(_Args) : 52174cba642SEric Fiselier sizeof...(_Tp)>::type 52274cba642SEric Fiselier >::value; 52374cba642SEric Fiselier } 52474cba642SEric Fiselier 52574cba642SEric Fiselier template <class ..._Args> 52674cba642SEric Fiselier static constexpr bool __enable_implicit() { 52774cba642SEric Fiselier return 52874cba642SEric Fiselier __tuple_convertible< 52974cba642SEric Fiselier tuple<_Args...>, 53074cba642SEric Fiselier typename __make_tuple_types<tuple, 53174cba642SEric Fiselier sizeof...(_Args) < sizeof...(_Tp) ? 53274cba642SEric Fiselier sizeof...(_Args) : 53374cba642SEric Fiselier sizeof...(_Tp)>::type 53474cba642SEric Fiselier >::value && 53574cba642SEric Fiselier __all_default_constructible< 53674cba642SEric Fiselier typename __make_tuple_types<tuple, sizeof...(_Tp), 53774cba642SEric Fiselier sizeof...(_Args) < sizeof...(_Tp) ? 53874cba642SEric Fiselier sizeof...(_Args) : 53974cba642SEric Fiselier sizeof...(_Tp)>::type 54074cba642SEric Fiselier >::value; 54174cba642SEric Fiselier } 54274cba642SEric Fiselier }; 54374cba642SEric Fiselier 54474cba642SEric Fiselier template <bool _MaybeEnable, 54574cba642SEric Fiselier bool = sizeof...(_Tp) == 1, 54674cba642SEric Fiselier class _Dummy = void> 54774cba642SEric Fiselier struct _CheckTupleLikeConstructor : __check_tuple_constructor_fail {}; 54874cba642SEric Fiselier 54974cba642SEric Fiselier template <class _Dummy> 55074cba642SEric Fiselier struct _CheckTupleLikeConstructor<true, false, _Dummy> 55174cba642SEric Fiselier { 55274cba642SEric Fiselier template <class _Tuple> 55374cba642SEric Fiselier static constexpr bool __enable_implicit() { 554347a1cc2SEric Fiselier return __tuple_convertible<_Tuple, tuple>::value; 55574cba642SEric Fiselier } 55674cba642SEric Fiselier 55774cba642SEric Fiselier template <class _Tuple> 55874cba642SEric Fiselier static constexpr bool __enable_explicit() { 559347a1cc2SEric Fiselier return __tuple_constructible<_Tuple, tuple>::value 560347a1cc2SEric Fiselier && !__tuple_convertible<_Tuple, tuple>::value; 56174cba642SEric Fiselier } 56274cba642SEric Fiselier }; 56374cba642SEric Fiselier 56474cba642SEric Fiselier template <class _Dummy> 56574cba642SEric Fiselier struct _CheckTupleLikeConstructor<true, true, _Dummy> 56674cba642SEric Fiselier { 56774cba642SEric Fiselier // This trait is used to disable the tuple-like constructor when 56874cba642SEric Fiselier // the UTypes... constructor should be selected instead. 56974cba642SEric Fiselier // See LWG issue #2549. 57074cba642SEric Fiselier template <class _Tuple> 57174cba642SEric Fiselier using _PreferTupleLikeConstructor = __lazy_or< 57274cba642SEric Fiselier // Don't attempt the two checks below if the tuple we are given 57374cba642SEric Fiselier // has the same type as this tuple. 57474cba642SEric Fiselier is_same<typename __uncvref<_Tuple>::type, tuple>, 57574cba642SEric Fiselier __lazy_and< 57674cba642SEric Fiselier __lazy_not<is_constructible<_Tp..., _Tuple>>, 57774cba642SEric Fiselier __lazy_not<is_convertible<_Tuple, _Tp...>> 57874cba642SEric Fiselier > 57974cba642SEric Fiselier >; 58074cba642SEric Fiselier 58174cba642SEric Fiselier template <class _Tuple> 58274cba642SEric Fiselier static constexpr bool __enable_implicit() { 58374cba642SEric Fiselier return __lazy_and< 58474cba642SEric Fiselier __tuple_convertible<_Tuple, tuple>, 58574cba642SEric Fiselier _PreferTupleLikeConstructor<_Tuple> 58674cba642SEric Fiselier >::value; 58774cba642SEric Fiselier } 58874cba642SEric Fiselier 58974cba642SEric Fiselier template <class _Tuple> 59074cba642SEric Fiselier static constexpr bool __enable_explicit() { 59174cba642SEric Fiselier return __lazy_and< 59274cba642SEric Fiselier __tuple_constructible<_Tuple, tuple>, 59374cba642SEric Fiselier _PreferTupleLikeConstructor<_Tuple>, 59474cba642SEric Fiselier __lazy_not<__tuple_convertible<_Tuple, tuple>> 59574cba642SEric Fiselier >::value; 59674cba642SEric Fiselier } 59774cba642SEric Fiselier }; 59874cba642SEric Fiselier 5998bf1f08aSMarshall Clow template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11 600c206366fSHoward Hinnant typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT; 6018bf1f08aSMarshall Clow template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11 602c206366fSHoward Hinnant const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT; 6038bf1f08aSMarshall Clow template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11 604c206366fSHoward Hinnant typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT; 605545b8861SEric Fiselier template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11 606545b8861SEric Fiselier const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT; 6073e519524SHoward Hinnantpublic: 6083e519524SHoward Hinnant 60965500d4bSEric Fiselier template <bool _Dummy = true, class = typename enable_if< 6104927c295SEric Fiselier _CheckArgsConstructor<_Dummy>::template __enable_default<_Tp...>() 61114c5ec51SMarshall Clow >::type> 612789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 613a0f4c45cSHoward Hinnant _LIBCPP_CONSTEXPR tuple() 614a0f4c45cSHoward Hinnant _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {} 615a62ebe04SHoward Hinnant 616aedcbf89SEric Fiselier tuple(tuple const&) = default; 617aedcbf89SEric Fiselier tuple(tuple&&) = default; 618aedcbf89SEric Fiselier 61990fb2bafSEric Fiselier template <class _AllocArgT, class _Alloc, bool _Dummy = true, class = typename enable_if< 62090fb2bafSEric Fiselier __lazy_and< 62109238677SEric Fiselier is_same<allocator_arg_t, _AllocArgT>, 62290fb2bafSEric Fiselier __lazy_all<__dependent_type<is_default_constructible<_Tp>, _Dummy>...> 62390fb2bafSEric Fiselier >::value 62490fb2bafSEric Fiselier >::type> 62590fb2bafSEric Fiselier _LIBCPP_INLINE_VISIBILITY 62690fb2bafSEric Fiselier tuple(_AllocArgT, _Alloc const& __a) 627def3c375SEric Fiselier : __base_(allocator_arg_t(), __a, 62890fb2bafSEric Fiselier __tuple_indices<>(), __tuple_types<>(), 62990fb2bafSEric Fiselier typename __make_tuple_indices<sizeof...(_Tp), 0>::type(), 63090fb2bafSEric Fiselier __tuple_types<_Tp...>()) {} 63190fb2bafSEric Fiselier 6329795699aSEric Fiselier template <bool _Dummy = true, 6339795699aSEric Fiselier typename enable_if 6349795699aSEric Fiselier < 6359795699aSEric Fiselier _CheckArgsConstructor< 6369795699aSEric Fiselier _Dummy 63740905833SEric Fiselier >::template __enable_implicit<_Tp const&...>(), 6389795699aSEric Fiselier bool 6399795699aSEric Fiselier >::type = false 6409795699aSEric Fiselier > 6419795699aSEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 6429795699aSEric Fiselier tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value)) 643def3c375SEric Fiselier : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(), 6449795699aSEric Fiselier typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), 6459795699aSEric Fiselier typename __make_tuple_indices<0>::type(), 6469795699aSEric Fiselier typename __make_tuple_types<tuple, 0>::type(), 6479795699aSEric Fiselier __t... 6489795699aSEric Fiselier ) {} 6499795699aSEric Fiselier 6509795699aSEric Fiselier template <bool _Dummy = true, 6519795699aSEric Fiselier typename enable_if 6529795699aSEric Fiselier < 6539795699aSEric Fiselier _CheckArgsConstructor< 6549795699aSEric Fiselier _Dummy 65540905833SEric Fiselier >::template __enable_explicit<_Tp const&...>(), 6569795699aSEric Fiselier bool 6579795699aSEric Fiselier >::type = false 6589795699aSEric Fiselier > 65975eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 6608a9ee148SHoward Hinnant explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value)) 661def3c375SEric Fiselier : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(), 6623e519524SHoward Hinnant typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), 6633e519524SHoward Hinnant typename __make_tuple_indices<0>::type(), 6643e519524SHoward Hinnant typename __make_tuple_types<tuple, 0>::type(), 6653e519524SHoward Hinnant __t... 6663e519524SHoward Hinnant ) {} 6673e519524SHoward Hinnant 6689795699aSEric Fiselier template <class _Alloc, bool _Dummy = true, 6699795699aSEric Fiselier typename enable_if 6709795699aSEric Fiselier < 6719795699aSEric Fiselier _CheckArgsConstructor< 6729795699aSEric Fiselier _Dummy 67340905833SEric Fiselier >::template __enable_implicit<_Tp const&...>(), 6749795699aSEric Fiselier bool 6759795699aSEric Fiselier >::type = false 6769795699aSEric Fiselier > 677789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 6783e519524SHoward Hinnant tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t) 679def3c375SEric Fiselier : __base_(allocator_arg_t(), __a, 6803e519524SHoward Hinnant typename __make_tuple_indices<sizeof...(_Tp)>::type(), 6813e519524SHoward Hinnant typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), 6823e519524SHoward Hinnant typename __make_tuple_indices<0>::type(), 6833e519524SHoward Hinnant typename __make_tuple_types<tuple, 0>::type(), 6843e519524SHoward Hinnant __t... 6853e519524SHoward Hinnant ) {} 6863e519524SHoward Hinnant 6879795699aSEric Fiselier template <class _Alloc, bool _Dummy = true, 6889795699aSEric Fiselier typename enable_if 6899795699aSEric Fiselier < 6909795699aSEric Fiselier _CheckArgsConstructor< 6919795699aSEric Fiselier _Dummy 69240905833SEric Fiselier >::template __enable_explicit<_Tp const&...>(), 6939795699aSEric Fiselier bool 6949795699aSEric Fiselier >::type = false 6959795699aSEric Fiselier > 6969795699aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 6979795699aSEric Fiselier explicit 6989795699aSEric Fiselier tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t) 699def3c375SEric Fiselier : __base_(allocator_arg_t(), __a, 7009795699aSEric Fiselier typename __make_tuple_indices<sizeof...(_Tp)>::type(), 7019795699aSEric Fiselier typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), 7029795699aSEric Fiselier typename __make_tuple_indices<0>::type(), 7039795699aSEric Fiselier typename __make_tuple_types<tuple, 0>::type(), 7049795699aSEric Fiselier __t... 7059795699aSEric Fiselier ) {} 7069795699aSEric Fiselier 7073e519524SHoward Hinnant template <class ..._Up, 708bd688258SEric Fiselier bool _PackIsTuple = _PackExpandsToThisTuple<_Up...>::value, 7090527c620SHoward Hinnant typename enable_if 7103e519524SHoward Hinnant < 71174cba642SEric Fiselier _CheckArgsConstructor< 712bd688258SEric Fiselier sizeof...(_Up) == sizeof...(_Tp) 713bd688258SEric Fiselier && !_PackIsTuple 714bd688258SEric Fiselier >::template __enable_implicit<_Up...>() || 715bd688258SEric Fiselier _CheckArgsConstructor< 716bd688258SEric Fiselier _EnableImplicitReducedArityExtension 717bd688258SEric Fiselier && sizeof...(_Up) < sizeof...(_Tp) 718bd688258SEric Fiselier && !_PackIsTuple 71974cba642SEric Fiselier >::template __enable_implicit<_Up...>(), 7200527c620SHoward Hinnant bool 7210527c620SHoward Hinnant >::type = false 7220527c620SHoward Hinnant > 72375eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 7240527c620SHoward Hinnant tuple(_Up&&... __u) 7258a9ee148SHoward Hinnant _NOEXCEPT_(( 726def3c375SEric Fiselier is_nothrow_constructible<_BaseT, 7278a9ee148SHoward Hinnant typename __make_tuple_indices<sizeof...(_Up)>::type, 7288a9ee148SHoward Hinnant typename __make_tuple_types<tuple, sizeof...(_Up)>::type, 7298a9ee148SHoward Hinnant typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type, 7308a9ee148SHoward Hinnant typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type, 73110a65e2eSMarshall Clow _Up... 7328a9ee148SHoward Hinnant >::value 7338a9ee148SHoward Hinnant )) 734def3c375SEric Fiselier : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(), 7350527c620SHoward Hinnant typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), 7360527c620SHoward Hinnant typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), 7370527c620SHoward Hinnant typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), 7380527c620SHoward Hinnant _VSTD::forward<_Up>(__u)...) {} 7390527c620SHoward Hinnant 7400527c620SHoward Hinnant template <class ..._Up, 7410527c620SHoward Hinnant typename enable_if 7420527c620SHoward Hinnant < 74374cba642SEric Fiselier _CheckArgsConstructor< 74474cba642SEric Fiselier sizeof...(_Up) <= sizeof...(_Tp) 74574cba642SEric Fiselier && !_PackExpandsToThisTuple<_Up...>::value 746bd688258SEric Fiselier >::template __enable_explicit<_Up...>() || 747bd688258SEric Fiselier _CheckArgsConstructor< 748bd688258SEric Fiselier !_EnableImplicitReducedArityExtension 749bd688258SEric Fiselier && sizeof...(_Up) < sizeof...(_Tp) 7505ddaeb88SEric Fiselier && !_PackExpandsToThisTuple<_Up...>::value 751bd688258SEric Fiselier >::template __enable_implicit<_Up...>(), 7520527c620SHoward Hinnant bool 7530527c620SHoward Hinnant >::type = false 7543e519524SHoward Hinnant > 75575eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 7563e519524SHoward Hinnant explicit 7573e519524SHoward Hinnant tuple(_Up&&... __u) 7588a9ee148SHoward Hinnant _NOEXCEPT_(( 759def3c375SEric Fiselier is_nothrow_constructible<_BaseT, 7608a9ee148SHoward Hinnant typename __make_tuple_indices<sizeof...(_Up)>::type, 7618a9ee148SHoward Hinnant typename __make_tuple_types<tuple, sizeof...(_Up)>::type, 7628a9ee148SHoward Hinnant typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type, 7638a9ee148SHoward Hinnant typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type, 7648a9ee148SHoward Hinnant _Up... 7658a9ee148SHoward Hinnant >::value 7668a9ee148SHoward Hinnant )) 767def3c375SEric Fiselier : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(), 7683e519524SHoward Hinnant typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), 7693e519524SHoward Hinnant typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), 7703e519524SHoward Hinnant typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), 771ce48a113SHoward Hinnant _VSTD::forward<_Up>(__u)...) {} 7723e519524SHoward Hinnant 7733e519524SHoward Hinnant template <class _Alloc, class ..._Up, 7749795699aSEric Fiselier typename enable_if 7753e519524SHoward Hinnant < 77674cba642SEric Fiselier _CheckArgsConstructor< 77790fb2bafSEric Fiselier sizeof...(_Up) == sizeof...(_Tp) && 77874cba642SEric Fiselier !_PackExpandsToThisTuple<_Up...>::value 7799795699aSEric Fiselier >::template __enable_implicit<_Up...>(), 7809795699aSEric Fiselier bool 7819795699aSEric Fiselier >::type = false 7823e519524SHoward Hinnant > 783789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 7843e519524SHoward Hinnant tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u) 785def3c375SEric Fiselier : __base_(allocator_arg_t(), __a, 7863e519524SHoward Hinnant typename __make_tuple_indices<sizeof...(_Up)>::type(), 7873e519524SHoward Hinnant typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), 7883e519524SHoward Hinnant typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), 7893e519524SHoward Hinnant typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), 790ce48a113SHoward Hinnant _VSTD::forward<_Up>(__u)...) {} 7913e519524SHoward Hinnant 7929795699aSEric Fiselier template <class _Alloc, class ..._Up, 7939795699aSEric Fiselier typename enable_if 7949795699aSEric Fiselier < 7959795699aSEric Fiselier _CheckArgsConstructor< 7969795699aSEric Fiselier sizeof...(_Up) == sizeof...(_Tp) && 7979795699aSEric Fiselier !_PackExpandsToThisTuple<_Up...>::value 7989795699aSEric Fiselier >::template __enable_explicit<_Up...>(), 7999795699aSEric Fiselier bool 8009795699aSEric Fiselier >::type = false 8019795699aSEric Fiselier > 8029795699aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 8039795699aSEric Fiselier explicit 8049795699aSEric Fiselier tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u) 805def3c375SEric Fiselier : __base_(allocator_arg_t(), __a, 8069795699aSEric Fiselier typename __make_tuple_indices<sizeof...(_Up)>::type(), 8079795699aSEric Fiselier typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), 8089795699aSEric Fiselier typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), 8099795699aSEric Fiselier typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), 8109795699aSEric Fiselier _VSTD::forward<_Up>(__u)...) {} 8119795699aSEric Fiselier 8123e519524SHoward Hinnant template <class _Tuple, 8130527c620SHoward Hinnant typename enable_if 8143e519524SHoward Hinnant < 81574cba642SEric Fiselier _CheckTupleLikeConstructor< 816347a1cc2SEric Fiselier __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value 817347a1cc2SEric Fiselier && !_PackExpandsToThisTuple<_Tuple>::value 818347a1cc2SEric Fiselier >::template __enable_implicit<_Tuple>(), 8190527c620SHoward Hinnant bool 8200527c620SHoward Hinnant >::type = false 8213e519524SHoward Hinnant > 82275eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 823def3c375SEric Fiselier tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value)) 824def3c375SEric Fiselier : __base_(_VSTD::forward<_Tuple>(__t)) {} 8253e519524SHoward Hinnant 8260527c620SHoward Hinnant template <class _Tuple, 8270527c620SHoward Hinnant typename enable_if 8280527c620SHoward Hinnant < 82974cba642SEric Fiselier _CheckTupleLikeConstructor< 830347a1cc2SEric Fiselier __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value 831347a1cc2SEric Fiselier && !_PackExpandsToThisTuple<_Tuple>::value 832347a1cc2SEric Fiselier >::template __enable_explicit<_Tuple>(), 8330527c620SHoward Hinnant bool 8340527c620SHoward Hinnant >::type = false 8350527c620SHoward Hinnant > 83675eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 8370527c620SHoward Hinnant explicit 838def3c375SEric Fiselier tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value)) 839def3c375SEric Fiselier : __base_(_VSTD::forward<_Tuple>(__t)) {} 8400527c620SHoward Hinnant 8413e519524SHoward Hinnant template <class _Alloc, class _Tuple, 8429795699aSEric Fiselier typename enable_if 8433e519524SHoward Hinnant < 84474cba642SEric Fiselier _CheckTupleLikeConstructor< 845347a1cc2SEric Fiselier __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value 846347a1cc2SEric Fiselier >::template __enable_implicit<_Tuple>(), 8479795699aSEric Fiselier bool 8489795699aSEric Fiselier >::type = false 8493e519524SHoward Hinnant > 850789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 8513e519524SHoward Hinnant tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t) 852def3c375SEric Fiselier : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {} 8533e519524SHoward Hinnant 8549795699aSEric Fiselier template <class _Alloc, class _Tuple, 8559795699aSEric Fiselier typename enable_if 8569795699aSEric Fiselier < 8579795699aSEric Fiselier _CheckTupleLikeConstructor< 858347a1cc2SEric Fiselier __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value 859347a1cc2SEric Fiselier >::template __enable_explicit<_Tuple>(), 8609795699aSEric Fiselier bool 8619795699aSEric Fiselier >::type = false 8629795699aSEric Fiselier > 8639795699aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 8649795699aSEric Fiselier explicit 8659795699aSEric Fiselier tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t) 866def3c375SEric Fiselier : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {} 8679795699aSEric Fiselier 868aedcbf89SEric Fiselier using _CanCopyAssign = __all<is_copy_assignable<_Tp>::value...>; 869aedcbf89SEric Fiselier using _CanMoveAssign = __all<is_move_assignable<_Tp>::value...>; 870aedcbf89SEric Fiselier 871aedcbf89SEric Fiselier _LIBCPP_INLINE_VISIBILITY 872347a1cc2SEric Fiselier tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, __nat>::type const& __t) 873aedcbf89SEric Fiselier _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value)) 874aedcbf89SEric Fiselier { 875def3c375SEric Fiselier __base_.operator=(__t.__base_); 876aedcbf89SEric Fiselier return *this; 877aedcbf89SEric Fiselier } 878aedcbf89SEric Fiselier 879aedcbf89SEric Fiselier _LIBCPP_INLINE_VISIBILITY 880aedcbf89SEric Fiselier tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, __nat>::type&& __t) 881aedcbf89SEric Fiselier _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value)) 882aedcbf89SEric Fiselier { 883def3c375SEric Fiselier __base_.operator=(static_cast<_BaseT&&>(__t.__base_)); 884aedcbf89SEric Fiselier return *this; 885aedcbf89SEric Fiselier } 886aedcbf89SEric Fiselier 8873e519524SHoward Hinnant template <class _Tuple, 8883e519524SHoward Hinnant class = typename enable_if 8893e519524SHoward Hinnant < 890347a1cc2SEric Fiselier __tuple_assignable<_Tuple, tuple>::value 8913e519524SHoward Hinnant >::type 8923e519524SHoward Hinnant > 893789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 8943e519524SHoward Hinnant tuple& 895def3c375SEric Fiselier operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<_BaseT&, _Tuple>::value)) 8963e519524SHoward Hinnant { 897def3c375SEric Fiselier __base_.operator=(_VSTD::forward<_Tuple>(__t)); 8983e519524SHoward Hinnant return *this; 8993e519524SHoward Hinnant } 9003e519524SHoward Hinnant 901789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 90227d0a2a7SHoward Hinnant void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) 903def3c375SEric Fiselier {__base_.swap(__t.__base_);} 9043e519524SHoward Hinnant}; 9053e519524SHoward Hinnant 9063e519524SHoward Hinnanttemplate <> 907e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS tuple<> 9083e519524SHoward Hinnant{ 9093e519524SHoward Hinnantpublic: 910789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 911a0f4c45cSHoward Hinnant _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {} 9123e519524SHoward Hinnant template <class _Alloc> 913789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 9148a9ee148SHoward Hinnant tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {} 9153e519524SHoward Hinnant template <class _Alloc> 916789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 9178a9ee148SHoward Hinnant tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {} 918c003db1fSHoward Hinnant template <class _Up> 919789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 9208a9ee148SHoward Hinnant tuple(array<_Up, 0>) _NOEXCEPT {} 921c003db1fSHoward Hinnant template <class _Alloc, class _Up> 922789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 9238a9ee148SHoward Hinnant tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {} 924789847ddSHoward Hinnant _LIBCPP_INLINE_VISIBILITY 92527d0a2a7SHoward Hinnant void swap(tuple&) _NOEXCEPT {} 9263e519524SHoward Hinnant}; 9273e519524SHoward Hinnant 928af65856eSEric Fiselier#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES 929baaee206SEric Fiselier// NOTE: These are not yet standardized, but are required to simulate the 930baaee206SEric Fiselier// implicit deduction guide that should be generated had libc++ declared the 931baaee206SEric Fiselier// tuple-like constructors "correctly" 932baaee206SEric Fiseliertemplate <class _Alloc, class ..._Args> 933baaee206SEric Fiseliertuple(allocator_arg_t, const _Alloc&, tuple<_Args...> const&) -> tuple<_Args...>; 934baaee206SEric Fiseliertemplate <class _Alloc, class ..._Args> 935baaee206SEric Fiseliertuple(allocator_arg_t, const _Alloc&, tuple<_Args...>&&) -> tuple<_Args...>; 936baaee206SEric Fiselier#endif 937baaee206SEric Fiselier 9383e519524SHoward Hinnanttemplate <class ..._Tp> 9393e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 940bc95cf0dSHoward Hinnanttypename enable_if 941bc95cf0dSHoward Hinnant< 942bc95cf0dSHoward Hinnant __all<__is_swappable<_Tp>::value...>::value, 9433e519524SHoward Hinnant void 944bc95cf0dSHoward Hinnant>::type 94527d0a2a7SHoward Hinnantswap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) 94627d0a2a7SHoward Hinnant _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) 94727d0a2a7SHoward Hinnant {__t.swap(__u);} 9483e519524SHoward Hinnant 9493e519524SHoward Hinnant// get 9503e519524SHoward Hinnant 9513e519524SHoward Hinnanttemplate <size_t _Ip, class ..._Tp> 9528bf1f08aSMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 9533e519524SHoward Hinnanttypename tuple_element<_Ip, tuple<_Tp...> >::type& 954c206366fSHoward Hinnantget(tuple<_Tp...>& __t) _NOEXCEPT 9553e519524SHoward Hinnant{ 9563e519524SHoward Hinnant typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; 957def3c375SEric Fiselier return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get(); 9583e519524SHoward Hinnant} 9593e519524SHoward Hinnant 9603e519524SHoward Hinnanttemplate <size_t _Ip, class ..._Tp> 9618bf1f08aSMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 9623e519524SHoward Hinnantconst typename tuple_element<_Ip, tuple<_Tp...> >::type& 963c206366fSHoward Hinnantget(const tuple<_Tp...>& __t) _NOEXCEPT 9643e519524SHoward Hinnant{ 9653e519524SHoward Hinnant typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; 966def3c375SEric Fiselier return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get(); 9673e519524SHoward Hinnant} 9683e519524SHoward Hinnant 969601afb30SHoward Hinnanttemplate <size_t _Ip, class ..._Tp> 9708bf1f08aSMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 971601afb30SHoward Hinnanttypename tuple_element<_Ip, tuple<_Tp...> >::type&& 972c206366fSHoward Hinnantget(tuple<_Tp...>&& __t) _NOEXCEPT 973601afb30SHoward Hinnant{ 974601afb30SHoward Hinnant typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; 9752a3f1bc1SHoward Hinnant return static_cast<type&&>( 976def3c375SEric Fiselier static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get()); 977601afb30SHoward Hinnant} 978601afb30SHoward Hinnant 979545b8861SEric Fiseliertemplate <size_t _Ip, class ..._Tp> 980545b8861SEric Fiselierinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 981545b8861SEric Fiselierconst typename tuple_element<_Ip, tuple<_Tp...> >::type&& 982545b8861SEric Fiselierget(const tuple<_Tp...>&& __t) _NOEXCEPT 983545b8861SEric Fiselier{ 984545b8861SEric Fiselier typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; 985545b8861SEric Fiselier return static_cast<const type&&>( 986def3c375SEric Fiselier static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get()); 987545b8861SEric Fiselier} 988545b8861SEric Fiselier 989e99520c7SMarshall Clow#if _LIBCPP_STD_VER > 11 990e99520c7SMarshall Clow 991f447e62eSEric Fiseliernamespace __find_detail { 992f447e62eSEric Fiselier 993f447e62eSEric Fiselierstatic constexpr size_t __not_found = -1; 994f447e62eSEric Fiselierstatic constexpr size_t __ambiguous = __not_found - 1; 995f447e62eSEric Fiselier 996f447e62eSEric Fiselierinline _LIBCPP_INLINE_VISIBILITY 997f447e62eSEric Fiselierconstexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) { 998f447e62eSEric Fiselier return !__matches ? __res : 999f447e62eSEric Fiselier (__res == __not_found ? __curr_i : __ambiguous); 1000f447e62eSEric Fiselier} 1001f447e62eSEric Fiselier 1002f447e62eSEric Fiseliertemplate <size_t _Nx> 1003f447e62eSEric Fiselierinline _LIBCPP_INLINE_VISIBILITY 1004f447e62eSEric Fiselierconstexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) { 1005f447e62eSEric Fiselier return __i == _Nx ? __not_found : 1006f447e62eSEric Fiselier __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]); 1007f447e62eSEric Fiselier} 1008f447e62eSEric Fiselier 1009f447e62eSEric Fiseliertemplate <class _T1, class ..._Args> 1010f447e62eSEric Fiselierstruct __find_exactly_one_checked { 101100c872f3SCasey Carter static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...}; 1012f447e62eSEric Fiselier static constexpr size_t value = __find_detail::__find_idx(0, __matches); 1013f447e62eSEric Fiselier static_assert(value != __not_found, "type not found in type list" ); 1014f447e62eSEric Fiselier static_assert(value != __ambiguous, "type occurs more than once in type list"); 1015e99520c7SMarshall Clow}; 1016e99520c7SMarshall Clow 10174f905b8dSEric Fiseliertemplate <class _T1> 10184f905b8dSEric Fiselierstruct __find_exactly_one_checked<_T1> { 10194f905b8dSEric Fiselier static_assert(!is_same<_T1, _T1>::value, "type not in empty type list"); 10204f905b8dSEric Fiselier}; 10214f905b8dSEric Fiselier 1022f447e62eSEric Fiselier} // namespace __find_detail; 1023e99520c7SMarshall Clow 1024e99520c7SMarshall Clowtemplate <typename _T1, typename... _Args> 1025f447e62eSEric Fiselierstruct __find_exactly_one_t 1026f447e62eSEric Fiselier : public __find_detail::__find_exactly_one_checked<_T1, _Args...> { 1027e99520c7SMarshall Clow}; 1028e99520c7SMarshall Clow 1029e99520c7SMarshall Clowtemplate <class _T1, class... _Args> 1030e99520c7SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY 1031e99520c7SMarshall Clowconstexpr _T1& get(tuple<_Args...>& __tup) noexcept 1032e99520c7SMarshall Clow{ 1033e99520c7SMarshall Clow return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); 1034e99520c7SMarshall Clow} 1035e99520c7SMarshall Clow 1036e99520c7SMarshall Clowtemplate <class _T1, class... _Args> 1037e99520c7SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY 1038e99520c7SMarshall Clowconstexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept 1039e99520c7SMarshall Clow{ 1040e99520c7SMarshall Clow return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); 1041e99520c7SMarshall Clow} 1042e99520c7SMarshall Clow 1043e99520c7SMarshall Clowtemplate <class _T1, class... _Args> 1044e99520c7SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY 1045e99520c7SMarshall Clowconstexpr _T1&& get(tuple<_Args...>&& __tup) noexcept 1046e99520c7SMarshall Clow{ 10471c682f0fSMarshall Clow return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup)); 1048e99520c7SMarshall Clow} 1049e99520c7SMarshall Clow 1050545b8861SEric Fiseliertemplate <class _T1, class... _Args> 1051545b8861SEric Fiselierinline _LIBCPP_INLINE_VISIBILITY 1052545b8861SEric Fiselierconstexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept 1053545b8861SEric Fiselier{ 1054545b8861SEric Fiselier return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup)); 1055545b8861SEric Fiselier} 1056545b8861SEric Fiselier 1057e99520c7SMarshall Clow#endif 1058e99520c7SMarshall Clow 10593e519524SHoward Hinnant// tie 10603e519524SHoward Hinnant 10613e519524SHoward Hinnanttemplate <class ..._Tp> 10620d1560e1SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 10633e519524SHoward Hinnanttuple<_Tp&...> 10648a9ee148SHoward Hinnanttie(_Tp&... __t) _NOEXCEPT 10653e519524SHoward Hinnant{ 10663e519524SHoward Hinnant return tuple<_Tp&...>(__t...); 10673e519524SHoward Hinnant} 10683e519524SHoward Hinnant 10693e519524SHoward Hinnanttemplate <class _Up> 10703e519524SHoward Hinnantstruct __ignore_t 10713e519524SHoward Hinnant{ 10723e519524SHoward Hinnant template <class _Tp> 10739af60c4aSEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 10743e519524SHoward Hinnant const __ignore_t& operator=(_Tp&&) const {return *this;} 10753e519524SHoward Hinnant}; 10763e519524SHoward Hinnant 10779af60c4aSEric Fiseliernamespace { 107840a01d53SMarshall Clow _LIBCPP_INLINE_VAR constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); 10799af60c4aSEric Fiselier} 10803e519524SHoward Hinnant 10813e519524SHoward Hinnanttemplate <class... _Tp> 108275eff748SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 1083*bb9ca6d0SLouis Dionnetuple<typename __unwrap_ref_decay<_Tp>::type...> 10843e519524SHoward Hinnantmake_tuple(_Tp&&... __t) 10853e519524SHoward Hinnant{ 1086*bb9ca6d0SLouis Dionne return tuple<typename __unwrap_ref_decay<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...); 10873e519524SHoward Hinnant} 10883e519524SHoward Hinnant 10891102fbbdSHoward Hinnanttemplate <class... _Tp> 109075eff748SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 109175eff748SMarshall Clowtuple<_Tp&&...> 10928a9ee148SHoward Hinnantforward_as_tuple(_Tp&&... __t) _NOEXCEPT 10931102fbbdSHoward Hinnant{ 1094ce48a113SHoward Hinnant return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...); 10951102fbbdSHoward Hinnant} 10961102fbbdSHoward Hinnant 1097c003db1fSHoward Hinnanttemplate <size_t _Ip> 10983e519524SHoward Hinnantstruct __tuple_equal 10993e519524SHoward Hinnant{ 11003e519524SHoward Hinnant template <class _Tp, class _Up> 110175eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 11023e519524SHoward Hinnant bool operator()(const _Tp& __x, const _Up& __y) 11033e519524SHoward Hinnant { 1104f9af6140SMarshall Clow return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y); 11053e519524SHoward Hinnant } 11063e519524SHoward Hinnant}; 11073e519524SHoward Hinnant 11083e519524SHoward Hinnanttemplate <> 11093e519524SHoward Hinnantstruct __tuple_equal<0> 11103e519524SHoward Hinnant{ 11113e519524SHoward Hinnant template <class _Tp, class _Up> 111275eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 11133e519524SHoward Hinnant bool operator()(const _Tp&, const _Up&) 11143e519524SHoward Hinnant { 11153e519524SHoward Hinnant return true; 11163e519524SHoward Hinnant } 11173e519524SHoward Hinnant}; 11183e519524SHoward Hinnant 11193e519524SHoward Hinnanttemplate <class ..._Tp, class ..._Up> 112075eff748SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 11213e519524SHoward Hinnantbool 11223e519524SHoward Hinnantoperator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) 11233e519524SHoward Hinnant{ 11243e519524SHoward Hinnant return __tuple_equal<sizeof...(_Tp)>()(__x, __y); 11253e519524SHoward Hinnant} 11263e519524SHoward Hinnant 11273e519524SHoward Hinnanttemplate <class ..._Tp, class ..._Up> 112875eff748SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 11293e519524SHoward Hinnantbool 11303e519524SHoward Hinnantoperator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) 11313e519524SHoward Hinnant{ 11323e519524SHoward Hinnant return !(__x == __y); 11333e519524SHoward Hinnant} 11343e519524SHoward Hinnant 1135c003db1fSHoward Hinnanttemplate <size_t _Ip> 11363e519524SHoward Hinnantstruct __tuple_less 11373e519524SHoward Hinnant{ 11383e519524SHoward Hinnant template <class _Tp, class _Up> 113975eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 11403e519524SHoward Hinnant bool operator()(const _Tp& __x, const _Up& __y) 11413e519524SHoward Hinnant { 114253afae49SDuncan P. N. Exon Smith const size_t __idx = tuple_size<_Tp>::value - _Ip; 114353afae49SDuncan P. N. Exon Smith if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y)) 114453afae49SDuncan P. N. Exon Smith return true; 114553afae49SDuncan P. N. Exon Smith if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x)) 114653afae49SDuncan P. N. Exon Smith return false; 114753afae49SDuncan P. N. Exon Smith return __tuple_less<_Ip-1>()(__x, __y); 11483e519524SHoward Hinnant } 11493e519524SHoward Hinnant}; 11503e519524SHoward Hinnant 11513e519524SHoward Hinnanttemplate <> 11523e519524SHoward Hinnantstruct __tuple_less<0> 11533e519524SHoward Hinnant{ 11543e519524SHoward Hinnant template <class _Tp, class _Up> 115575eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 11563e519524SHoward Hinnant bool operator()(const _Tp&, const _Up&) 11573e519524SHoward Hinnant { 11583e519524SHoward Hinnant return false; 11593e519524SHoward Hinnant } 11603e519524SHoward Hinnant}; 11613e519524SHoward Hinnant 11623e519524SHoward Hinnanttemplate <class ..._Tp, class ..._Up> 116375eff748SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 11643e519524SHoward Hinnantbool 11653e519524SHoward Hinnantoperator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) 11663e519524SHoward Hinnant{ 11673e519524SHoward Hinnant return __tuple_less<sizeof...(_Tp)>()(__x, __y); 11683e519524SHoward Hinnant} 11693e519524SHoward Hinnant 11703e519524SHoward Hinnanttemplate <class ..._Tp, class ..._Up> 117175eff748SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 11723e519524SHoward Hinnantbool 11733e519524SHoward Hinnantoperator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) 11743e519524SHoward Hinnant{ 11753e519524SHoward Hinnant return __y < __x; 11763e519524SHoward Hinnant} 11773e519524SHoward Hinnant 11783e519524SHoward Hinnanttemplate <class ..._Tp, class ..._Up> 117975eff748SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 11803e519524SHoward Hinnantbool 11813e519524SHoward Hinnantoperator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) 11823e519524SHoward Hinnant{ 11833e519524SHoward Hinnant return !(__x < __y); 11843e519524SHoward Hinnant} 11853e519524SHoward Hinnant 11863e519524SHoward Hinnanttemplate <class ..._Tp, class ..._Up> 118775eff748SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 11883e519524SHoward Hinnantbool 11893e519524SHoward Hinnantoperator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) 11903e519524SHoward Hinnant{ 11913e519524SHoward Hinnant return !(__y < __x); 11923e519524SHoward Hinnant} 11933e519524SHoward Hinnant 11943e519524SHoward Hinnant// tuple_cat 11953e519524SHoward Hinnant 11967f64810bSHoward Hinnanttemplate <class _Tp, class _Up> struct __tuple_cat_type; 11977f64810bSHoward Hinnant 11987f64810bSHoward Hinnanttemplate <class ..._Ttypes, class ..._Utypes> 11997f64810bSHoward Hinnantstruct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> > 12003e519524SHoward Hinnant{ 12017f64810bSHoward Hinnant typedef tuple<_Ttypes..., _Utypes...> type; 12027f64810bSHoward Hinnant}; 12037f64810bSHoward Hinnant 12047f64810bSHoward Hinnanttemplate <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples> 12057f64810bSHoward Hinnantstruct __tuple_cat_return_1 12067f64810bSHoward Hinnant{ 12077f64810bSHoward Hinnant}; 12087f64810bSHoward Hinnant 12097f64810bSHoward Hinnanttemplate <class ..._Types, class _Tuple0> 12107f64810bSHoward Hinnantstruct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0> 12117f64810bSHoward Hinnant{ 12127f64810bSHoward Hinnant typedef typename __tuple_cat_type<tuple<_Types...>, 12137f64810bSHoward Hinnant typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type 12147f64810bSHoward Hinnant type; 12157f64810bSHoward Hinnant}; 12167f64810bSHoward Hinnant 12177f64810bSHoward Hinnanttemplate <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples> 12187f64810bSHoward Hinnantstruct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...> 12197f64810bSHoward Hinnant : public __tuple_cat_return_1< 12207f64810bSHoward Hinnant typename __tuple_cat_type< 12217f64810bSHoward Hinnant tuple<_Types...>, 12227f64810bSHoward Hinnant typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type 12237f64810bSHoward Hinnant >::type, 12247f64810bSHoward Hinnant __tuple_like<typename remove_reference<_Tuple1>::type>::value, 12257f64810bSHoward Hinnant _Tuple1, _Tuples...> 12267f64810bSHoward Hinnant{ 12277f64810bSHoward Hinnant}; 12287f64810bSHoward Hinnant 12297f64810bSHoward Hinnanttemplate <class ..._Tuples> struct __tuple_cat_return; 12307f64810bSHoward Hinnant 12317f64810bSHoward Hinnanttemplate <class _Tuple0, class ..._Tuples> 12327f64810bSHoward Hinnantstruct __tuple_cat_return<_Tuple0, _Tuples...> 12337f64810bSHoward Hinnant : public __tuple_cat_return_1<tuple<>, 12347f64810bSHoward Hinnant __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0, 12357f64810bSHoward Hinnant _Tuples...> 12367f64810bSHoward Hinnant{ 12377f64810bSHoward Hinnant}; 12387f64810bSHoward Hinnant 12397f64810bSHoward Hinnanttemplate <> 12407f64810bSHoward Hinnantstruct __tuple_cat_return<> 12417f64810bSHoward Hinnant{ 12427f64810bSHoward Hinnant typedef tuple<> type; 12437f64810bSHoward Hinnant}; 12447f64810bSHoward Hinnant 124575eff748SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 12467f64810bSHoward Hinnanttuple<> 12477f64810bSHoward Hinnanttuple_cat() 12487f64810bSHoward Hinnant{ 12497f64810bSHoward Hinnant return tuple<>(); 12503e519524SHoward Hinnant} 12513e519524SHoward Hinnant 1252c003db1fSHoward Hinnanttemplate <class _Rp, class _Indices, class _Tuple0, class ..._Tuples> 1253ba31cbdbSHoward Hinnantstruct __tuple_cat_return_ref_imp; 12543e519524SHoward Hinnant 1255ba31cbdbSHoward Hinnanttemplate <class ..._Types, size_t ..._I0, class _Tuple0> 1256ba31cbdbSHoward Hinnantstruct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> 12573e519524SHoward Hinnant{ 12587f64810bSHoward Hinnant typedef typename remove_reference<_Tuple0>::type _T0; 1259ba31cbdbSHoward Hinnant typedef tuple<_Types..., typename __apply_cv<_Tuple0, 1260ba31cbdbSHoward Hinnant typename tuple_element<_I0, _T0>::type>::type&&...> type; 1261ba31cbdbSHoward Hinnant}; 1262ba31cbdbSHoward Hinnant 1263ba31cbdbSHoward Hinnanttemplate <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples> 1264ba31cbdbSHoward Hinnantstruct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, 1265ba31cbdbSHoward Hinnant _Tuple0, _Tuple1, _Tuples...> 1266ba31cbdbSHoward Hinnant : public __tuple_cat_return_ref_imp< 1267ba31cbdbSHoward Hinnant tuple<_Types..., typename __apply_cv<_Tuple0, 1268ba31cbdbSHoward Hinnant typename tuple_element<_I0, 1269ba31cbdbSHoward Hinnant typename remove_reference<_Tuple0>::type>::type>::type&&...>, 1270ba31cbdbSHoward Hinnant typename __make_tuple_indices<tuple_size<typename 1271ba31cbdbSHoward Hinnant remove_reference<_Tuple1>::type>::value>::type, 1272ba31cbdbSHoward Hinnant _Tuple1, _Tuples...> 1273ba31cbdbSHoward Hinnant{ 1274ba31cbdbSHoward Hinnant}; 1275ba31cbdbSHoward Hinnant 1276ba31cbdbSHoward Hinnanttemplate <class _Tuple0, class ..._Tuples> 1277ba31cbdbSHoward Hinnantstruct __tuple_cat_return_ref 1278ba31cbdbSHoward Hinnant : public __tuple_cat_return_ref_imp<tuple<>, 1279ba31cbdbSHoward Hinnant typename __make_tuple_indices< 1280ba31cbdbSHoward Hinnant tuple_size<typename remove_reference<_Tuple0>::type>::value 1281ba31cbdbSHoward Hinnant >::type, _Tuple0, _Tuples...> 1282ba31cbdbSHoward Hinnant{ 1283ba31cbdbSHoward Hinnant}; 1284ba31cbdbSHoward Hinnant 1285ba31cbdbSHoward Hinnanttemplate <class _Types, class _I0, class _J0> 1286ba31cbdbSHoward Hinnantstruct __tuple_cat; 1287ba31cbdbSHoward Hinnant 1288ba31cbdbSHoward Hinnanttemplate <class ..._Types, size_t ..._I0, size_t ..._J0> 1289ba31cbdbSHoward Hinnantstruct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> > 1290ba31cbdbSHoward Hinnant{ 1291ba31cbdbSHoward Hinnant template <class _Tuple0> 129275eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 1293ba31cbdbSHoward Hinnant typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type 1294ba31cbdbSHoward Hinnant operator()(tuple<_Types...> __t, _Tuple0&& __t0) 1295ba31cbdbSHoward Hinnant { 1296f9af6140SMarshall Clow return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))..., 1297f9af6140SMarshall Clow _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...); 12983e519524SHoward Hinnant } 12993e519524SHoward Hinnant 13007f64810bSHoward Hinnant template <class _Tuple0, class _Tuple1, class ..._Tuples> 130175eff748SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 1302ba31cbdbSHoward Hinnant typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type 1303ba31cbdbSHoward Hinnant operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls) 13043e519524SHoward Hinnant { 1305ba31cbdbSHoward Hinnant typedef typename remove_reference<_Tuple0>::type _T0; 1306ba31cbdbSHoward Hinnant typedef typename remove_reference<_Tuple1>::type _T1; 1307ba31cbdbSHoward Hinnant return __tuple_cat< 1308ba31cbdbSHoward Hinnant tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>, 1309ba31cbdbSHoward Hinnant typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type, 1310ba31cbdbSHoward Hinnant typename __make_tuple_indices<tuple_size<_T1>::value>::type>() 1311de9320aaSMarshall Clow (forward_as_tuple( 1312f9af6140SMarshall Clow _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))..., 1313f9af6140SMarshall Clow _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))... 1314ba31cbdbSHoward Hinnant ), 1315ce48a113SHoward Hinnant _VSTD::forward<_Tuple1>(__t1), 1316ce48a113SHoward Hinnant _VSTD::forward<_Tuples>(__tpls)...); 1317ba31cbdbSHoward Hinnant } 1318ba31cbdbSHoward Hinnant}; 1319ba31cbdbSHoward Hinnant 1320ba31cbdbSHoward Hinnanttemplate <class _Tuple0, class... _Tuples> 132175eff748SMarshall Clowinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 1322ba31cbdbSHoward Hinnanttypename __tuple_cat_return<_Tuple0, _Tuples...>::type 1323ba31cbdbSHoward Hinnanttuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) 1324ba31cbdbSHoward Hinnant{ 1325ba31cbdbSHoward Hinnant typedef typename remove_reference<_Tuple0>::type _T0; 1326ba31cbdbSHoward Hinnant return __tuple_cat<tuple<>, __tuple_indices<>, 1327ba31cbdbSHoward Hinnant typename __make_tuple_indices<tuple_size<_T0>::value>::type>() 1328ce48a113SHoward Hinnant (tuple<>(), _VSTD::forward<_Tuple0>(__t0), 1329ce48a113SHoward Hinnant _VSTD::forward<_Tuples>(__tpls)...); 13303e519524SHoward Hinnant} 13313e519524SHoward Hinnant 13323e519524SHoward Hinnanttemplate <class ..._Tp, class _Alloc> 1333e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc> 13343e519524SHoward Hinnant : true_type {}; 13353e519524SHoward Hinnant 13363e519524SHoward Hinnanttemplate <class _T1, class _T2> 13373e519524SHoward Hinnanttemplate <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2> 13383e519524SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 13393e519524SHoward Hinnantpair<_T1, _T2>::pair(piecewise_construct_t, 13403e519524SHoward Hinnant tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args, 13413e519524SHoward Hinnant __tuple_indices<_I1...>, __tuple_indices<_I2...>) 1342f9af6140SMarshall Clow : first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...), 1343f9af6140SMarshall Clow second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...) 13443e519524SHoward Hinnant{ 13453e519524SHoward Hinnant} 13463e519524SHoward Hinnant 134703e29a29SEric Fiselier#if _LIBCPP_STD_VER > 14 134803e29a29SEric Fiseliertemplate <class _Tp> 134940a01d53SMarshall Clow_LIBCPP_INLINE_VAR constexpr size_t tuple_size_v = tuple_size<_Tp>::value; 135003e29a29SEric Fiselier 135103e29a29SEric Fiselier#define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; } 135203e29a29SEric Fiselier 135303e29a29SEric Fiseliertemplate <class _Fn, class _Tuple, size_t ..._Id> 135403e29a29SEric Fiselierinline _LIBCPP_INLINE_VISIBILITY 135503e29a29SEric Fiselierconstexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t, 135603e29a29SEric Fiselier __tuple_indices<_Id...>) 135703e29a29SEric Fiselier_LIBCPP_NOEXCEPT_RETURN( 135803e29a29SEric Fiselier _VSTD::__invoke_constexpr( 135903e29a29SEric Fiselier _VSTD::forward<_Fn>(__f), 136003e29a29SEric Fiselier _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...) 136103e29a29SEric Fiselier) 136203e29a29SEric Fiselier 136303e29a29SEric Fiseliertemplate <class _Fn, class _Tuple> 136403e29a29SEric Fiselierinline _LIBCPP_INLINE_VISIBILITY 136503e29a29SEric Fiselierconstexpr decltype(auto) apply(_Fn && __f, _Tuple && __t) 136603e29a29SEric Fiselier_LIBCPP_NOEXCEPT_RETURN( 136703e29a29SEric Fiselier _VSTD::__apply_tuple_impl( 136803e29a29SEric Fiselier _VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t), 1369655c4695SMarshall Clow typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{}) 137003e29a29SEric Fiselier) 137103e29a29SEric Fiselier 137203e29a29SEric Fiseliertemplate <class _Tp, class _Tuple, size_t... _Idx> 137303e29a29SEric Fiselierinline _LIBCPP_INLINE_VISIBILITY 137403e29a29SEric Fiselierconstexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>) 137503e29a29SEric Fiselier_LIBCPP_NOEXCEPT_RETURN( 137603e29a29SEric Fiselier _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...) 137703e29a29SEric Fiselier) 137803e29a29SEric Fiselier 137903e29a29SEric Fiseliertemplate <class _Tp, class _Tuple> 138003e29a29SEric Fiselierinline _LIBCPP_INLINE_VISIBILITY 138103e29a29SEric Fiselierconstexpr _Tp make_from_tuple(_Tuple&& __t) 138203e29a29SEric Fiselier_LIBCPP_NOEXCEPT_RETURN( 138303e29a29SEric Fiselier _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t), 1384655c4695SMarshall Clow typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{}) 138503e29a29SEric Fiselier) 138603e29a29SEric Fiselier 138703e29a29SEric Fiselier#undef _LIBCPP_NOEXCEPT_RETURN 138803e29a29SEric Fiselier 138903e29a29SEric Fiselier#endif // _LIBCPP_STD_VER > 14 139003e29a29SEric Fiselier 139129870871SEric Fiselier#endif // !defined(_LIBCPP_CXX03_LANG) 139229870871SEric Fiselier 13933e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD 13943e519524SHoward Hinnant 13953e519524SHoward Hinnant#endif // _LIBCPP_TUPLE 1396