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 |
Howard Hinnant | 0e1493e | 2010-12-11 20:47:50 +0000 | [diff] [blame] | 79 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 80 | // 20.4.1.4, tuple helper classes: |
| 81 | template <class T> class tuple_size; // undefined |
| 82 | template <class... T> class tuple_size<tuple<T...>>; |
| 83 | template <intsize_t I, class T> class tuple_element; // undefined |
| 84 | template <intsize_t I, class... T> class tuple_element<I, tuple<T...>>; |
Marshall Clow | 50fe0c7 | 2014-03-03 06:18:11 +0000 | [diff] [blame] | 85 | template <size_t _Ip, class ..._Tp> |
| 86 | using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // C++14 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 87 | |
| 88 | // 20.4.1.5, element access: |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 89 | template <intsize_t I, class... T> |
| 90 | typename tuple_element<I, tuple<T...>>::type& |
Marshall Clow | 8fc4f5a | 2013-07-17 18:25:36 +0000 | [diff] [blame] | 91 | get(tuple<T...>&) noexcept; // constexpr in C++14 |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 92 | template <intsize_t I, class... T> |
Marshall Clow | 50fe0c7 | 2014-03-03 06:18:11 +0000 | [diff] [blame] | 93 | typename const tuple_element<I, tuple<T...>>::type & |
Marshall Clow | 8fc4f5a | 2013-07-17 18:25:36 +0000 | [diff] [blame] | 94 | get(const tuple<T...>&) noexcept; // constexpr in C++14 |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 95 | template <intsize_t I, class... T> |
| 96 | typename tuple_element<I, tuple<T...>>::type&& |
Marshall Clow | 8fc4f5a | 2013-07-17 18:25:36 +0000 | [diff] [blame] | 97 | get(tuple<T...>&&) noexcept; // constexpr in C++14 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 98 | |
Marshall Clow | e8029e5 | 2013-07-13 02:54:05 +0000 | [diff] [blame] | 99 | template <class T1, class... T> |
| 100 | constexpr T1& get(tuple<T...>&) noexcept; // C++14 |
| 101 | template <class T1, class... T> |
| 102 | constexpr T1 const& get(const tuple<T...>&) noexcept; // C++14 |
| 103 | template <class T1, class... T> |
| 104 | constexpr T1&& get(tuple<T...>&&) noexcept; // C++14 |
| 105 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 106 | // 20.4.1.6, relational operators: |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 107 | template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 |
| 108 | template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 |
| 109 | template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 |
| 110 | template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 |
| 111 | template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 |
| 112 | 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] | 113 | |
| 114 | template <class... Types, class Alloc> |
| 115 | struct uses_allocator<tuple<Types...>, Alloc>; |
| 116 | |
| 117 | template <class... Types> |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 118 | void |
| 119 | swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y))); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 120 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 121 | } // std |
| 122 | |
| 123 | */ |
| 124 | |
| 125 | #include <__config> |
| 126 | #include <__tuple> |
| 127 | #include <cstddef> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 128 | #include <type_traits> |
Howard Hinnant | 6cc99fa | 2011-12-19 17:58:44 +0000 | [diff] [blame] | 129 | #include <__functional_base> |
| 130 | #include <utility> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 131 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 132 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 133 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 134 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 135 | |
| 136 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 137 | |
| 138 | #ifndef _LIBCPP_HAS_NO_VARIADICS |
| 139 | |
| 140 | // tuple_size |
| 141 | |
| 142 | template <class ..._Tp> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 143 | class _LIBCPP_TYPE_VIS_ONLY tuple_size<tuple<_Tp...> > |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 144 | : public integral_constant<size_t, sizeof...(_Tp)> |
| 145 | { |
| 146 | }; |
| 147 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 148 | // tuple_element |
| 149 | |
| 150 | template <size_t _Ip, class ..._Tp> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 151 | class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> > |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 152 | { |
| 153 | public: |
Howard Hinnant | f83417b | 2011-01-24 16:07:25 +0000 | [diff] [blame] | 154 | typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 155 | }; |
| 156 | |
Marshall Clow | 50fe0c7 | 2014-03-03 06:18:11 +0000 | [diff] [blame] | 157 | #if _LIBCPP_STD_VER > 11 |
| 158 | template <size_t _Ip, class ..._Tp> |
| 159 | using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; |
| 160 | #endif |
| 161 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 162 | // __tuple_leaf |
| 163 | |
Howard Hinnant | d4cf215 | 2011-12-11 20:31:33 +0000 | [diff] [blame] | 164 | template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value |
| 165 | #if __has_feature(is_final) |
| 166 | && !__is_final(_Hp) |
| 167 | #endif |
| 168 | > |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 169 | class __tuple_leaf; |
| 170 | |
| 171 | template <size_t _Ip, class _Hp, bool _Ep> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 172 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 173 | 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] | 174 | _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 175 | { |
| 176 | swap(__x.get(), __y.get()); |
| 177 | } |
| 178 | |
| 179 | template <size_t _Ip, class _Hp, bool> |
| 180 | class __tuple_leaf |
| 181 | { |
| 182 | _Hp value; |
| 183 | |
| 184 | __tuple_leaf& operator=(const __tuple_leaf&); |
| 185 | public: |
Howard Hinnant | 4eebfc3 | 2012-07-06 20:50:27 +0000 | [diff] [blame] | 186 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf() |
| 187 | _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value() |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 188 | {static_assert(!is_reference<_Hp>::value, |
| 189 | "Attempted to default construct a reference element in a tuple");} |
| 190 | |
| 191 | template <class _Alloc> |
| 192 | _LIBCPP_INLINE_VISIBILITY |
| 193 | __tuple_leaf(integral_constant<int, 0>, const _Alloc&) |
| 194 | : value() |
| 195 | {static_assert(!is_reference<_Hp>::value, |
| 196 | "Attempted to default construct a reference element in a tuple");} |
| 197 | |
| 198 | template <class _Alloc> |
| 199 | _LIBCPP_INLINE_VISIBILITY |
| 200 | __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a) |
| 201 | : value(allocator_arg_t(), __a) |
| 202 | {static_assert(!is_reference<_Hp>::value, |
| 203 | "Attempted to default construct a reference element in a tuple");} |
| 204 | |
| 205 | template <class _Alloc> |
| 206 | _LIBCPP_INLINE_VISIBILITY |
| 207 | __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a) |
| 208 | : value(__a) |
| 209 | {static_assert(!is_reference<_Hp>::value, |
| 210 | "Attempted to default construct a reference element in a tuple");} |
| 211 | |
Howard Hinnant | e049cc5 | 2010-09-27 17:54:17 +0000 | [diff] [blame] | 212 | template <class _Tp, |
| 213 | class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 214 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 215 | explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 216 | : value(_VSTD::forward<_Tp>(__t)) |
Howard Hinnant | e049cc5 | 2010-09-27 17:54:17 +0000 | [diff] [blame] | 217 | {static_assert(!is_reference<_Hp>::value || |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 218 | (is_lvalue_reference<_Hp>::value && |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 219 | (is_lvalue_reference<_Tp>::value || |
| 220 | is_same<typename remove_reference<_Tp>::type, |
| 221 | reference_wrapper< |
| 222 | typename remove_reference<_Hp>::type |
| 223 | > |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 224 | >::value)) || |
Howard Hinnant | e049cc5 | 2010-09-27 17:54:17 +0000 | [diff] [blame] | 225 | (is_rvalue_reference<_Hp>::value && |
| 226 | !is_lvalue_reference<_Tp>::value), |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 227 | "Attempted to construct a reference element in a tuple with an rvalue");} |
| 228 | |
| 229 | template <class _Tp, class _Alloc> |
| 230 | _LIBCPP_INLINE_VISIBILITY |
| 231 | explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 232 | : value(_VSTD::forward<_Tp>(__t)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 233 | {static_assert(!is_lvalue_reference<_Hp>::value || |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 234 | (is_lvalue_reference<_Hp>::value && |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 235 | (is_lvalue_reference<_Tp>::value || |
| 236 | is_same<typename remove_reference<_Tp>::type, |
| 237 | reference_wrapper< |
| 238 | typename remove_reference<_Hp>::type |
| 239 | > |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 240 | >::value)), |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 241 | "Attempted to construct a reference element in a tuple with an rvalue");} |
| 242 | |
| 243 | template <class _Tp, class _Alloc> |
| 244 | _LIBCPP_INLINE_VISIBILITY |
| 245 | explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 246 | : value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 247 | {static_assert(!is_lvalue_reference<_Hp>::value || |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 248 | (is_lvalue_reference<_Hp>::value && |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 249 | (is_lvalue_reference<_Tp>::value || |
| 250 | is_same<typename remove_reference<_Tp>::type, |
| 251 | reference_wrapper< |
| 252 | typename remove_reference<_Hp>::type |
| 253 | > |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 254 | >::value)), |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 255 | "Attempted to construct a reference element in a tuple with an rvalue");} |
| 256 | |
| 257 | template <class _Tp, class _Alloc> |
| 258 | _LIBCPP_INLINE_VISIBILITY |
| 259 | explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 260 | : value(_VSTD::forward<_Tp>(__t), __a) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 261 | {static_assert(!is_lvalue_reference<_Hp>::value || |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 262 | (is_lvalue_reference<_Hp>::value && |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 263 | (is_lvalue_reference<_Tp>::value || |
| 264 | is_same<typename remove_reference<_Tp>::type, |
| 265 | reference_wrapper< |
| 266 | typename remove_reference<_Hp>::type |
| 267 | > |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 268 | >::value)), |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 269 | "Attempted to construct a reference element in a tuple with an rvalue");} |
| 270 | |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 271 | _LIBCPP_INLINE_VISIBILITY |
| 272 | _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 273 | __tuple_leaf(const __tuple_leaf& __t) _NOEXCEPT_(is_nothrow_copy_constructible<_Hp>::value) |
Howard Hinnant | e049cc5 | 2010-09-27 17:54:17 +0000 | [diff] [blame] | 274 | : value(__t.get()) |
| 275 | {static_assert(!is_rvalue_reference<_Hp>::value, "Can not copy a tuple with rvalue reference member");} |
| 276 | |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 277 | _LIBCPP_INLINE_VISIBILITY |
| 278 | _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 279 | __tuple_leaf(__tuple_leaf&& __t) _NOEXCEPT_(is_nothrow_move_constructible<_Hp>::value) |
Howard Hinnant | 3de5086 | 2013-11-06 17:45:43 +0000 | [diff] [blame] | 280 | : value(_VSTD::forward<_Hp>(__t.get())) |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 281 | {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 282 | |
| 283 | template <class _Tp> |
| 284 | _LIBCPP_INLINE_VISIBILITY |
| 285 | __tuple_leaf& |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 286 | operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 287 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 288 | value = _VSTD::forward<_Tp>(__t); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 289 | return *this; |
| 290 | } |
| 291 | |
| 292 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 293 | int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 294 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 295 | _VSTD::swap(*this, __t); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 296 | return 0; |
| 297 | } |
| 298 | |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 299 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return value;} |
| 300 | _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] | 301 | }; |
| 302 | |
| 303 | template <size_t _Ip, class _Hp> |
| 304 | class __tuple_leaf<_Ip, _Hp, true> |
| 305 | : private _Hp |
| 306 | { |
| 307 | |
| 308 | __tuple_leaf& operator=(const __tuple_leaf&); |
| 309 | public: |
Howard Hinnant | 4eebfc3 | 2012-07-06 20:50:27 +0000 | [diff] [blame] | 310 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf() |
| 311 | _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 312 | |
| 313 | template <class _Alloc> |
| 314 | _LIBCPP_INLINE_VISIBILITY |
| 315 | __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {} |
| 316 | |
| 317 | template <class _Alloc> |
| 318 | _LIBCPP_INLINE_VISIBILITY |
| 319 | __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a) |
| 320 | : _Hp(allocator_arg_t(), __a) {} |
| 321 | |
| 322 | template <class _Alloc> |
| 323 | _LIBCPP_INLINE_VISIBILITY |
| 324 | __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a) |
| 325 | : _Hp(__a) {} |
| 326 | |
Howard Hinnant | e049cc5 | 2010-09-27 17:54:17 +0000 | [diff] [blame] | 327 | template <class _Tp, |
| 328 | class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 329 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 330 | explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value)) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 331 | : _Hp(_VSTD::forward<_Tp>(__t)) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 332 | |
| 333 | template <class _Tp, class _Alloc> |
| 334 | _LIBCPP_INLINE_VISIBILITY |
| 335 | explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 336 | : _Hp(_VSTD::forward<_Tp>(__t)) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 337 | |
| 338 | template <class _Tp, class _Alloc> |
| 339 | _LIBCPP_INLINE_VISIBILITY |
| 340 | explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 341 | : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 342 | |
| 343 | template <class _Tp, class _Alloc> |
| 344 | _LIBCPP_INLINE_VISIBILITY |
| 345 | explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 346 | : _Hp(_VSTD::forward<_Tp>(__t), __a) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 347 | |
| 348 | template <class _Tp> |
| 349 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 350 | __tuple_leaf& |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 351 | operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 352 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 353 | _Hp::operator=(_VSTD::forward<_Tp>(__t)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 354 | return *this; |
| 355 | } |
| 356 | |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 357 | _LIBCPP_INLINE_VISIBILITY |
| 358 | int |
| 359 | swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 360 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 361 | _VSTD::swap(*this, __t); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 362 | return 0; |
| 363 | } |
| 364 | |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 365 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);} |
| 366 | _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] | 367 | }; |
| 368 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 369 | template <class ..._Tp> |
| 370 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 371 | void __swallow(_Tp&&...) _NOEXCEPT {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 372 | |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 373 | template <bool ...> struct __all; |
| 374 | |
| 375 | template <> |
| 376 | struct __all<> |
| 377 | { |
| 378 | static const bool value = true; |
| 379 | }; |
| 380 | |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 381 | template <bool _B0, bool ... _Bp> |
| 382 | struct __all<_B0, _Bp...> |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 383 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 384 | static const bool value = _B0 && __all<_Bp...>::value; |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 385 | }; |
| 386 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 387 | // __tuple_impl |
| 388 | |
| 389 | template<class _Indx, class ..._Tp> struct __tuple_impl; |
| 390 | |
| 391 | template<size_t ..._Indx, class ..._Tp> |
| 392 | struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...> |
| 393 | : public __tuple_leaf<_Indx, _Tp>... |
| 394 | { |
Howard Hinnant | 5394c1e | 2012-07-06 20:39:45 +0000 | [diff] [blame] | 395 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 4eebfc3 | 2012-07-06 20:50:27 +0000 | [diff] [blame] | 396 | _LIBCPP_CONSTEXPR __tuple_impl() |
| 397 | _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {} |
Howard Hinnant | 5394c1e | 2012-07-06 20:39:45 +0000 | [diff] [blame] | 398 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 399 | template <size_t ..._Uf, class ..._Tf, |
| 400 | size_t ..._Ul, class ..._Tl, class ..._Up> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 401 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 402 | explicit |
| 403 | __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>, |
| 404 | __tuple_indices<_Ul...>, __tuple_types<_Tl...>, |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 405 | _Up&&... __u) |
| 406 | _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value && |
| 407 | __all<is_nothrow_default_constructible<_Tl>::value...>::value)) : |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 408 | __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))..., |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 409 | __tuple_leaf<_Ul, _Tl>()... |
| 410 | {} |
| 411 | |
| 412 | template <class _Alloc, size_t ..._Uf, class ..._Tf, |
| 413 | size_t ..._Ul, class ..._Tl, class ..._Up> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 414 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 415 | explicit |
| 416 | __tuple_impl(allocator_arg_t, const _Alloc& __a, |
| 417 | __tuple_indices<_Uf...>, __tuple_types<_Tf...>, |
| 418 | __tuple_indices<_Ul...>, __tuple_types<_Tl...>, |
| 419 | _Up&&... __u) : |
| 420 | __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a, |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 421 | _VSTD::forward<_Up>(__u))..., |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 422 | __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)... |
| 423 | {} |
| 424 | |
| 425 | template <class _Tuple, |
| 426 | class = typename enable_if |
| 427 | < |
Howard Hinnant | 9932489 | 2013-04-14 00:01:13 +0000 | [diff] [blame] | 428 | __tuple_constructible<_Tuple, tuple<_Tp...> >::value |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 429 | >::type |
| 430 | > |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 431 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 432 | __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx, |
| 433 | typename __make_tuple_types<_Tuple>::type>::type>::value...>::value)) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 434 | : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx, |
| 435 | typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))... |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 436 | {} |
| 437 | |
| 438 | template <class _Alloc, class _Tuple, |
| 439 | class = typename enable_if |
| 440 | < |
Howard Hinnant | f83417b | 2011-01-24 16:07:25 +0000 | [diff] [blame] | 441 | __tuple_convertible<_Tuple, tuple<_Tp...> >::value |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 442 | >::type |
| 443 | > |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 444 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 445 | __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t) |
| 446 | : __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] | 447 | typename __make_tuple_types<_Tuple>::type>::type>(), __a, |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 448 | _VSTD::forward<typename tuple_element<_Indx, |
| 449 | typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))... |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 450 | {} |
| 451 | |
| 452 | template <class _Tuple> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 453 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 454 | typename enable_if |
| 455 | < |
Howard Hinnant | f83417b | 2011-01-24 16:07:25 +0000 | [diff] [blame] | 456 | __tuple_assignable<_Tuple, tuple<_Tp...> >::value, |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 457 | __tuple_impl& |
| 458 | >::type |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 459 | operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx, |
| 460 | typename __make_tuple_types<_Tuple>::type>::type>::value...>::value)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 461 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 462 | __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx, |
| 463 | typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 464 | return *this; |
| 465 | } |
| 466 | |
Howard Hinnant | 3de5086 | 2013-11-06 17:45:43 +0000 | [diff] [blame] | 467 | __tuple_impl(const __tuple_impl&) = default; |
| 468 | __tuple_impl(__tuple_impl&&) = default; |
| 469 | |
| 470 | _LIBCPP_INLINE_VISIBILITY |
| 471 | __tuple_impl& |
| 472 | operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value)) |
| 473 | { |
| 474 | __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...); |
| 475 | return *this; |
| 476 | } |
| 477 | |
| 478 | _LIBCPP_INLINE_VISIBILITY |
| 479 | __tuple_impl& |
| 480 | operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value)) |
| 481 | { |
| 482 | __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...); |
| 483 | return *this; |
| 484 | } |
Howard Hinnant | 2848444 | 2012-02-15 20:13:52 +0000 | [diff] [blame] | 485 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 486 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 487 | void swap(__tuple_impl& __t) |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 488 | _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 489 | { |
| 490 | __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...); |
| 491 | } |
| 492 | }; |
| 493 | |
| 494 | template <class ..._Tp> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 495 | class _LIBCPP_TYPE_VIS_ONLY tuple |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 496 | { |
| 497 | typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base; |
| 498 | |
| 499 | base base_; |
| 500 | |
Marshall Clow | 8fc4f5a | 2013-07-17 18:25:36 +0000 | [diff] [blame] | 501 | template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 502 | typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT; |
Marshall Clow | 8fc4f5a | 2013-07-17 18:25:36 +0000 | [diff] [blame] | 503 | template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 504 | 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] | 505 | template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 506 | typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 507 | public: |
| 508 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 509 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 4eebfc3 | 2012-07-06 20:50:27 +0000 | [diff] [blame] | 510 | _LIBCPP_CONSTEXPR tuple() |
| 511 | _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {} |
Howard Hinnant | 5394c1e | 2012-07-06 20:39:45 +0000 | [diff] [blame] | 512 | |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 513 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 514 | explicit 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] | 515 | : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(), |
| 516 | typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), |
| 517 | typename __make_tuple_indices<0>::type(), |
| 518 | typename __make_tuple_types<tuple, 0>::type(), |
| 519 | __t... |
| 520 | ) {} |
| 521 | |
| 522 | template <class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 523 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 524 | tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t) |
| 525 | : base_(allocator_arg_t(), __a, |
| 526 | typename __make_tuple_indices<sizeof...(_Tp)>::type(), |
| 527 | typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), |
| 528 | typename __make_tuple_indices<0>::type(), |
| 529 | typename __make_tuple_types<tuple, 0>::type(), |
| 530 | __t... |
| 531 | ) {} |
| 532 | |
| 533 | template <class ..._Up, |
Howard Hinnant | dc1345f | 2012-04-01 23:10:42 +0000 | [diff] [blame] | 534 | typename enable_if |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 535 | < |
| 536 | sizeof...(_Up) <= sizeof...(_Tp) && |
| 537 | __tuple_convertible |
| 538 | < |
| 539 | tuple<_Up...>, |
| 540 | typename __make_tuple_types<tuple, |
| 541 | sizeof...(_Up) < sizeof...(_Tp) ? |
| 542 | sizeof...(_Up) : |
| 543 | sizeof...(_Tp)>::type |
Howard Hinnant | dc1345f | 2012-04-01 23:10:42 +0000 | [diff] [blame] | 544 | >::value, |
| 545 | bool |
| 546 | >::type = false |
| 547 | > |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 548 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | dc1345f | 2012-04-01 23:10:42 +0000 | [diff] [blame] | 549 | tuple(_Up&&... __u) |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 550 | _NOEXCEPT_(( |
| 551 | is_nothrow_constructible< |
| 552 | typename __make_tuple_indices<sizeof...(_Up)>::type, |
| 553 | typename __make_tuple_types<tuple, sizeof...(_Up)>::type, |
| 554 | typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type, |
| 555 | typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type, |
| 556 | _Up... |
| 557 | >::value |
| 558 | )) |
Howard Hinnant | dc1345f | 2012-04-01 23:10:42 +0000 | [diff] [blame] | 559 | : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(), |
| 560 | typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), |
| 561 | typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), |
| 562 | typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), |
| 563 | _VSTD::forward<_Up>(__u)...) {} |
| 564 | |
| 565 | template <class ..._Up, |
| 566 | typename enable_if |
| 567 | < |
| 568 | sizeof...(_Up) <= sizeof...(_Tp) && |
| 569 | __tuple_constructible |
| 570 | < |
| 571 | tuple<_Up...>, |
| 572 | typename __make_tuple_types<tuple, |
| 573 | sizeof...(_Up) < sizeof...(_Tp) ? |
| 574 | sizeof...(_Up) : |
| 575 | sizeof...(_Tp)>::type |
| 576 | >::value && |
| 577 | !__tuple_convertible |
| 578 | < |
| 579 | tuple<_Up...>, |
| 580 | typename __make_tuple_types<tuple, |
| 581 | sizeof...(_Up) < sizeof...(_Tp) ? |
| 582 | sizeof...(_Up) : |
| 583 | sizeof...(_Tp)>::type |
| 584 | >::value, |
| 585 | bool |
| 586 | >::type =false |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 587 | > |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 588 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 589 | explicit |
| 590 | tuple(_Up&&... __u) |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 591 | _NOEXCEPT_(( |
| 592 | is_nothrow_constructible< |
| 593 | typename __make_tuple_indices<sizeof...(_Up)>::type, |
| 594 | typename __make_tuple_types<tuple, sizeof...(_Up)>::type, |
| 595 | typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type, |
| 596 | typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type, |
| 597 | _Up... |
| 598 | >::value |
| 599 | )) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 600 | : base_(typename __make_tuple_indices<sizeof...(_Up)>::type(), |
| 601 | typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), |
| 602 | typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), |
| 603 | typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 604 | _VSTD::forward<_Up>(__u)...) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 605 | |
| 606 | template <class _Alloc, class ..._Up, |
| 607 | class = typename enable_if |
| 608 | < |
| 609 | sizeof...(_Up) <= sizeof...(_Tp) && |
| 610 | __tuple_convertible |
| 611 | < |
| 612 | tuple<_Up...>, |
| 613 | typename __make_tuple_types<tuple, |
| 614 | sizeof...(_Up) < sizeof...(_Tp) ? |
| 615 | sizeof...(_Up) : |
| 616 | sizeof...(_Tp)>::type |
| 617 | >::value |
| 618 | >::type |
| 619 | > |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 620 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 621 | tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u) |
| 622 | : base_(allocator_arg_t(), __a, |
| 623 | typename __make_tuple_indices<sizeof...(_Up)>::type(), |
| 624 | typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), |
| 625 | typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), |
| 626 | typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 627 | _VSTD::forward<_Up>(__u)...) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 628 | |
| 629 | template <class _Tuple, |
Howard Hinnant | dc1345f | 2012-04-01 23:10:42 +0000 | [diff] [blame] | 630 | typename enable_if |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 631 | < |
Howard Hinnant | dc1345f | 2012-04-01 23:10:42 +0000 | [diff] [blame] | 632 | __tuple_convertible<_Tuple, tuple>::value, |
| 633 | bool |
| 634 | >::type = false |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 635 | > |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 636 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 637 | tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value)) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 638 | : base_(_VSTD::forward<_Tuple>(__t)) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 639 | |
Howard Hinnant | dc1345f | 2012-04-01 23:10:42 +0000 | [diff] [blame] | 640 | template <class _Tuple, |
| 641 | typename enable_if |
| 642 | < |
| 643 | __tuple_constructible<_Tuple, tuple>::value && |
| 644 | !__tuple_convertible<_Tuple, tuple>::value, |
| 645 | bool |
| 646 | >::type = false |
| 647 | > |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 648 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | dc1345f | 2012-04-01 23:10:42 +0000 | [diff] [blame] | 649 | explicit |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 650 | tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value)) |
Howard Hinnant | dc1345f | 2012-04-01 23:10:42 +0000 | [diff] [blame] | 651 | : base_(_VSTD::forward<_Tuple>(__t)) {} |
| 652 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 653 | template <class _Alloc, class _Tuple, |
| 654 | class = typename enable_if |
| 655 | < |
| 656 | __tuple_convertible<_Tuple, tuple>::value |
| 657 | >::type |
| 658 | > |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 659 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 660 | tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 661 | : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 662 | |
| 663 | template <class _Tuple, |
| 664 | class = typename enable_if |
| 665 | < |
| 666 | __tuple_assignable<_Tuple, tuple>::value |
| 667 | >::type |
| 668 | > |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 669 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 670 | tuple& |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 671 | operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value)) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 672 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 673 | base_.operator=(_VSTD::forward<_Tuple>(__t)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 674 | return *this; |
| 675 | } |
| 676 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 677 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 678 | void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) |
| 679 | {base_.swap(__t.base_);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 680 | }; |
| 681 | |
| 682 | template <> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 683 | class _LIBCPP_TYPE_VIS_ONLY tuple<> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 684 | { |
| 685 | public: |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 686 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 4eebfc3 | 2012-07-06 20:50:27 +0000 | [diff] [blame] | 687 | _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 688 | template <class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 689 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 690 | tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 691 | template <class _Alloc> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 692 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 693 | tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {} |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 694 | template <class _Up> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 695 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 696 | tuple(array<_Up, 0>) _NOEXCEPT {} |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 697 | template <class _Alloc, class _Up> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 698 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 699 | tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 700 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 701 | void swap(tuple&) _NOEXCEPT {} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 702 | }; |
| 703 | |
| 704 | template <class ..._Tp> |
| 705 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | aabf287 | 2011-06-01 19:59:32 +0000 | [diff] [blame] | 706 | typename enable_if |
| 707 | < |
| 708 | __all<__is_swappable<_Tp>::value...>::value, |
| 709 | void |
| 710 | >::type |
Howard Hinnant | a5e0121 | 2011-05-27 19:08:18 +0000 | [diff] [blame] | 711 | swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) |
| 712 | _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) |
| 713 | {__t.swap(__u);} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 714 | |
| 715 | // get |
| 716 | |
| 717 | template <size_t _Ip, class ..._Tp> |
Marshall Clow | 8fc4f5a | 2013-07-17 18:25:36 +0000 | [diff] [blame] | 718 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | f83417b | 2011-01-24 16:07:25 +0000 | [diff] [blame] | 719 | typename tuple_element<_Ip, tuple<_Tp...> >::type& |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 720 | get(tuple<_Tp...>& __t) _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 721 | { |
Howard Hinnant | f83417b | 2011-01-24 16:07:25 +0000 | [diff] [blame] | 722 | typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 723 | return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get(); |
| 724 | } |
| 725 | |
| 726 | template <size_t _Ip, class ..._Tp> |
Marshall Clow | 8fc4f5a | 2013-07-17 18:25:36 +0000 | [diff] [blame] | 727 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | f83417b | 2011-01-24 16:07:25 +0000 | [diff] [blame] | 728 | const typename tuple_element<_Ip, tuple<_Tp...> >::type& |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 729 | get(const tuple<_Tp...>& __t) _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 730 | { |
Howard Hinnant | f83417b | 2011-01-24 16:07:25 +0000 | [diff] [blame] | 731 | typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 732 | return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get(); |
| 733 | } |
| 734 | |
Howard Hinnant | cd2254b | 2010-11-17 19:52:17 +0000 | [diff] [blame] | 735 | template <size_t _Ip, class ..._Tp> |
Marshall Clow | 8fc4f5a | 2013-07-17 18:25:36 +0000 | [diff] [blame] | 736 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | f83417b | 2011-01-24 16:07:25 +0000 | [diff] [blame] | 737 | typename tuple_element<_Ip, tuple<_Tp...> >::type&& |
Howard Hinnant | ec3773c | 2011-12-01 20:21:04 +0000 | [diff] [blame] | 738 | get(tuple<_Tp...>&& __t) _NOEXCEPT |
Howard Hinnant | cd2254b | 2010-11-17 19:52:17 +0000 | [diff] [blame] | 739 | { |
Howard Hinnant | f83417b | 2011-01-24 16:07:25 +0000 | [diff] [blame] | 740 | typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; |
Howard Hinnant | 56a85ca | 2011-01-25 16:31:30 +0000 | [diff] [blame] | 741 | return static_cast<type&&>( |
Douglas Gregor | 6c66994 | 2011-01-25 16:14:21 +0000 | [diff] [blame] | 742 | static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get()); |
Howard Hinnant | cd2254b | 2010-11-17 19:52:17 +0000 | [diff] [blame] | 743 | } |
| 744 | |
Marshall Clow | e8029e5 | 2013-07-13 02:54:05 +0000 | [diff] [blame] | 745 | #if _LIBCPP_STD_VER > 11 |
| 746 | // get by type |
| 747 | template <typename _T1, size_t _Idx, typename... _Args> |
| 748 | struct __find_exactly_one_t_helper; |
| 749 | |
| 750 | // -- find exactly one |
| 751 | template <typename _T1, size_t _Idx, typename... _Args> |
| 752 | struct __find_exactly_one_t_checker { |
| 753 | static constexpr size_t value = _Idx; |
| 754 | // Check the rest of the list to make sure there's only one |
| 755 | static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" ); |
| 756 | }; |
| 757 | |
| 758 | |
| 759 | template <typename _T1, size_t _Idx> |
| 760 | struct __find_exactly_one_t_helper <_T1, _Idx> { |
| 761 | static constexpr size_t value = -1; |
| 762 | }; |
| 763 | |
| 764 | template <typename _T1, size_t _Idx, typename _Head, typename... _Args> |
| 765 | struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> { |
| 766 | static constexpr size_t value = |
| 767 | std::conditional< |
| 768 | std::is_same<_T1, _Head>::value, |
Marshall Clow | 19e7862 | 2013-10-01 13:28:20 +0000 | [diff] [blame] | 769 | __find_exactly_one_t_checker<_T1, _Idx, _Args...>, |
Marshall Clow | e8029e5 | 2013-07-13 02:54:05 +0000 | [diff] [blame] | 770 | __find_exactly_one_t_helper <_T1, _Idx+1, _Args...> |
| 771 | >::type::value; |
| 772 | }; |
| 773 | |
| 774 | template <typename _T1, typename... _Args> |
| 775 | struct __find_exactly_one_t { |
| 776 | static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value; |
| 777 | static_assert ( value != -1, "type not found in type list" ); |
| 778 | }; |
| 779 | |
| 780 | template <class _T1, class... _Args> |
| 781 | inline _LIBCPP_INLINE_VISIBILITY |
| 782 | constexpr _T1& get(tuple<_Args...>& __tup) noexcept |
| 783 | { |
| 784 | return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); |
| 785 | } |
| 786 | |
| 787 | template <class _T1, class... _Args> |
| 788 | inline _LIBCPP_INLINE_VISIBILITY |
| 789 | constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept |
| 790 | { |
| 791 | return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup); |
| 792 | } |
| 793 | |
| 794 | template <class _T1, class... _Args> |
| 795 | inline _LIBCPP_INLINE_VISIBILITY |
| 796 | constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept |
| 797 | { |
Marshall Clow | 01a0e90 | 2013-07-15 20:46:11 +0000 | [diff] [blame] | 798 | 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] | 799 | } |
| 800 | |
| 801 | #endif |
| 802 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 803 | // tie |
| 804 | |
| 805 | template <class ..._Tp> |
Marshall Clow | 8e554d9 | 2014-02-25 16:11:46 +0000 | [diff] [blame] | 806 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 807 | tuple<_Tp&...> |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 808 | tie(_Tp&... __t) _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 809 | { |
| 810 | return tuple<_Tp&...>(__t...); |
| 811 | } |
| 812 | |
| 813 | template <class _Up> |
| 814 | struct __ignore_t |
| 815 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 816 | template <class _Tp> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 817 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 818 | const __ignore_t& operator=(_Tp&&) const {return *this;} |
| 819 | }; |
| 820 | |
| 821 | namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); } |
| 822 | |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 823 | template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 824 | |
| 825 | template <class _Tp> |
Marshall Clow | a71f956 | 2014-01-03 22:55:49 +0000 | [diff] [blame] | 826 | struct __make_tuple_return_impl |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 827 | { |
| 828 | typedef _Tp type; |
| 829 | }; |
| 830 | |
| 831 | template <class _Tp> |
Marshall Clow | a71f956 | 2014-01-03 22:55:49 +0000 | [diff] [blame] | 832 | struct __make_tuple_return_impl<reference_wrapper<_Tp> > |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 833 | { |
| 834 | typedef _Tp& type; |
| 835 | }; |
| 836 | |
| 837 | template <class _Tp> |
| 838 | struct __make_tuple_return |
| 839 | { |
Marshall Clow | a71f956 | 2014-01-03 22:55:49 +0000 | [diff] [blame] | 840 | typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 841 | }; |
| 842 | |
| 843 | template <class... _Tp> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 844 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 845 | tuple<typename __make_tuple_return<_Tp>::type...> |
| 846 | make_tuple(_Tp&&... __t) |
| 847 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 848 | return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 849 | } |
| 850 | |
Howard Hinnant | 3c1ffba | 2010-08-19 18:59:38 +0000 | [diff] [blame] | 851 | template <class... _Tp> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 852 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 853 | tuple<_Tp&&...> |
Howard Hinnant | 74f26f2 | 2012-07-06 21:53:48 +0000 | [diff] [blame] | 854 | forward_as_tuple(_Tp&&... __t) _NOEXCEPT |
Howard Hinnant | 3c1ffba | 2010-08-19 18:59:38 +0000 | [diff] [blame] | 855 | { |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 856 | return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...); |
Howard Hinnant | 3c1ffba | 2010-08-19 18:59:38 +0000 | [diff] [blame] | 857 | } |
| 858 | |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 859 | template <size_t _Ip> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 860 | struct __tuple_equal |
| 861 | { |
| 862 | template <class _Tp, class _Up> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 863 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 864 | bool operator()(const _Tp& __x, const _Up& __y) |
| 865 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 866 | return __tuple_equal<_Ip - 1>()(__x, __y) && get<_Ip-1>(__x) == get<_Ip-1>(__y); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 867 | } |
| 868 | }; |
| 869 | |
| 870 | template <> |
| 871 | struct __tuple_equal<0> |
| 872 | { |
| 873 | template <class _Tp, class _Up> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 874 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 875 | bool operator()(const _Tp&, const _Up&) |
| 876 | { |
| 877 | return true; |
| 878 | } |
| 879 | }; |
| 880 | |
| 881 | template <class ..._Tp, class ..._Up> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 882 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 883 | bool |
| 884 | operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) |
| 885 | { |
| 886 | return __tuple_equal<sizeof...(_Tp)>()(__x, __y); |
| 887 | } |
| 888 | |
| 889 | template <class ..._Tp, class ..._Up> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 890 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 891 | bool |
| 892 | operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) |
| 893 | { |
| 894 | return !(__x == __y); |
| 895 | } |
| 896 | |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 897 | template <size_t _Ip> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 898 | struct __tuple_less |
| 899 | { |
| 900 | template <class _Tp, class _Up> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 901 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 902 | bool operator()(const _Tp& __x, const _Up& __y) |
| 903 | { |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 904 | return __tuple_less<_Ip-1>()(__x, __y) || |
| 905 | (!__tuple_less<_Ip-1>()(__y, __x) && get<_Ip-1>(__x) < get<_Ip-1>(__y)); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 906 | } |
| 907 | }; |
| 908 | |
| 909 | template <> |
| 910 | struct __tuple_less<0> |
| 911 | { |
| 912 | template <class _Tp, class _Up> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 913 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 914 | bool operator()(const _Tp&, const _Up&) |
| 915 | { |
| 916 | return false; |
| 917 | } |
| 918 | }; |
| 919 | |
| 920 | template <class ..._Tp, class ..._Up> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 921 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 922 | bool |
| 923 | operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) |
| 924 | { |
| 925 | return __tuple_less<sizeof...(_Tp)>()(__x, __y); |
| 926 | } |
| 927 | |
| 928 | template <class ..._Tp, class ..._Up> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 929 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 930 | bool |
| 931 | operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) |
| 932 | { |
| 933 | return __y < __x; |
| 934 | } |
| 935 | |
| 936 | template <class ..._Tp, class ..._Up> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 937 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 938 | bool |
| 939 | operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) |
| 940 | { |
| 941 | return !(__x < __y); |
| 942 | } |
| 943 | |
| 944 | template <class ..._Tp, class ..._Up> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 945 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 946 | bool |
| 947 | operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) |
| 948 | { |
| 949 | return !(__y < __x); |
| 950 | } |
| 951 | |
| 952 | // tuple_cat |
| 953 | |
Howard Hinnant | 0e1493e | 2010-12-11 20:47:50 +0000 | [diff] [blame] | 954 | template <class _Tp, class _Up> struct __tuple_cat_type; |
| 955 | |
| 956 | template <class ..._Ttypes, class ..._Utypes> |
Howard Hinnant | f83417b | 2011-01-24 16:07:25 +0000 | [diff] [blame] | 957 | struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> > |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 958 | { |
Howard Hinnant | 0e1493e | 2010-12-11 20:47:50 +0000 | [diff] [blame] | 959 | typedef tuple<_Ttypes..., _Utypes...> type; |
| 960 | }; |
| 961 | |
| 962 | template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples> |
| 963 | struct __tuple_cat_return_1 |
| 964 | { |
| 965 | }; |
| 966 | |
| 967 | template <class ..._Types, class _Tuple0> |
| 968 | struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0> |
| 969 | { |
| 970 | typedef typename __tuple_cat_type<tuple<_Types...>, |
| 971 | typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type |
| 972 | type; |
| 973 | }; |
| 974 | |
| 975 | template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples> |
| 976 | struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...> |
| 977 | : public __tuple_cat_return_1< |
| 978 | typename __tuple_cat_type< |
| 979 | tuple<_Types...>, |
| 980 | typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type |
| 981 | >::type, |
| 982 | __tuple_like<typename remove_reference<_Tuple1>::type>::value, |
| 983 | _Tuple1, _Tuples...> |
| 984 | { |
| 985 | }; |
| 986 | |
| 987 | template <class ..._Tuples> struct __tuple_cat_return; |
| 988 | |
| 989 | template <class _Tuple0, class ..._Tuples> |
| 990 | struct __tuple_cat_return<_Tuple0, _Tuples...> |
| 991 | : public __tuple_cat_return_1<tuple<>, |
| 992 | __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0, |
| 993 | _Tuples...> |
| 994 | { |
| 995 | }; |
| 996 | |
| 997 | template <> |
| 998 | struct __tuple_cat_return<> |
| 999 | { |
| 1000 | typedef tuple<> type; |
| 1001 | }; |
| 1002 | |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 1003 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | 0e1493e | 2010-12-11 20:47:50 +0000 | [diff] [blame] | 1004 | tuple<> |
| 1005 | tuple_cat() |
| 1006 | { |
| 1007 | return tuple<>(); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1008 | } |
| 1009 | |
Howard Hinnant | 9996844 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1010 | template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples> |
Howard Hinnant | e48e366 | 2010-12-12 23:04:37 +0000 | [diff] [blame] | 1011 | struct __tuple_cat_return_ref_imp; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1012 | |
Howard Hinnant | e48e366 | 2010-12-12 23:04:37 +0000 | [diff] [blame] | 1013 | template <class ..._Types, size_t ..._I0, class _Tuple0> |
| 1014 | struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1015 | { |
Howard Hinnant | 0e1493e | 2010-12-11 20:47:50 +0000 | [diff] [blame] | 1016 | typedef typename remove_reference<_Tuple0>::type _T0; |
Howard Hinnant | e48e366 | 2010-12-12 23:04:37 +0000 | [diff] [blame] | 1017 | typedef tuple<_Types..., typename __apply_cv<_Tuple0, |
| 1018 | typename tuple_element<_I0, _T0>::type>::type&&...> type; |
| 1019 | }; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1020 | |
Howard Hinnant | e48e366 | 2010-12-12 23:04:37 +0000 | [diff] [blame] | 1021 | template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples> |
| 1022 | struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, |
| 1023 | _Tuple0, _Tuple1, _Tuples...> |
| 1024 | : public __tuple_cat_return_ref_imp< |
| 1025 | tuple<_Types..., typename __apply_cv<_Tuple0, |
| 1026 | typename tuple_element<_I0, |
| 1027 | typename remove_reference<_Tuple0>::type>::type>::type&&...>, |
| 1028 | typename __make_tuple_indices<tuple_size<typename |
| 1029 | remove_reference<_Tuple1>::type>::value>::type, |
| 1030 | _Tuple1, _Tuples...> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1031 | { |
Howard Hinnant | e48e366 | 2010-12-12 23:04:37 +0000 | [diff] [blame] | 1032 | }; |
| 1033 | |
| 1034 | template <class _Tuple0, class ..._Tuples> |
| 1035 | struct __tuple_cat_return_ref |
| 1036 | : public __tuple_cat_return_ref_imp<tuple<>, |
| 1037 | typename __make_tuple_indices< |
| 1038 | tuple_size<typename remove_reference<_Tuple0>::type>::value |
| 1039 | >::type, _Tuple0, _Tuples...> |
| 1040 | { |
| 1041 | }; |
| 1042 | |
| 1043 | template <class _Types, class _I0, class _J0> |
| 1044 | struct __tuple_cat; |
| 1045 | |
| 1046 | template <class ..._Types, size_t ..._I0, size_t ..._J0> |
Howard Hinnant | f83417b | 2011-01-24 16:07:25 +0000 | [diff] [blame] | 1047 | struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> > |
Howard Hinnant | e48e366 | 2010-12-12 23:04:37 +0000 | [diff] [blame] | 1048 | { |
| 1049 | template <class _Tuple0> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 1050 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | e48e366 | 2010-12-12 23:04:37 +0000 | [diff] [blame] | 1051 | typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type |
| 1052 | operator()(tuple<_Types...> __t, _Tuple0&& __t0) |
| 1053 | { |
Marshall Clow | 1d927e3 | 2013-10-05 18:46:37 +0000 | [diff] [blame] | 1054 | return forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))..., |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1055 | get<_J0>(_VSTD::forward<_Tuple0>(__t0))...); |
Howard Hinnant | e48e366 | 2010-12-12 23:04:37 +0000 | [diff] [blame] | 1056 | } |
| 1057 | |
| 1058 | template <class _Tuple0, class _Tuple1, class ..._Tuples> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 1059 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | e48e366 | 2010-12-12 23:04:37 +0000 | [diff] [blame] | 1060 | typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type |
| 1061 | operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls) |
| 1062 | { |
| 1063 | typedef typename remove_reference<_Tuple0>::type _T0; |
| 1064 | typedef typename remove_reference<_Tuple1>::type _T1; |
| 1065 | return __tuple_cat< |
| 1066 | tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>, |
| 1067 | typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type, |
| 1068 | typename __make_tuple_indices<tuple_size<_T1>::value>::type>() |
Marshall Clow | 1d927e3 | 2013-10-05 18:46:37 +0000 | [diff] [blame] | 1069 | (forward_as_tuple( |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1070 | _VSTD::forward<_Types>(get<_I0>(__t))..., |
| 1071 | get<_J0>(_VSTD::forward<_Tuple0>(__t0))... |
Howard Hinnant | e48e366 | 2010-12-12 23:04:37 +0000 | [diff] [blame] | 1072 | ), |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1073 | _VSTD::forward<_Tuple1>(__t1), |
| 1074 | _VSTD::forward<_Tuples>(__tpls)...); |
Howard Hinnant | e48e366 | 2010-12-12 23:04:37 +0000 | [diff] [blame] | 1075 | } |
| 1076 | }; |
| 1077 | |
| 1078 | template <class _Tuple0, class... _Tuples> |
Marshall Clow | da0a0e8 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 1079 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
Howard Hinnant | e48e366 | 2010-12-12 23:04:37 +0000 | [diff] [blame] | 1080 | typename __tuple_cat_return<_Tuple0, _Tuples...>::type |
| 1081 | tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) |
| 1082 | { |
| 1083 | typedef typename remove_reference<_Tuple0>::type _T0; |
| 1084 | return __tuple_cat<tuple<>, __tuple_indices<>, |
| 1085 | typename __make_tuple_indices<tuple_size<_T0>::value>::type>() |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1086 | (tuple<>(), _VSTD::forward<_Tuple0>(__t0), |
| 1087 | _VSTD::forward<_Tuples>(__tpls)...); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | template <class ..._Tp, class _Alloc> |
Howard Hinnant | 0f678bd | 2013-08-12 18:38:34 +0000 | [diff] [blame] | 1091 | struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1092 | : true_type {}; |
| 1093 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1094 | template <class _T1, class _T2> |
| 1095 | template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2> |
| 1096 | inline _LIBCPP_INLINE_VISIBILITY |
| 1097 | pair<_T1, _T2>::pair(piecewise_construct_t, |
| 1098 | tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args, |
| 1099 | __tuple_indices<_I1...>, __tuple_indices<_I2...>) |
Howard Hinnant | 0949eed | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1100 | : first(_VSTD::forward<_Args1>(get<_I1>( __first_args))...), |
| 1101 | second(_VSTD::forward<_Args2>(get<_I2>(__second_args))...) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1102 | { |
| 1103 | } |
| 1104 | |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1105 | #endif // _LIBCPP_HAS_NO_VARIADICS |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1106 | |
| 1107 | _LIBCPP_END_NAMESPACE_STD |
| 1108 | |
| 1109 | #endif // _LIBCPP_TUPLE |