| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // A Tuple is a generic templatized container, similar in concept to std::pair. | 5 // A Tuple is a generic templatized container, similar in concept to std::pair. |
| 6 // There are classes Tuple0 to Tuple6, cooresponding to the number of elements | 6 // There are classes Tuple0 to Tuple8, cooresponding to the number of elements |
| 7 // it contains. The convenient MakeTuple() function takes 0 to 6 arguments, | 7 // it contains. The convenient MakeTuple() function takes 0 to 8 arguments, |
| 8 // and will construct and return the appropriate Tuple object. The functions | 8 // and will construct and return the appropriate Tuple object. The functions |
| 9 // DispatchToMethod and DispatchToFunction take a function pointer or instance | 9 // DispatchToMethod and DispatchToFunction take a function pointer or instance |
| 10 // and method pointer, and unpack a tuple into arguments to the call. | 10 // and method pointer, and unpack a tuple into arguments to the call. |
| 11 // | 11 // |
| 12 // Tuple elements are copied by value, and stored in the tuple. See the unit | 12 // Tuple elements are copied by value, and stored in the tuple. See the unit |
| 13 // tests for more details of how/when the values are copied. | 13 // tests for more details of how/when the values are copied. |
| 14 // | 14 // |
| 15 // Example usage: | 15 // Example usage: |
| 16 // // These two methods of creating a Tuple are identical. | 16 // // These two methods of creating a Tuple are identical. |
| 17 // Tuple2<int, const char*> tuple_a(1, "wee"); | 17 // Tuple2<int, const char*> tuple_a(1, "wee"); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 template <class P> | 49 template <class P> |
| 50 struct TupleTraits<P&> { | 50 struct TupleTraits<P&> { |
| 51 typedef P ValueType; | 51 typedef P ValueType; |
| 52 typedef P& RefType; | 52 typedef P& RefType; |
| 53 typedef P& ParamType; | 53 typedef P& ParamType; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 template <class P> | 56 template <class P> |
| 57 struct TupleTypes { }; | 57 struct TupleTypes; |
| 58 | 58 |
| 59 // Tuple ----------------------------------------------------------------------- | 59 // Tuple ----------------------------------------------------------------------- |
| 60 // | 60 // |
| 61 // This set of classes is useful for bundling 0 or more heterogeneous data types | 61 // This set of classes is useful for bundling 0 or more heterogeneous data types |
| 62 // into a single variable. The advantage of this is that it greatly simplifies | 62 // into a single variable. The advantage of this is that it greatly simplifies |
| 63 // function objects that need to take an arbitrary number of parameters; see | 63 // function objects that need to take an arbitrary number of parameters; see |
| 64 // RunnableMethod and IPC::MessageWithTuple. | 64 // RunnableMethod and IPC::MessageWithTuple. |
| 65 // | 65 // |
| 66 // Tuple0 is supplied to act as a 'void' type. It can be used, for example, | 66 // Tuple0 is supplied to act as a 'void' type. It can be used, for example, |
| 67 // when dispatching to a function that accepts no arguments (see the | 67 // when dispatching to a function that accepts no arguments (see the |
| 68 // Dispatchers below). | 68 // Dispatchers below). |
| 69 // Tuple1<A> is rarely useful. One such use is when A is non-const ref that you | 69 // Tuple1<A> is rarely useful. One such use is when A is non-const ref that you |
| 70 // want filled by the dispatchee, and the tuple is merely a container for that | 70 // want filled by the dispatchee, and the tuple is merely a container for that |
| 71 // output (a "tier"). See MakeRefTuple and its usages. | 71 // output (a "tier"). See MakeRefTuple and its usages. |
| 72 | 72 |
| 73 struct Tuple0 { | 73 struct Tuple0; |
| 74 typedef Tuple0 ValueTuple; | 74 |
| 75 typedef Tuple0 RefTuple; | 75 template <typename A> |
| 76 typedef Tuple0 ParamTuple; | 76 struct Tuple1; |
| 77 |
| 78 template <typename A, typename B> |
| 79 struct Tuple2; |
| 80 |
| 81 template <typename A, typename B, typename C> |
| 82 struct Tuple3; |
| 83 |
| 84 template <typename A, typename B, typename C, typename D> |
| 85 struct Tuple4; |
| 86 |
| 87 template <typename A, typename B, typename C, typename D, typename E> |
| 88 struct Tuple5; |
| 89 |
| 90 template <typename A, typename B, typename C, typename D, typename E, |
| 91 typename F> |
| 92 struct Tuple6; |
| 93 |
| 94 template <typename A, typename B, typename C, typename D, typename E, |
| 95 typename F, typename G> |
| 96 struct Tuple7; |
| 97 |
| 98 template <typename A, typename B, typename C, typename D, typename E, |
| 99 typename F, typename G, typename H> |
| 100 struct Tuple8; |
| 101 |
| 102 namespace internal { |
| 103 |
| 104 template <typename... T> |
| 105 struct MakeTupleType; |
| 106 |
| 107 template <> |
| 108 struct MakeTupleType<> { |
| 109 typedef Tuple0 Type; |
| 110 }; |
| 111 |
| 112 template <typename A> |
| 113 struct MakeTupleType<A> { |
| 114 typedef Tuple1<A> Type; |
| 115 }; |
| 116 |
| 117 template <typename A, typename B> |
| 118 struct MakeTupleType<A, B> { |
| 119 typedef Tuple2<A, B> Type; |
| 120 }; |
| 121 |
| 122 template <typename A, typename B, typename C> |
| 123 struct MakeTupleType<A, B, C> { |
| 124 typedef Tuple3<A, B, C> Type; |
| 125 }; |
| 126 |
| 127 template <typename A, typename B, typename C, typename D> |
| 128 struct MakeTupleType<A, B, C, D> { |
| 129 typedef Tuple4<A, B, C, D> Type; |
| 130 }; |
| 131 |
| 132 template <typename A, typename B, typename C, typename D, typename E> |
| 133 struct MakeTupleType<A, B, C, D, E> { |
| 134 typedef Tuple5<A, B, C, D, E> Type; |
| 135 }; |
| 136 |
| 137 template <typename A, typename B, typename C, typename D, typename E, |
| 138 typename F> |
| 139 struct MakeTupleType<A, B, C, D, E, F> { |
| 140 typedef Tuple6<A, B, C, D, E, F> Type; |
| 141 }; |
| 142 |
| 143 template <typename A, typename B, typename C, typename D, typename E, |
| 144 typename F, typename G> |
| 145 struct MakeTupleType<A, B, C, D, E, F, G> { |
| 146 typedef Tuple7<A, B, C, D, E, F, G> Type; |
| 147 }; |
| 148 |
| 149 template <typename A, typename B, typename C, typename D, typename E, |
| 150 typename F, typename G, typename H> |
| 151 struct MakeTupleType<A, B, C, D, E, F, G, H> { |
| 152 typedef Tuple8<A, B, C, D, E, F, G, H> Type; |
| 153 }; |
| 154 |
| 155 template <int index, typename TupleType> |
| 156 struct NthTupleItemImpl; |
| 157 |
| 158 template <typename TupleType> |
| 159 struct NthTupleItemImpl<0, TupleType> { |
| 160 typedef typename TupleType::TypeA Type; |
| 161 static Type& Get(TupleType* tuple) { return tuple->a; } |
| 162 static const Type& Get(const TupleType* tuple) { return tuple->a; } |
| 163 }; |
| 164 |
| 165 template <typename TupleType> |
| 166 struct NthTupleItemImpl<1, TupleType> { |
| 167 typedef typename TupleType::TypeB Type; |
| 168 static Type& Get(TupleType* tuple) { return tuple->b; } |
| 169 static const Type& Get(const TupleType* tuple) { return tuple->b; } |
| 170 }; |
| 171 |
| 172 template <typename TupleType> |
| 173 struct NthTupleItemImpl<2, TupleType> { |
| 174 typedef typename TupleType::TypeC Type; |
| 175 static Type& Get(TupleType* tuple) { return tuple->c; } |
| 176 static const Type& Get(const TupleType* tuple) { return tuple->c; } |
| 177 }; |
| 178 |
| 179 template <typename TupleType> |
| 180 struct NthTupleItemImpl<3, TupleType> { |
| 181 typedef typename TupleType::TypeD Type; |
| 182 static Type& Get(TupleType* tuple) { return tuple->d; } |
| 183 static const Type& Get(const TupleType* tuple) { return tuple->d; } |
| 184 }; |
| 185 |
| 186 template <typename TupleType> |
| 187 struct NthTupleItemImpl<4, TupleType> { |
| 188 typedef typename TupleType::TypeE Type; |
| 189 static Type& Get(TupleType* tuple) { return tuple->e; } |
| 190 static const Type& Get(const TupleType* tuple) { return tuple->e; } |
| 191 }; |
| 192 |
| 193 template <typename TupleType> |
| 194 struct NthTupleItemImpl<5, TupleType> { |
| 195 typedef typename TupleType::TypeF Type; |
| 196 static Type& Get(TupleType* tuple) { return tuple->f; } |
| 197 static const Type& Get(const TupleType* tuple) { return tuple->f; } |
| 198 }; |
| 199 |
| 200 template <typename TupleType> |
| 201 struct NthTupleItemImpl<6, TupleType> { |
| 202 typedef typename TupleType::TypeG Type; |
| 203 static Type& Get(TupleType* tuple) { return tuple->g; } |
| 204 static const Type& Get(const TupleType* tuple) { return tuple->g; } |
| 205 }; |
| 206 |
| 207 template <typename TupleType> |
| 208 struct NthTupleItemImpl<7, TupleType> { |
| 209 typedef typename TupleType::TypeH Type; |
| 210 static Type& Get(TupleType* tuple) { return tuple->h; } |
| 211 static const Type& Get(const TupleType* tuple) { return tuple->h; } |
| 212 }; |
| 213 |
| 214 } // namespace internal |
| 215 |
| 216 template <typename... T> |
| 217 using Tuple = typename internal::MakeTupleType<T...>::Type; |
| 218 |
| 219 template <typename... T> |
| 220 struct TupleBase { |
| 221 static const int size = sizeof...(T); |
| 222 typedef Tuple<T...> TupleType; |
| 223 |
| 224 template <int index> |
| 225 using NthItemType = typename internal::NthTupleItemImpl< |
| 226 index, TupleType>::Type; |
| 227 |
| 228 template <int index> |
| 229 NthItemType<index>& Get() { |
| 230 static_assert(index < size, "Index out of bound"); |
| 231 return internal::NthTupleItemImpl<index, TupleType>::Get( |
| 232 static_cast<TupleType*>(this)); |
| 233 } |
| 234 |
| 235 template <int index> |
| 236 const NthItemType<index>& Get() const { |
| 237 static_assert(index < size, "Index out of bound"); |
| 238 return internal::NthTupleItemImpl<index, TupleType>::Get( |
| 239 static_cast<const TupleType*>(this)); |
| 240 } |
| 241 }; |
| 242 |
| 243 struct Tuple0 : TupleBase<> { |
| 77 }; | 244 }; |
| 78 | 245 |
| 79 template <class A> | 246 template <class A> |
| 80 struct Tuple1 { | 247 struct Tuple1 : TupleBase<A> { |
| 81 public: | |
| 82 typedef A TypeA; | 248 typedef A TypeA; |
| 83 | 249 |
| 84 Tuple1() {} | 250 Tuple1() {} |
| 85 explicit Tuple1(typename TupleTraits<A>::ParamType a) : a(a) {} | 251 explicit Tuple1(typename TupleTraits<A>::ParamType a) : a(a) {} |
| 86 | 252 |
| 87 A a; | 253 A a; |
| 88 }; | 254 }; |
| 89 | 255 |
| 90 template <class A, class B> | 256 template <class A, class B> |
| 91 struct Tuple2 { | 257 struct Tuple2 : TupleBase<A, B> { |
| 92 public: | |
| 93 typedef A TypeA; | 258 typedef A TypeA; |
| 94 typedef B TypeB; | 259 typedef B TypeB; |
| 95 | 260 |
| 96 Tuple2() {} | 261 Tuple2() {} |
| 97 Tuple2(typename TupleTraits<A>::ParamType a, | 262 Tuple2(typename TupleTraits<A>::ParamType a, |
| 98 typename TupleTraits<B>::ParamType b) | 263 typename TupleTraits<B>::ParamType b) |
| 99 : a(a), b(b) { | 264 : a(a), b(b) { |
| 100 } | 265 } |
| 101 | 266 |
| 102 A a; | 267 A a; |
| 103 B b; | 268 B b; |
| 104 }; | 269 }; |
| 105 | 270 |
| 106 template <class A, class B, class C> | 271 template <class A, class B, class C> |
| 107 struct Tuple3 { | 272 struct Tuple3 : TupleBase<A, B, C> { |
| 108 public: | |
| 109 typedef A TypeA; | 273 typedef A TypeA; |
| 110 typedef B TypeB; | 274 typedef B TypeB; |
| 111 typedef C TypeC; | 275 typedef C TypeC; |
| 112 | 276 |
| 113 Tuple3() {} | 277 Tuple3() {} |
| 114 Tuple3(typename TupleTraits<A>::ParamType a, | 278 Tuple3(typename TupleTraits<A>::ParamType a, |
| 115 typename TupleTraits<B>::ParamType b, | 279 typename TupleTraits<B>::ParamType b, |
| 116 typename TupleTraits<C>::ParamType c) | 280 typename TupleTraits<C>::ParamType c) |
| 117 : a(a), b(b), c(c){ | 281 : a(a), b(b), c(c){ |
| 118 } | 282 } |
| 119 | 283 |
| 120 A a; | 284 A a; |
| 121 B b; | 285 B b; |
| 122 C c; | 286 C c; |
| 123 }; | 287 }; |
| 124 | 288 |
| 125 template <class A, class B, class C, class D> | 289 template <class A, class B, class C, class D> |
| 126 struct Tuple4 { | 290 struct Tuple4 : TupleBase<A, B, C, D> { |
| 127 public: | |
| 128 typedef A TypeA; | 291 typedef A TypeA; |
| 129 typedef B TypeB; | 292 typedef B TypeB; |
| 130 typedef C TypeC; | 293 typedef C TypeC; |
| 131 typedef D TypeD; | 294 typedef D TypeD; |
| 132 | 295 |
| 133 Tuple4() {} | 296 Tuple4() {} |
| 134 Tuple4(typename TupleTraits<A>::ParamType a, | 297 Tuple4(typename TupleTraits<A>::ParamType a, |
| 135 typename TupleTraits<B>::ParamType b, | 298 typename TupleTraits<B>::ParamType b, |
| 136 typename TupleTraits<C>::ParamType c, | 299 typename TupleTraits<C>::ParamType c, |
| 137 typename TupleTraits<D>::ParamType d) | 300 typename TupleTraits<D>::ParamType d) |
| 138 : a(a), b(b), c(c), d(d) { | 301 : a(a), b(b), c(c), d(d) { |
| 139 } | 302 } |
| 140 | 303 |
| 141 A a; | 304 A a; |
| 142 B b; | 305 B b; |
| 143 C c; | 306 C c; |
| 144 D d; | 307 D d; |
| 145 }; | 308 }; |
| 146 | 309 |
| 147 template <class A, class B, class C, class D, class E> | 310 template <class A, class B, class C, class D, class E> |
| 148 struct Tuple5 { | 311 struct Tuple5 : TupleBase<A, B, C, D, E> { |
| 149 public: | |
| 150 typedef A TypeA; | 312 typedef A TypeA; |
| 151 typedef B TypeB; | 313 typedef B TypeB; |
| 152 typedef C TypeC; | 314 typedef C TypeC; |
| 153 typedef D TypeD; | 315 typedef D TypeD; |
| 154 typedef E TypeE; | 316 typedef E TypeE; |
| 155 | 317 |
| 156 Tuple5() {} | 318 Tuple5() {} |
| 157 Tuple5(typename TupleTraits<A>::ParamType a, | 319 Tuple5(typename TupleTraits<A>::ParamType a, |
| 158 typename TupleTraits<B>::ParamType b, | 320 typename TupleTraits<B>::ParamType b, |
| 159 typename TupleTraits<C>::ParamType c, | 321 typename TupleTraits<C>::ParamType c, |
| 160 typename TupleTraits<D>::ParamType d, | 322 typename TupleTraits<D>::ParamType d, |
| 161 typename TupleTraits<E>::ParamType e) | 323 typename TupleTraits<E>::ParamType e) |
| 162 : a(a), b(b), c(c), d(d), e(e) { | 324 : a(a), b(b), c(c), d(d), e(e) { |
| 163 } | 325 } |
| 164 | 326 |
| 165 A a; | 327 A a; |
| 166 B b; | 328 B b; |
| 167 C c; | 329 C c; |
| 168 D d; | 330 D d; |
| 169 E e; | 331 E e; |
| 170 }; | 332 }; |
| 171 | 333 |
| 172 template <class A, class B, class C, class D, class E, class F> | 334 template <class A, class B, class C, class D, class E, class F> |
| 173 struct Tuple6 { | 335 struct Tuple6 : TupleBase<A, B, C, D, E, F> { |
| 174 public: | |
| 175 typedef A TypeA; | 336 typedef A TypeA; |
| 176 typedef B TypeB; | 337 typedef B TypeB; |
| 177 typedef C TypeC; | 338 typedef C TypeC; |
| 178 typedef D TypeD; | 339 typedef D TypeD; |
| 179 typedef E TypeE; | 340 typedef E TypeE; |
| 180 typedef F TypeF; | 341 typedef F TypeF; |
| 181 | 342 |
| 182 Tuple6() {} | 343 Tuple6() {} |
| 183 Tuple6(typename TupleTraits<A>::ParamType a, | 344 Tuple6(typename TupleTraits<A>::ParamType a, |
| 184 typename TupleTraits<B>::ParamType b, | 345 typename TupleTraits<B>::ParamType b, |
| 185 typename TupleTraits<C>::ParamType c, | 346 typename TupleTraits<C>::ParamType c, |
| 186 typename TupleTraits<D>::ParamType d, | 347 typename TupleTraits<D>::ParamType d, |
| 187 typename TupleTraits<E>::ParamType e, | 348 typename TupleTraits<E>::ParamType e, |
| 188 typename TupleTraits<F>::ParamType f) | 349 typename TupleTraits<F>::ParamType f) |
| 189 : a(a), b(b), c(c), d(d), e(e), f(f) { | 350 : a(a), b(b), c(c), d(d), e(e), f(f) { |
| 190 } | 351 } |
| 191 | 352 |
| 192 A a; | 353 A a; |
| 193 B b; | 354 B b; |
| 194 C c; | 355 C c; |
| 195 D d; | 356 D d; |
| 196 E e; | 357 E e; |
| 197 F f; | 358 F f; |
| 198 }; | 359 }; |
| 199 | 360 |
| 200 template <class A, class B, class C, class D, class E, class F, class G> | 361 template <class A, class B, class C, class D, class E, class F, class G> |
| 201 struct Tuple7 { | 362 struct Tuple7 : TupleBase<A, B, C, D, E, F, G> { |
| 202 public: | |
| 203 typedef A TypeA; | 363 typedef A TypeA; |
| 204 typedef B TypeB; | 364 typedef B TypeB; |
| 205 typedef C TypeC; | 365 typedef C TypeC; |
| 206 typedef D TypeD; | 366 typedef D TypeD; |
| 207 typedef E TypeE; | 367 typedef E TypeE; |
| 208 typedef F TypeF; | 368 typedef F TypeF; |
| 209 typedef G TypeG; | 369 typedef G TypeG; |
| 210 | 370 |
| 211 Tuple7() {} | 371 Tuple7() {} |
| 212 Tuple7(typename TupleTraits<A>::ParamType a, | 372 Tuple7(typename TupleTraits<A>::ParamType a, |
| 213 typename TupleTraits<B>::ParamType b, | 373 typename TupleTraits<B>::ParamType b, |
| 214 typename TupleTraits<C>::ParamType c, | 374 typename TupleTraits<C>::ParamType c, |
| 215 typename TupleTraits<D>::ParamType d, | 375 typename TupleTraits<D>::ParamType d, |
| 216 typename TupleTraits<E>::ParamType e, | 376 typename TupleTraits<E>::ParamType e, |
| 217 typename TupleTraits<F>::ParamType f, | 377 typename TupleTraits<F>::ParamType f, |
| 218 typename TupleTraits<G>::ParamType g) | 378 typename TupleTraits<G>::ParamType g) |
| 219 : a(a), b(b), c(c), d(d), e(e), f(f), g(g) { | 379 : a(a), b(b), c(c), d(d), e(e), f(f), g(g) { |
| 220 } | 380 } |
| 221 | 381 |
| 222 A a; | 382 A a; |
| 223 B b; | 383 B b; |
| 224 C c; | 384 C c; |
| 225 D d; | 385 D d; |
| 226 E e; | 386 E e; |
| 227 F f; | 387 F f; |
| 228 G g; | 388 G g; |
| 229 }; | 389 }; |
| 230 | 390 |
| 231 template <class A, class B, class C, class D, class E, class F, class G, | 391 template <class A, class B, class C, class D, class E, class F, class G, |
| 232 class H> | 392 class H> |
| 233 struct Tuple8 { | 393 struct Tuple8 : TupleBase<A, B, C, D, E, F, G, H> { |
| 234 public: | |
| 235 typedef A TypeA; | 394 typedef A TypeA; |
| 236 typedef B TypeB; | 395 typedef B TypeB; |
| 237 typedef C TypeC; | 396 typedef C TypeC; |
| 238 typedef D TypeD; | 397 typedef D TypeD; |
| 239 typedef E TypeE; | 398 typedef E TypeE; |
| 240 typedef F TypeF; | 399 typedef F TypeF; |
| 241 typedef G TypeG; | 400 typedef G TypeG; |
| 242 typedef H TypeH; | 401 typedef H TypeH; |
| 243 | 402 |
| 244 Tuple8() {} | 403 Tuple8() {} |
| 245 Tuple8(typename TupleTraits<A>::ParamType a, | 404 Tuple8(typename TupleTraits<A>::ParamType a, |
| 246 typename TupleTraits<B>::ParamType b, | 405 typename TupleTraits<B>::ParamType b, |
| 247 typename TupleTraits<C>::ParamType c, | 406 typename TupleTraits<C>::ParamType c, |
| 248 typename TupleTraits<D>::ParamType d, | 407 typename TupleTraits<D>::ParamType d, |
| 249 typename TupleTraits<E>::ParamType e, | 408 typename TupleTraits<E>::ParamType e, |
| 250 typename TupleTraits<F>::ParamType f, | 409 typename TupleTraits<F>::ParamType f, |
| 251 typename TupleTraits<G>::ParamType g, | 410 typename TupleTraits<G>::ParamType g, |
| 252 typename TupleTraits<H>::ParamType h) | 411 typename TupleTraits<H>::ParamType h) |
| 253 : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) { | 412 : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) { |
| 254 } | 413 } |
| 255 | 414 |
| 256 A a; | 415 A a; |
| 257 B b; | 416 B b; |
| 258 C c; | 417 C c; |
| 259 D d; | 418 D d; |
| 260 E e; | 419 E e; |
| 261 F f; | 420 F f; |
| 262 G g; | 421 G g; |
| 263 H h; | 422 H h; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 279 struct TupleTypes< Tuple1<A> > { | 438 struct TupleTypes< Tuple1<A> > { |
| 280 typedef Tuple1<typename TupleTraits<A>::ValueType> ValueTuple; | 439 typedef Tuple1<typename TupleTraits<A>::ValueType> ValueTuple; |
| 281 typedef Tuple1<typename TupleTraits<A>::RefType> RefTuple; | 440 typedef Tuple1<typename TupleTraits<A>::RefType> RefTuple; |
| 282 typedef Tuple1<typename TupleTraits<A>::ParamType> ParamTuple; | 441 typedef Tuple1<typename TupleTraits<A>::ParamType> ParamTuple; |
| 283 }; | 442 }; |
| 284 | 443 |
| 285 template <class A, class B> | 444 template <class A, class B> |
| 286 struct TupleTypes< Tuple2<A, B> > { | 445 struct TupleTypes< Tuple2<A, B> > { |
| 287 typedef Tuple2<typename TupleTraits<A>::ValueType, | 446 typedef Tuple2<typename TupleTraits<A>::ValueType, |
| 288 typename TupleTraits<B>::ValueType> ValueTuple; | 447 typename TupleTraits<B>::ValueType> ValueTuple; |
| 289 typedef Tuple2<typename TupleTraits<A>::RefType, | 448 typedef Tuple2<typename TupleTraits<A>::RefType, |
| 290 typename TupleTraits<B>::RefType> RefTuple; | 449 typename TupleTraits<B>::RefType> RefTuple; |
| 291 typedef Tuple2<typename TupleTraits<A>::ParamType, | 450 typedef Tuple2<typename TupleTraits<A>::ParamType, |
| 292 typename TupleTraits<B>::ParamType> ParamTuple; | 451 typename TupleTraits<B>::ParamType> ParamTuple; |
| 293 }; | 452 }; |
| 294 | 453 |
| 295 template <class A, class B, class C> | 454 template <class A, class B, class C> |
| 296 struct TupleTypes< Tuple3<A, B, C> > { | 455 struct TupleTypes< Tuple3<A, B, C> > { |
| 297 typedef Tuple3<typename TupleTraits<A>::ValueType, | 456 typedef Tuple3<typename TupleTraits<A>::ValueType, |
| 298 typename TupleTraits<B>::ValueType, | 457 typename TupleTraits<B>::ValueType, |
| 299 typename TupleTraits<C>::ValueType> ValueTuple; | 458 typename TupleTraits<C>::ValueType> ValueTuple; |
| 300 typedef Tuple3<typename TupleTraits<A>::RefType, | 459 typedef Tuple3<typename TupleTraits<A>::RefType, |
| 301 typename TupleTraits<B>::RefType, | 460 typename TupleTraits<B>::RefType, |
| 302 typename TupleTraits<C>::RefType> RefTuple; | 461 typename TupleTraits<C>::RefType> RefTuple; |
| 303 typedef Tuple3<typename TupleTraits<A>::ParamType, | 462 typedef Tuple3<typename TupleTraits<A>::ParamType, |
| 304 typename TupleTraits<B>::ParamType, | 463 typename TupleTraits<B>::ParamType, |
| 305 typename TupleTraits<C>::ParamType> ParamTuple; | 464 typename TupleTraits<C>::ParamType> ParamTuple; |
| 306 }; | 465 }; |
| 307 | 466 |
| 308 template <class A, class B, class C, class D> | 467 template <class A, class B, class C, class D> |
| 309 struct TupleTypes< Tuple4<A, B, C, D> > { | 468 struct TupleTypes< Tuple4<A, B, C, D> > { |
| 310 typedef Tuple4<typename TupleTraits<A>::ValueType, | 469 typedef Tuple4<typename TupleTraits<A>::ValueType, |
| 311 typename TupleTraits<B>::ValueType, | 470 typename TupleTraits<B>::ValueType, |
| 312 typename TupleTraits<C>::ValueType, | 471 typename TupleTraits<C>::ValueType, |
| 313 typename TupleTraits<D>::ValueType> ValueTuple; | 472 typename TupleTraits<D>::ValueType> ValueTuple; |
| 314 typedef Tuple4<typename TupleTraits<A>::RefType, | 473 typedef Tuple4<typename TupleTraits<A>::RefType, |
| 315 typename TupleTraits<B>::RefType, | 474 typename TupleTraits<B>::RefType, |
| 316 typename TupleTraits<C>::RefType, | 475 typename TupleTraits<C>::RefType, |
| 317 typename TupleTraits<D>::RefType> RefTuple; | 476 typename TupleTraits<D>::RefType> RefTuple; |
| 318 typedef Tuple4<typename TupleTraits<A>::ParamType, | 477 typedef Tuple4<typename TupleTraits<A>::ParamType, |
| 319 typename TupleTraits<B>::ParamType, | 478 typename TupleTraits<B>::ParamType, |
| 320 typename TupleTraits<C>::ParamType, | 479 typename TupleTraits<C>::ParamType, |
| 321 typename TupleTraits<D>::ParamType> ParamTuple; | 480 typename TupleTraits<D>::ParamType> ParamTuple; |
| 322 }; | 481 }; |
| 323 | 482 |
| 324 template <class A, class B, class C, class D, class E> | 483 template <class A, class B, class C, class D, class E> |
| 325 struct TupleTypes< Tuple5<A, B, C, D, E> > { | 484 struct TupleTypes< Tuple5<A, B, C, D, E> > { |
| 326 typedef Tuple5<typename TupleTraits<A>::ValueType, | 485 typedef Tuple5<typename TupleTraits<A>::ValueType, |
| 327 typename TupleTraits<B>::ValueType, | 486 typename TupleTraits<B>::ValueType, |
| 328 typename TupleTraits<C>::ValueType, | 487 typename TupleTraits<C>::ValueType, |
| 329 typename TupleTraits<D>::ValueType, | 488 typename TupleTraits<D>::ValueType, |
| 330 typename TupleTraits<E>::ValueType> ValueTuple; | 489 typename TupleTraits<E>::ValueType> ValueTuple; |
| 331 typedef Tuple5<typename TupleTraits<A>::RefType, | 490 typedef Tuple5<typename TupleTraits<A>::RefType, |
| 332 typename TupleTraits<B>::RefType, | 491 typename TupleTraits<B>::RefType, |
| 333 typename TupleTraits<C>::RefType, | 492 typename TupleTraits<C>::RefType, |
| 334 typename TupleTraits<D>::RefType, | 493 typename TupleTraits<D>::RefType, |
| 335 typename TupleTraits<E>::RefType> RefTuple; | 494 typename TupleTraits<E>::RefType> RefTuple; |
| 336 typedef Tuple5<typename TupleTraits<A>::ParamType, | 495 typedef Tuple5<typename TupleTraits<A>::ParamType, |
| 337 typename TupleTraits<B>::ParamType, | 496 typename TupleTraits<B>::ParamType, |
| 338 typename TupleTraits<C>::ParamType, | 497 typename TupleTraits<C>::ParamType, |
| 339 typename TupleTraits<D>::ParamType, | 498 typename TupleTraits<D>::ParamType, |
| 340 typename TupleTraits<E>::ParamType> ParamTuple; | 499 typename TupleTraits<E>::ParamType> ParamTuple; |
| 341 }; | 500 }; |
| 342 | 501 |
| 343 template <class A, class B, class C, class D, class E, class F> | 502 template <class A, class B, class C, class D, class E, class F> |
| 344 struct TupleTypes< Tuple6<A, B, C, D, E, F> > { | 503 struct TupleTypes< Tuple6<A, B, C, D, E, F> > { |
| 345 typedef Tuple6<typename TupleTraits<A>::ValueType, | 504 typedef Tuple6<typename TupleTraits<A>::ValueType, |
| 346 typename TupleTraits<B>::ValueType, | 505 typename TupleTraits<B>::ValueType, |
| 347 typename TupleTraits<C>::ValueType, | 506 typename TupleTraits<C>::ValueType, |
| 348 typename TupleTraits<D>::ValueType, | 507 typename TupleTraits<D>::ValueType, |
| 349 typename TupleTraits<E>::ValueType, | 508 typename TupleTraits<E>::ValueType, |
| 350 typename TupleTraits<F>::ValueType> ValueTuple; | 509 typename TupleTraits<F>::ValueType> ValueTuple; |
| 351 typedef Tuple6<typename TupleTraits<A>::RefType, | 510 typedef Tuple6<typename TupleTraits<A>::RefType, |
| 352 typename TupleTraits<B>::RefType, | 511 typename TupleTraits<B>::RefType, |
| 353 typename TupleTraits<C>::RefType, | 512 typename TupleTraits<C>::RefType, |
| 354 typename TupleTraits<D>::RefType, | 513 typename TupleTraits<D>::RefType, |
| 355 typename TupleTraits<E>::RefType, | 514 typename TupleTraits<E>::RefType, |
| 356 typename TupleTraits<F>::RefType> RefTuple; | 515 typename TupleTraits<F>::RefType> RefTuple; |
| 357 typedef Tuple6<typename TupleTraits<A>::ParamType, | 516 typedef Tuple6<typename TupleTraits<A>::ParamType, |
| 358 typename TupleTraits<B>::ParamType, | 517 typename TupleTraits<B>::ParamType, |
| 359 typename TupleTraits<C>::ParamType, | 518 typename TupleTraits<C>::ParamType, |
| 360 typename TupleTraits<D>::ParamType, | 519 typename TupleTraits<D>::ParamType, |
| 361 typename TupleTraits<E>::ParamType, | 520 typename TupleTraits<E>::ParamType, |
| 362 typename TupleTraits<F>::ParamType> ParamTuple; | 521 typename TupleTraits<F>::ParamType> ParamTuple; |
| 363 }; | 522 }; |
| 364 | 523 |
| 365 template <class A, class B, class C, class D, class E, class F, class G> | 524 template <class A, class B, class C, class D, class E, class F, class G> |
| 366 struct TupleTypes< Tuple7<A, B, C, D, E, F, G> > { | 525 struct TupleTypes< Tuple7<A, B, C, D, E, F, G> > { |
| 367 typedef Tuple7<typename TupleTraits<A>::ValueType, | 526 typedef Tuple7<typename TupleTraits<A>::ValueType, |
| 368 typename TupleTraits<B>::ValueType, | 527 typename TupleTraits<B>::ValueType, |
| 369 typename TupleTraits<C>::ValueType, | 528 typename TupleTraits<C>::ValueType, |
| 370 typename TupleTraits<D>::ValueType, | 529 typename TupleTraits<D>::ValueType, |
| 371 typename TupleTraits<E>::ValueType, | 530 typename TupleTraits<E>::ValueType, |
| 372 typename TupleTraits<F>::ValueType, | 531 typename TupleTraits<F>::ValueType, |
| 373 typename TupleTraits<G>::ValueType> ValueTuple; | 532 typename TupleTraits<G>::ValueType> ValueTuple; |
| 374 typedef Tuple7<typename TupleTraits<A>::RefType, | 533 typedef Tuple7<typename TupleTraits<A>::RefType, |
| 375 typename TupleTraits<B>::RefType, | 534 typename TupleTraits<B>::RefType, |
| 376 typename TupleTraits<C>::RefType, | 535 typename TupleTraits<C>::RefType, |
| 377 typename TupleTraits<D>::RefType, | 536 typename TupleTraits<D>::RefType, |
| 378 typename TupleTraits<E>::RefType, | 537 typename TupleTraits<E>::RefType, |
| 379 typename TupleTraits<F>::RefType, | 538 typename TupleTraits<F>::RefType, |
| 380 typename TupleTraits<G>::RefType> RefTuple; | 539 typename TupleTraits<G>::RefType> RefTuple; |
| 381 typedef Tuple7<typename TupleTraits<A>::ParamType, | 540 typedef Tuple7<typename TupleTraits<A>::ParamType, |
| 382 typename TupleTraits<B>::ParamType, | 541 typename TupleTraits<B>::ParamType, |
| 383 typename TupleTraits<C>::ParamType, | 542 typename TupleTraits<C>::ParamType, |
| 384 typename TupleTraits<D>::ParamType, | 543 typename TupleTraits<D>::ParamType, |
| 385 typename TupleTraits<E>::ParamType, | 544 typename TupleTraits<E>::ParamType, |
| 386 typename TupleTraits<F>::ParamType, | 545 typename TupleTraits<F>::ParamType, |
| 387 typename TupleTraits<G>::ParamType> ParamTuple; | 546 typename TupleTraits<G>::ParamType> ParamTuple; |
| 388 }; | 547 }; |
| 389 | 548 |
| 390 template <class A, class B, class C, class D, class E, class F, class G, | 549 template <class A, class B, class C, class D, class E, class F, class G, |
| 391 class H> | 550 class H> |
| 392 struct TupleTypes< Tuple8<A, B, C, D, E, F, G, H> > { | 551 struct TupleTypes< Tuple8<A, B, C, D, E, F, G, H> > { |
| 393 typedef Tuple8<typename TupleTraits<A>::ValueType, | 552 typedef Tuple8<typename TupleTraits<A>::ValueType, |
| 394 typename TupleTraits<B>::ValueType, | 553 typename TupleTraits<B>::ValueType, |
| 395 typename TupleTraits<C>::ValueType, | 554 typename TupleTraits<C>::ValueType, |
| 396 typename TupleTraits<D>::ValueType, | 555 typename TupleTraits<D>::ValueType, |
| 397 typename TupleTraits<E>::ValueType, | 556 typename TupleTraits<E>::ValueType, |
| 398 typename TupleTraits<F>::ValueType, | 557 typename TupleTraits<F>::ValueType, |
| 399 typename TupleTraits<G>::ValueType, | 558 typename TupleTraits<G>::ValueType, |
| 400 typename TupleTraits<H>::ValueType> ValueTuple; | 559 typename TupleTraits<H>::ValueType> ValueTuple; |
| 401 typedef Tuple8<typename TupleTraits<A>::RefType, | 560 typedef Tuple8<typename TupleTraits<A>::RefType, |
| 402 typename TupleTraits<B>::RefType, | 561 typename TupleTraits<B>::RefType, |
| 403 typename TupleTraits<C>::RefType, | 562 typename TupleTraits<C>::RefType, |
| 404 typename TupleTraits<D>::RefType, | 563 typename TupleTraits<D>::RefType, |
| 405 typename TupleTraits<E>::RefType, | 564 typename TupleTraits<E>::RefType, |
| 406 typename TupleTraits<F>::RefType, | 565 typename TupleTraits<F>::RefType, |
| 407 typename TupleTraits<G>::RefType, | 566 typename TupleTraits<G>::RefType, |
| 408 typename TupleTraits<H>::RefType> RefTuple; | 567 typename TupleTraits<H>::RefType> RefTuple; |
| 409 typedef Tuple8<typename TupleTraits<A>::ParamType, | 568 typedef Tuple8<typename TupleTraits<A>::ParamType, |
| 410 typename TupleTraits<B>::ParamType, | 569 typename TupleTraits<B>::ParamType, |
| 411 typename TupleTraits<C>::ParamType, | 570 typename TupleTraits<C>::ParamType, |
| 412 typename TupleTraits<D>::ParamType, | 571 typename TupleTraits<D>::ParamType, |
| 413 typename TupleTraits<E>::ParamType, | 572 typename TupleTraits<E>::ParamType, |
| 414 typename TupleTraits<F>::ParamType, | 573 typename TupleTraits<F>::ParamType, |
| 415 typename TupleTraits<G>::ParamType, | 574 typename TupleTraits<G>::ParamType, |
| 416 typename TupleTraits<H>::ParamType> ParamTuple; | 575 typename TupleTraits<H>::ParamType> ParamTuple; |
| 417 }; | 576 }; |
| 418 | 577 |
| 419 // Tuple creators ------------------------------------------------------------- | 578 // Tuple creators ------------------------------------------------------------- |
| 420 // | 579 // |
| 421 // Helper functions for constructing tuples while inferring the template | 580 // Helper function for constructing tuples while inferring the template |
| 422 // argument types. | 581 // argument types. |
| 423 | 582 template <typename... T> |
| 424 inline Tuple0 MakeTuple() { | 583 inline Tuple<T...> MakeTuple(const T&... p) { |
| 425 return Tuple0(); | 584 return Tuple<T...>(p...); |
| 426 } | 585 } |
| 427 | 586 |
| 428 template <class A> | 587 // The following helper make what Boost refers to as "Tiers" - a tuple |
| 429 inline Tuple1<A> MakeTuple(const A& a) { | |
| 430 return Tuple1<A>(a); | |
| 431 } | |
| 432 | |
| 433 template <class A, class B> | |
| 434 inline Tuple2<A, B> MakeTuple(const A& a, const B& b) { | |
| 435 return Tuple2<A, B>(a, b); | |
| 436 } | |
| 437 | |
| 438 template <class A, class B, class C> | |
| 439 inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c) { | |
| 440 return Tuple3<A, B, C>(a, b, c); | |
| 441 } | |
| 442 | |
| 443 template <class A, class B, class C, class D> | |
| 444 inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c, | |
| 445 const D& d) { | |
| 446 return Tuple4<A, B, C, D>(a, b, c, d); | |
| 447 } | |
| 448 | |
| 449 template <class A, class B, class C, class D, class E> | |
| 450 inline Tuple5<A, B, C, D, E> MakeTuple(const A& a, const B& b, const C& c, | |
| 451 const D& d, const E& e) { | |
| 452 return Tuple5<A, B, C, D, E>(a, b, c, d, e); | |
| 453 } | |
| 454 | |
| 455 template <class A, class B, class C, class D, class E, class F> | |
| 456 inline Tuple6<A, B, C, D, E, F> MakeTuple(const A& a, const B& b, const C& c, | |
| 457 const D& d, const E& e, const F& f) { | |
| 458 return Tuple6<A, B, C, D, E, F>(a, b, c, d, e, f); | |
| 459 } | |
| 460 | |
| 461 template <class A, class B, class C, class D, class E, class F, class G> | |
| 462 inline Tuple7<A, B, C, D, E, F, G> MakeTuple(const A& a, const B& b, const C& c, | |
| 463 const D& d, const E& e, const F& f, | |
| 464 const G& g) { | |
| 465 return Tuple7<A, B, C, D, E, F, G>(a, b, c, d, e, f, g); | |
| 466 } | |
| 467 | |
| 468 template <class A, class B, class C, class D, class E, class F, class G, | |
| 469 class H> | |
| 470 inline Tuple8<A, B, C, D, E, F, G, H> MakeTuple(const A& a, const B& b, | |
| 471 const C& c, const D& d, | |
| 472 const E& e, const F& f, | |
| 473 const G& g, const H& h) { | |
| 474 return Tuple8<A, B, C, D, E, F, G, H>(a, b, c, d, e, f, g, h); | |
| 475 } | |
| 476 | |
| 477 // The following set of helpers make what Boost refers to as "Tiers" - a tuple | |
| 478 // of references. | 588 // of references. |
| 479 | 589 template <typename... T> |
| 480 template <class A> | 590 inline Tuple<T&...> MakeRefTuple(T&... p) { |
| 481 inline Tuple1<A&> MakeRefTuple(A& a) { | 591 return Tuple<T&...>(p...); |
| 482 return Tuple1<A&>(a); | |
| 483 } | |
| 484 | |
| 485 template <class A, class B> | |
| 486 inline Tuple2<A&, B&> MakeRefTuple(A& a, B& b) { | |
| 487 return Tuple2<A&, B&>(a, b); | |
| 488 } | |
| 489 | |
| 490 template <class A, class B, class C> | |
| 491 inline Tuple3<A&, B&, C&> MakeRefTuple(A& a, B& b, C& c) { | |
| 492 return Tuple3<A&, B&, C&>(a, b, c); | |
| 493 } | |
| 494 | |
| 495 template <class A, class B, class C, class D> | |
| 496 inline Tuple4<A&, B&, C&, D&> MakeRefTuple(A& a, B& b, C& c, D& d) { | |
| 497 return Tuple4<A&, B&, C&, D&>(a, b, c, d); | |
| 498 } | |
| 499 | |
| 500 template <class A, class B, class C, class D, class E> | |
| 501 inline Tuple5<A&, B&, C&, D&, E&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e) { | |
| 502 return Tuple5<A&, B&, C&, D&, E&>(a, b, c, d, e); | |
| 503 } | |
| 504 | |
| 505 template <class A, class B, class C, class D, class E, class F> | |
| 506 inline Tuple6<A&, B&, C&, D&, E&, F&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e, | |
| 507 F& f) { | |
| 508 return Tuple6<A&, B&, C&, D&, E&, F&>(a, b, c, d, e, f); | |
| 509 } | |
| 510 | |
| 511 template <class A, class B, class C, class D, class E, class F, class G> | |
| 512 inline Tuple7<A&, B&, C&, D&, E&, F&, G&> MakeRefTuple(A& a, B& b, C& c, D& d, | |
| 513 E& e, F& f, G& g) { | |
| 514 return Tuple7<A&, B&, C&, D&, E&, F&, G&>(a, b, c, d, e, f, g); | |
| 515 } | |
| 516 | |
| 517 template <class A, class B, class C, class D, class E, class F, class G, | |
| 518 class H> | |
| 519 inline Tuple8<A&, B&, C&, D&, E&, F&, G&, H&> MakeRefTuple(A& a, B& b, C& c, | |
| 520 D& d, E& e, F& f, | |
| 521 G& g, H& h) { | |
| 522 return Tuple8<A&, B&, C&, D&, E&, F&, G&, H&>(a, b, c, d, e, f, g, h); | |
| 523 } | 592 } |
| 524 | 593 |
| 525 // Dispatchers ---------------------------------------------------------------- | 594 // Dispatchers ---------------------------------------------------------------- |
| 526 // | 595 // |
| 527 // Helper functions that call the given method on an object, with the unpacked | 596 // Helper functions that call the given method on an object, with the unpacked |
| 528 // tuple arguments. Notice that they all have the same number of arguments, | 597 // tuple arguments. Notice that they all have the same number of arguments, |
| 529 // so you need only write: | 598 // so you need only write: |
| 530 // DispatchToMethod(object, &Object::method, args); | 599 // DispatchToMethod(object, &Object::method, args); |
| 531 // This is very useful for templated dispatchers, since they don't need to know | 600 // This is very useful for templated dispatchers, since they don't need to know |
| 532 // what type |args| is. | 601 // what type |args| is. |
| 533 | 602 |
| 534 // Non-Static Dispatchers with no out params. | 603 // Non-Static Dispatchers with no out params. |
| 535 | 604 |
| 536 template <class ObjT, class Method> | 605 template <class ObjT, class Method> |
| 537 inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) { | 606 inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) { |
| 538 (obj->*method)(); | 607 (obj->*method)(); |
| 539 } | 608 } |
| 540 | 609 |
| 541 template <class ObjT, class Method, class A> | 610 template <class ObjT, class Method, class A> |
| 542 inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) { | |
| 543 (obj->*method)(base::internal::UnwrapTraits<A>::Unwrap(arg)); | |
| 544 } | |
| 545 | |
| 546 template <class ObjT, class Method, class A> | |
| 547 inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) { | 611 inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) { |
| 548 (obj->*method)(base::internal::UnwrapTraits<A>::Unwrap(arg.a)); | 612 (obj->*method)(base::internal::UnwrapTraits<A>::Unwrap(arg.a)); |
| 549 } | 613 } |
| 550 | 614 |
| 551 template<class ObjT, class Method, class A, class B> | 615 template<class ObjT, class Method, class A, class B> |
| 552 inline void DispatchToMethod(ObjT* obj, | 616 inline void DispatchToMethod(ObjT* obj, |
| 553 Method method, | 617 Method method, |
| 554 const Tuple2<A, B>& arg) { | 618 const Tuple2<A, B>& arg) { |
| 555 (obj->*method)(base::internal::UnwrapTraits<A>::Unwrap(arg.a), | 619 (obj->*method)(base::internal::UnwrapTraits<A>::Unwrap(arg.a), |
| 556 base::internal::UnwrapTraits<B>::Unwrap(arg.b)); | 620 base::internal::UnwrapTraits<B>::Unwrap(arg.b)); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 } | 687 } |
| 624 | 688 |
| 625 // Static Dispatchers with no out params. | 689 // Static Dispatchers with no out params. |
| 626 | 690 |
| 627 template <class Function> | 691 template <class Function> |
| 628 inline void DispatchToFunction(Function function, const Tuple0& arg) { | 692 inline void DispatchToFunction(Function function, const Tuple0& arg) { |
| 629 (*function)(); | 693 (*function)(); |
| 630 } | 694 } |
| 631 | 695 |
| 632 template <class Function, class A> | 696 template <class Function, class A> |
| 633 inline void DispatchToFunction(Function function, const A& arg) { | |
| 634 (*function)(arg); | |
| 635 } | |
| 636 | |
| 637 template <class Function, class A> | |
| 638 inline void DispatchToFunction(Function function, const Tuple1<A>& arg) { | 697 inline void DispatchToFunction(Function function, const Tuple1<A>& arg) { |
| 639 (*function)(base::internal::UnwrapTraits<A>::Unwrap(arg.a)); | 698 (*function)(base::internal::UnwrapTraits<A>::Unwrap(arg.a)); |
| 640 } | 699 } |
| 641 | 700 |
| 642 template<class Function, class A, class B> | 701 template<class Function, class A, class B> |
| 643 inline void DispatchToFunction(Function function, const Tuple2<A, B>& arg) { | 702 inline void DispatchToFunction(Function function, const Tuple2<A, B>& arg) { |
| 644 (*function)(base::internal::UnwrapTraits<A>::Unwrap(arg.a), | 703 (*function)(base::internal::UnwrapTraits<A>::Unwrap(arg.a), |
| 645 base::internal::UnwrapTraits<B>::Unwrap(arg.b)); | 704 base::internal::UnwrapTraits<B>::Unwrap(arg.b)); |
| 646 } | 705 } |
| 647 | 706 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 // Dispatchers with 0 out param (as a Tuple0). | 771 // Dispatchers with 0 out param (as a Tuple0). |
| 713 | 772 |
| 714 template <class ObjT, class Method> | 773 template <class ObjT, class Method> |
| 715 inline void DispatchToMethod(ObjT* obj, | 774 inline void DispatchToMethod(ObjT* obj, |
| 716 Method method, | 775 Method method, |
| 717 const Tuple0& arg, Tuple0*) { | 776 const Tuple0& arg, Tuple0*) { |
| 718 (obj->*method)(); | 777 (obj->*method)(); |
| 719 } | 778 } |
| 720 | 779 |
| 721 template <class ObjT, class Method, class A> | 780 template <class ObjT, class Method, class A> |
| 722 inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) { | |
| 723 (obj->*method)(base::internal::UnwrapTraits<A>::Unwrap(arg)); | |
| 724 } | |
| 725 | |
| 726 template <class ObjT, class Method, class A> | |
| 727 inline void DispatchToMethod(ObjT* obj, | 781 inline void DispatchToMethod(ObjT* obj, |
| 728 Method method, | 782 Method method, |
| 729 const Tuple1<A>& arg, Tuple0*) { | 783 const Tuple1<A>& arg, Tuple0*) { |
| 730 (obj->*method)(base::internal::UnwrapTraits<A>::Unwrap(arg.a)); | 784 (obj->*method)(base::internal::UnwrapTraits<A>::Unwrap(arg.a)); |
| 731 } | 785 } |
| 732 | 786 |
| 733 template<class ObjT, class Method, class A, class B> | 787 template<class ObjT, class Method, class A, class B> |
| 734 inline void DispatchToMethod(ObjT* obj, | 788 inline void DispatchToMethod(ObjT* obj, |
| 735 Method method, | 789 Method method, |
| 736 const Tuple2<A, B>& arg, Tuple0*) { | 790 const Tuple2<A, B>& arg, Tuple0*) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 class OutA> | 837 class OutA> |
| 784 inline void DispatchToMethod(ObjT* obj, Method method, | 838 inline void DispatchToMethod(ObjT* obj, Method method, |
| 785 const Tuple0& in, | 839 const Tuple0& in, |
| 786 Tuple1<OutA>* out) { | 840 Tuple1<OutA>* out) { |
| 787 (obj->*method)(&out->a); | 841 (obj->*method)(&out->a); |
| 788 } | 842 } |
| 789 | 843 |
| 790 template<class ObjT, class Method, class InA, | 844 template<class ObjT, class Method, class InA, |
| 791 class OutA> | 845 class OutA> |
| 792 inline void DispatchToMethod(ObjT* obj, Method method, | 846 inline void DispatchToMethod(ObjT* obj, Method method, |
| 793 const InA& in, | |
| 794 Tuple1<OutA>* out) { | |
| 795 (obj->*method)(in, &out->a); | |
| 796 } | |
| 797 | |
| 798 template<class ObjT, class Method, class InA, | |
| 799 class OutA> | |
| 800 inline void DispatchToMethod(ObjT* obj, Method method, | |
| 801 const Tuple1<InA>& in, | 847 const Tuple1<InA>& in, |
| 802 Tuple1<OutA>* out) { | 848 Tuple1<OutA>* out) { |
| 803 (obj->*method)(base::internal::UnwrapTraits<InA>::Unwrap(in.a), &out->a); | 849 (obj->*method)(base::internal::UnwrapTraits<InA>::Unwrap(in.a), &out->a); |
| 804 } | 850 } |
| 805 | 851 |
| 806 template<class ObjT, class Method, class InA, class InB, | 852 template<class ObjT, class Method, class InA, class InB, |
| 807 class OutA> | 853 class OutA> |
| 808 inline void DispatchToMethod(ObjT* obj, Method method, | 854 inline void DispatchToMethod(ObjT* obj, Method method, |
| 809 const Tuple2<InA, InB>& in, | 855 const Tuple2<InA, InB>& in, |
| 810 Tuple1<OutA>* out) { | 856 Tuple1<OutA>* out) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 class OutA, class OutB> | 916 class OutA, class OutB> |
| 871 inline void DispatchToMethod(ObjT* obj, Method method, | 917 inline void DispatchToMethod(ObjT* obj, Method method, |
| 872 const Tuple0& in, | 918 const Tuple0& in, |
| 873 Tuple2<OutA, OutB>* out) { | 919 Tuple2<OutA, OutB>* out) { |
| 874 (obj->*method)(&out->a, &out->b); | 920 (obj->*method)(&out->a, &out->b); |
| 875 } | 921 } |
| 876 | 922 |
| 877 template<class ObjT, class Method, class InA, | 923 template<class ObjT, class Method, class InA, |
| 878 class OutA, class OutB> | 924 class OutA, class OutB> |
| 879 inline void DispatchToMethod(ObjT* obj, Method method, | 925 inline void DispatchToMethod(ObjT* obj, Method method, |
| 880 const InA& in, | |
| 881 Tuple2<OutA, OutB>* out) { | |
| 882 (obj->*method)(in, &out->a, &out->b); | |
| 883 } | |
| 884 | |
| 885 template<class ObjT, class Method, class InA, | |
| 886 class OutA, class OutB> | |
| 887 inline void DispatchToMethod(ObjT* obj, Method method, | |
| 888 const Tuple1<InA>& in, | 926 const Tuple1<InA>& in, |
| 889 Tuple2<OutA, OutB>* out) { | 927 Tuple2<OutA, OutB>* out) { |
| 890 (obj->*method)( | 928 (obj->*method)( |
| 891 base::internal::UnwrapTraits<InA>::Unwrap(in.a), &out->a, &out->b); | 929 base::internal::UnwrapTraits<InA>::Unwrap(in.a), &out->a, &out->b); |
| 892 } | 930 } |
| 893 | 931 |
| 894 template<class ObjT, class Method, class InA, class InB, | 932 template<class ObjT, class Method, class InA, class InB, |
| 895 class OutA, class OutB> | 933 class OutA, class OutB> |
| 896 inline void DispatchToMethod(ObjT* obj, Method method, | 934 inline void DispatchToMethod(ObjT* obj, Method method, |
| 897 const Tuple2<InA, InB>& in, | 935 const Tuple2<InA, InB>& in, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 class OutA, class OutB, class OutC> | 1002 class OutA, class OutB, class OutC> |
| 965 inline void DispatchToMethod(ObjT* obj, Method method, | 1003 inline void DispatchToMethod(ObjT* obj, Method method, |
| 966 const Tuple0& in, | 1004 const Tuple0& in, |
| 967 Tuple3<OutA, OutB, OutC>* out) { | 1005 Tuple3<OutA, OutB, OutC>* out) { |
| 968 (obj->*method)(&out->a, &out->b, &out->c); | 1006 (obj->*method)(&out->a, &out->b, &out->c); |
| 969 } | 1007 } |
| 970 | 1008 |
| 971 template<class ObjT, class Method, class InA, | 1009 template<class ObjT, class Method, class InA, |
| 972 class OutA, class OutB, class OutC> | 1010 class OutA, class OutB, class OutC> |
| 973 inline void DispatchToMethod(ObjT* obj, Method method, | 1011 inline void DispatchToMethod(ObjT* obj, Method method, |
| 974 const InA& in, | |
| 975 Tuple3<OutA, OutB, OutC>* out) { | |
| 976 (obj->*method)(in, &out->a, &out->b, &out->c); | |
| 977 } | |
| 978 | |
| 979 template<class ObjT, class Method, class InA, | |
| 980 class OutA, class OutB, class OutC> | |
| 981 inline void DispatchToMethod(ObjT* obj, Method method, | |
| 982 const Tuple1<InA>& in, | 1012 const Tuple1<InA>& in, |
| 983 Tuple3<OutA, OutB, OutC>* out) { | 1013 Tuple3<OutA, OutB, OutC>* out) { |
| 984 (obj->*method)(base::internal::UnwrapTraits<InA>::Unwrap(in.a), | 1014 (obj->*method)(base::internal::UnwrapTraits<InA>::Unwrap(in.a), |
| 985 &out->a, | 1015 &out->a, |
| 986 &out->b, | 1016 &out->b, |
| 987 &out->c); | 1017 &out->c); |
| 988 } | 1018 } |
| 989 | 1019 |
| 990 template<class ObjT, class Method, class InA, class InB, | 1020 template<class ObjT, class Method, class InA, class InB, |
| 991 class OutA, class OutB, class OutC> | 1021 class OutA, class OutB, class OutC> |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 class OutA, class OutB, class OutC, class OutD> | 1095 class OutA, class OutB, class OutC, class OutD> |
| 1066 inline void DispatchToMethod(ObjT* obj, Method method, | 1096 inline void DispatchToMethod(ObjT* obj, Method method, |
| 1067 const Tuple0& in, | 1097 const Tuple0& in, |
| 1068 Tuple4<OutA, OutB, OutC, OutD>* out) { | 1098 Tuple4<OutA, OutB, OutC, OutD>* out) { |
| 1069 (obj->*method)(&out->a, &out->b, &out->c, &out->d); | 1099 (obj->*method)(&out->a, &out->b, &out->c, &out->d); |
| 1070 } | 1100 } |
| 1071 | 1101 |
| 1072 template<class ObjT, class Method, class InA, | 1102 template<class ObjT, class Method, class InA, |
| 1073 class OutA, class OutB, class OutC, class OutD> | 1103 class OutA, class OutB, class OutC, class OutD> |
| 1074 inline void DispatchToMethod(ObjT* obj, Method method, | 1104 inline void DispatchToMethod(ObjT* obj, Method method, |
| 1075 const InA& in, | |
| 1076 Tuple4<OutA, OutB, OutC, OutD>* out) { | |
| 1077 (obj->*method)(base::internal::UnwrapTraits<InA>::Unwrap(in), | |
| 1078 &out->a, | |
| 1079 &out->b, | |
| 1080 &out->c, | |
| 1081 &out->d); | |
| 1082 } | |
| 1083 | |
| 1084 template<class ObjT, class Method, class InA, | |
| 1085 class OutA, class OutB, class OutC, class OutD> | |
| 1086 inline void DispatchToMethod(ObjT* obj, Method method, | |
| 1087 const Tuple1<InA>& in, | 1105 const Tuple1<InA>& in, |
| 1088 Tuple4<OutA, OutB, OutC, OutD>* out) { | 1106 Tuple4<OutA, OutB, OutC, OutD>* out) { |
| 1089 (obj->*method)(base::internal::UnwrapTraits<InA>::Unwrap(in.a), | 1107 (obj->*method)(base::internal::UnwrapTraits<InA>::Unwrap(in.a), |
| 1090 &out->a, | 1108 &out->a, |
| 1091 &out->b, | 1109 &out->b, |
| 1092 &out->c, | 1110 &out->c, |
| 1093 &out->d); | 1111 &out->d); |
| 1094 } | 1112 } |
| 1095 | 1113 |
| 1096 template<class ObjT, class Method, class InA, class InB, | 1114 template<class ObjT, class Method, class InA, class InB, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 class OutA, class OutB, class OutC, class OutD, class OutE> | 1194 class OutA, class OutB, class OutC, class OutD, class OutE> |
| 1177 inline void DispatchToMethod(ObjT* obj, Method method, | 1195 inline void DispatchToMethod(ObjT* obj, Method method, |
| 1178 const Tuple0& in, | 1196 const Tuple0& in, |
| 1179 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { | 1197 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { |
| 1180 (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e); | 1198 (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e); |
| 1181 } | 1199 } |
| 1182 | 1200 |
| 1183 template<class ObjT, class Method, class InA, | 1201 template<class ObjT, class Method, class InA, |
| 1184 class OutA, class OutB, class OutC, class OutD, class OutE> | 1202 class OutA, class OutB, class OutC, class OutD, class OutE> |
| 1185 inline void DispatchToMethod(ObjT* obj, Method method, | 1203 inline void DispatchToMethod(ObjT* obj, Method method, |
| 1186 const InA& in, | |
| 1187 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { | |
| 1188 (obj->*method)(base::internal::UnwrapTraits<InA>::Unwrap(in), | |
| 1189 &out->a, | |
| 1190 &out->b, | |
| 1191 &out->c, | |
| 1192 &out->d, | |
| 1193 &out->e); | |
| 1194 } | |
| 1195 | |
| 1196 template<class ObjT, class Method, class InA, | |
| 1197 class OutA, class OutB, class OutC, class OutD, class OutE> | |
| 1198 inline void DispatchToMethod(ObjT* obj, Method method, | |
| 1199 const Tuple1<InA>& in, | 1204 const Tuple1<InA>& in, |
| 1200 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { | 1205 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { |
| 1201 (obj->*method)(base::internal::UnwrapTraits<InA>::Unwrap(in.a), | 1206 (obj->*method)(base::internal::UnwrapTraits<InA>::Unwrap(in.a), |
| 1202 &out->a, | 1207 &out->a, |
| 1203 &out->b, | 1208 &out->b, |
| 1204 &out->c, | 1209 &out->c, |
| 1205 &out->d, | 1210 &out->d, |
| 1206 &out->e); | 1211 &out->e); |
| 1207 } | 1212 } |
| 1208 | 1213 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1282 base::internal::UnwrapTraits<InE>::Unwrap(in.e), | 1287 base::internal::UnwrapTraits<InE>::Unwrap(in.e), |
| 1283 base::internal::UnwrapTraits<InF>::Unwrap(in.f), | 1288 base::internal::UnwrapTraits<InF>::Unwrap(in.f), |
| 1284 &out->a, | 1289 &out->a, |
| 1285 &out->b, | 1290 &out->b, |
| 1286 &out->c, | 1291 &out->c, |
| 1287 &out->d, | 1292 &out->d, |
| 1288 &out->e); | 1293 &out->e); |
| 1289 } | 1294 } |
| 1290 | 1295 |
| 1291 #endif // BASE_TUPLE_H__ | 1296 #endif // BASE_TUPLE_H__ |
| OLD | NEW |