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