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