Revert "Revert "Revert 198403 "Move WrappedTexImage functionality to ui/gl"""
[chromium-blink-merge.git] / base / tuple.h
blob04809d9bdb096112966a6e7e8fba0145367d2197
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
3 // found in the LICENSE file.
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
7 // it contains. The convenient MakeTuple() function takes 0 to 6 arguments,
8 // and will construct and return the appropriate Tuple object. The functions
9 // DispatchToMethod and DispatchToFunction take a function pointer or instance
10 // and method pointer, and unpack a tuple into arguments to the call.
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.
15 // Example usage:
16 // // These two methods of creating a Tuple are identical.
17 // Tuple2<int, const char*> tuple_a(1, "wee");
18 // Tuple2<int, const char*> tuple_b = MakeTuple(1, "wee");
20 // void SomeFunc(int a, const char* b) { }
21 // DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee")
22 // DispatchToFunction(
23 // &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo")
25 // struct { void SomeMeth(int a, int b, int c) { } } foo;
26 // DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3));
27 // // foo->SomeMeth(1, 2, 3);
29 #ifndef BASE_TUPLE_H__
30 #define BASE_TUPLE_H__
32 // Traits ----------------------------------------------------------------------
34 // A simple traits class for tuple arguments.
36 // ValueType: the bare, nonref version of a type (same as the type for nonrefs).
37 // RefType: the ref version of a type (same as the type for refs).
38 // ParamType: what type to pass to functions (refs should not be constified).
40 template <class P>
41 struct TupleTraits {
42 typedef P ValueType;
43 typedef P& RefType;
44 typedef const P& ParamType;
47 template <class P>
48 struct TupleTraits<P&> {
49 typedef P ValueType;
50 typedef P& RefType;
51 typedef P& ParamType;
54 template <class P>
55 struct TupleTypes { };
57 // Tuple -----------------------------------------------------------------------
59 // This set of classes is useful for bundling 0 or more heterogeneous data types
60 // into a single variable. The advantage of this is that it greatly simplifies
61 // function objects that need to take an arbitrary number of parameters; see
62 // RunnableMethod and IPC::MessageWithTuple.
64 // Tuple0 is supplied to act as a 'void' type. It can be used, for example,
65 // when dispatching to a function that accepts no arguments (see the
66 // Dispatchers below).
67 // Tuple1<A> is rarely useful. One such use is when A is non-const ref that you
68 // want filled by the dispatchee, and the tuple is merely a container for that
69 // output (a "tier"). See MakeRefTuple and its usages.
71 struct Tuple0 {
72 typedef Tuple0 ValueTuple;
73 typedef Tuple0 RefTuple;
74 typedef Tuple0 ParamTuple;
77 template <class A>
78 struct Tuple1 {
79 public:
80 typedef A TypeA;
82 Tuple1() {}
83 explicit Tuple1(typename TupleTraits<A>::ParamType a) : a(a) {}
85 A a;
88 template <class A, class B>
89 struct Tuple2 {
90 public:
91 typedef A TypeA;
92 typedef B TypeB;
94 Tuple2() {}
95 Tuple2(typename TupleTraits<A>::ParamType a,
96 typename TupleTraits<B>::ParamType b)
97 : a(a), b(b) {
100 A a;
101 B b;
104 template <class A, class B, class C>
105 struct Tuple3 {
106 public:
107 typedef A TypeA;
108 typedef B TypeB;
109 typedef C TypeC;
111 Tuple3() {}
112 Tuple3(typename TupleTraits<A>::ParamType a,
113 typename TupleTraits<B>::ParamType b,
114 typename TupleTraits<C>::ParamType c)
115 : a(a), b(b), c(c){
118 A a;
119 B b;
120 C c;
123 template <class A, class B, class C, class D>
124 struct Tuple4 {
125 public:
126 typedef A TypeA;
127 typedef B TypeB;
128 typedef C TypeC;
129 typedef D TypeD;
131 Tuple4() {}
132 Tuple4(typename TupleTraits<A>::ParamType a,
133 typename TupleTraits<B>::ParamType b,
134 typename TupleTraits<C>::ParamType c,
135 typename TupleTraits<D>::ParamType d)
136 : a(a), b(b), c(c), d(d) {
139 A a;
140 B b;
141 C c;
142 D d;
145 template <class A, class B, class C, class D, class E>
146 struct Tuple5 {
147 public:
148 typedef A TypeA;
149 typedef B TypeB;
150 typedef C TypeC;
151 typedef D TypeD;
152 typedef E TypeE;
154 Tuple5() {}
155 Tuple5(typename TupleTraits<A>::ParamType a,
156 typename TupleTraits<B>::ParamType b,
157 typename TupleTraits<C>::ParamType c,
158 typename TupleTraits<D>::ParamType d,
159 typename TupleTraits<E>::ParamType e)
160 : a(a), b(b), c(c), d(d), e(e) {
163 A a;
164 B b;
165 C c;
166 D d;
167 E e;
170 template <class A, class B, class C, class D, class E, class F>
171 struct Tuple6 {
172 public:
173 typedef A TypeA;
174 typedef B TypeB;
175 typedef C TypeC;
176 typedef D TypeD;
177 typedef E TypeE;
178 typedef F TypeF;
180 Tuple6() {}
181 Tuple6(typename TupleTraits<A>::ParamType a,
182 typename TupleTraits<B>::ParamType b,
183 typename TupleTraits<C>::ParamType c,
184 typename TupleTraits<D>::ParamType d,
185 typename TupleTraits<E>::ParamType e,
186 typename TupleTraits<F>::ParamType f)
187 : a(a), b(b), c(c), d(d), e(e), f(f) {
190 A a;
191 B b;
192 C c;
193 D d;
194 E e;
195 F f;
198 template <class A, class B, class C, class D, class E, class F, class G>
199 struct Tuple7 {
200 public:
201 typedef A TypeA;
202 typedef B TypeB;
203 typedef C TypeC;
204 typedef D TypeD;
205 typedef E TypeE;
206 typedef F TypeF;
207 typedef G TypeG;
209 Tuple7() {}
210 Tuple7(typename TupleTraits<A>::ParamType a,
211 typename TupleTraits<B>::ParamType b,
212 typename TupleTraits<C>::ParamType c,
213 typename TupleTraits<D>::ParamType d,
214 typename TupleTraits<E>::ParamType e,
215 typename TupleTraits<F>::ParamType f,
216 typename TupleTraits<G>::ParamType g)
217 : a(a), b(b), c(c), d(d), e(e), f(f), g(g) {
220 A a;
221 B b;
222 C c;
223 D d;
224 E e;
225 F f;
226 G g;
229 template <class A, class B, class C, class D, class E, class F, class G,
230 class H>
231 struct Tuple8 {
232 public:
233 typedef A TypeA;
234 typedef B TypeB;
235 typedef C TypeC;
236 typedef D TypeD;
237 typedef E TypeE;
238 typedef F TypeF;
239 typedef G TypeG;
240 typedef H TypeH;
242 Tuple8() {}
243 Tuple8(typename TupleTraits<A>::ParamType a,
244 typename TupleTraits<B>::ParamType b,
245 typename TupleTraits<C>::ParamType c,
246 typename TupleTraits<D>::ParamType d,
247 typename TupleTraits<E>::ParamType e,
248 typename TupleTraits<F>::ParamType f,
249 typename TupleTraits<G>::ParamType g,
250 typename TupleTraits<H>::ParamType h)
251 : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) {
254 A a;
255 B b;
256 C c;
257 D d;
258 E e;
259 F f;
260 G g;
261 H h;
264 // Tuple types ----------------------------------------------------------------
266 // Allows for selection of ValueTuple/RefTuple/ParamTuple without needing the
267 // definitions of class types the tuple takes as parameters.
269 template <>
270 struct TupleTypes< Tuple0 > {
271 typedef Tuple0 ValueTuple;
272 typedef Tuple0 RefTuple;
273 typedef Tuple0 ParamTuple;
276 template <class A>
277 struct TupleTypes< Tuple1<A> > {
278 typedef Tuple1<typename TupleTraits<A>::ValueType> ValueTuple;
279 typedef Tuple1<typename TupleTraits<A>::RefType> RefTuple;
280 typedef Tuple1<typename TupleTraits<A>::ParamType> ParamTuple;
283 template <class A, class B>
284 struct TupleTypes< Tuple2<A, B> > {
285 typedef Tuple2<typename TupleTraits<A>::ValueType,
286 typename TupleTraits<B>::ValueType> ValueTuple;
287 typedef Tuple2<typename TupleTraits<A>::RefType,
288 typename TupleTraits<B>::RefType> RefTuple;
289 typedef Tuple2<typename TupleTraits<A>::ParamType,
290 typename TupleTraits<B>::ParamType> ParamTuple;
293 template <class A, class B, class C>
294 struct TupleTypes< Tuple3<A, B, C> > {
295 typedef Tuple3<typename TupleTraits<A>::ValueType,
296 typename TupleTraits<B>::ValueType,
297 typename TupleTraits<C>::ValueType> ValueTuple;
298 typedef Tuple3<typename TupleTraits<A>::RefType,
299 typename TupleTraits<B>::RefType,
300 typename TupleTraits<C>::RefType> RefTuple;
301 typedef Tuple3<typename TupleTraits<A>::ParamType,
302 typename TupleTraits<B>::ParamType,
303 typename TupleTraits<C>::ParamType> ParamTuple;
306 template <class A, class B, class C, class D>
307 struct TupleTypes< Tuple4<A, B, C, D> > {
308 typedef Tuple4<typename TupleTraits<A>::ValueType,
309 typename TupleTraits<B>::ValueType,
310 typename TupleTraits<C>::ValueType,
311 typename TupleTraits<D>::ValueType> ValueTuple;
312 typedef Tuple4<typename TupleTraits<A>::RefType,
313 typename TupleTraits<B>::RefType,
314 typename TupleTraits<C>::RefType,
315 typename TupleTraits<D>::RefType> RefTuple;
316 typedef Tuple4<typename TupleTraits<A>::ParamType,
317 typename TupleTraits<B>::ParamType,
318 typename TupleTraits<C>::ParamType,
319 typename TupleTraits<D>::ParamType> ParamTuple;
322 template <class A, class B, class C, class D, class E>
323 struct TupleTypes< Tuple5<A, B, C, D, E> > {
324 typedef Tuple5<typename TupleTraits<A>::ValueType,
325 typename TupleTraits<B>::ValueType,
326 typename TupleTraits<C>::ValueType,
327 typename TupleTraits<D>::ValueType,
328 typename TupleTraits<E>::ValueType> ValueTuple;
329 typedef Tuple5<typename TupleTraits<A>::RefType,
330 typename TupleTraits<B>::RefType,
331 typename TupleTraits<C>::RefType,
332 typename TupleTraits<D>::RefType,
333 typename TupleTraits<E>::RefType> RefTuple;
334 typedef Tuple5<typename TupleTraits<A>::ParamType,
335 typename TupleTraits<B>::ParamType,
336 typename TupleTraits<C>::ParamType,
337 typename TupleTraits<D>::ParamType,
338 typename TupleTraits<E>::ParamType> ParamTuple;
341 template <class A, class B, class C, class D, class E, class F>
342 struct TupleTypes< Tuple6<A, B, C, D, E, F> > {
343 typedef Tuple6<typename TupleTraits<A>::ValueType,
344 typename TupleTraits<B>::ValueType,
345 typename TupleTraits<C>::ValueType,
346 typename TupleTraits<D>::ValueType,
347 typename TupleTraits<E>::ValueType,
348 typename TupleTraits<F>::ValueType> ValueTuple;
349 typedef Tuple6<typename TupleTraits<A>::RefType,
350 typename TupleTraits<B>::RefType,
351 typename TupleTraits<C>::RefType,
352 typename TupleTraits<D>::RefType,
353 typename TupleTraits<E>::RefType,
354 typename TupleTraits<F>::RefType> RefTuple;
355 typedef Tuple6<typename TupleTraits<A>::ParamType,
356 typename TupleTraits<B>::ParamType,
357 typename TupleTraits<C>::ParamType,
358 typename TupleTraits<D>::ParamType,
359 typename TupleTraits<E>::ParamType,
360 typename TupleTraits<F>::ParamType> ParamTuple;
363 template <class A, class B, class C, class D, class E, class F, class G>
364 struct TupleTypes< Tuple7<A, B, C, D, E, F, G> > {
365 typedef Tuple7<typename TupleTraits<A>::ValueType,
366 typename TupleTraits<B>::ValueType,
367 typename TupleTraits<C>::ValueType,
368 typename TupleTraits<D>::ValueType,
369 typename TupleTraits<E>::ValueType,
370 typename TupleTraits<F>::ValueType,
371 typename TupleTraits<G>::ValueType> ValueTuple;
372 typedef Tuple7<typename TupleTraits<A>::RefType,
373 typename TupleTraits<B>::RefType,
374 typename TupleTraits<C>::RefType,
375 typename TupleTraits<D>::RefType,
376 typename TupleTraits<E>::RefType,
377 typename TupleTraits<F>::RefType,
378 typename TupleTraits<G>::RefType> RefTuple;
379 typedef Tuple7<typename TupleTraits<A>::ParamType,
380 typename TupleTraits<B>::ParamType,
381 typename TupleTraits<C>::ParamType,
382 typename TupleTraits<D>::ParamType,
383 typename TupleTraits<E>::ParamType,
384 typename TupleTraits<F>::ParamType,
385 typename TupleTraits<G>::ParamType> ParamTuple;
388 template <class A, class B, class C, class D, class E, class F, class G,
389 class H>
390 struct TupleTypes< Tuple8<A, B, C, D, E, F, G, H> > {
391 typedef Tuple8<typename TupleTraits<A>::ValueType,
392 typename TupleTraits<B>::ValueType,
393 typename TupleTraits<C>::ValueType,
394 typename TupleTraits<D>::ValueType,
395 typename TupleTraits<E>::ValueType,
396 typename TupleTraits<F>::ValueType,
397 typename TupleTraits<G>::ValueType,
398 typename TupleTraits<H>::ValueType> ValueTuple;
399 typedef Tuple8<typename TupleTraits<A>::RefType,
400 typename TupleTraits<B>::RefType,
401 typename TupleTraits<C>::RefType,
402 typename TupleTraits<D>::RefType,
403 typename TupleTraits<E>::RefType,
404 typename TupleTraits<F>::RefType,
405 typename TupleTraits<G>::RefType,
406 typename TupleTraits<H>::RefType> RefTuple;
407 typedef Tuple8<typename TupleTraits<A>::ParamType,
408 typename TupleTraits<B>::ParamType,
409 typename TupleTraits<C>::ParamType,
410 typename TupleTraits<D>::ParamType,
411 typename TupleTraits<E>::ParamType,
412 typename TupleTraits<F>::ParamType,
413 typename TupleTraits<G>::ParamType,
414 typename TupleTraits<H>::ParamType> ParamTuple;
417 // Tuple creators -------------------------------------------------------------
419 // Helper functions for constructing tuples while inferring the template
420 // argument types.
422 inline Tuple0 MakeTuple() {
423 return Tuple0();
426 template <class A>
427 inline Tuple1<A> MakeTuple(const A& a) {
428 return Tuple1<A>(a);
431 template <class A, class B>
432 inline Tuple2<A, B> MakeTuple(const A& a, const B& b) {
433 return Tuple2<A, B>(a, b);
436 template <class A, class B, class C>
437 inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c) {
438 return Tuple3<A, B, C>(a, b, c);
441 template <class A, class B, class C, class D>
442 inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c,
443 const D& d) {
444 return Tuple4<A, B, C, D>(a, b, c, d);
447 template <class A, class B, class C, class D, class E>
448 inline Tuple5<A, B, C, D, E> MakeTuple(const A& a, const B& b, const C& c,
449 const D& d, const E& e) {
450 return Tuple5<A, B, C, D, E>(a, b, c, d, e);
453 template <class A, class B, class C, class D, class E, class F>
454 inline Tuple6<A, B, C, D, E, F> MakeTuple(const A& a, const B& b, const C& c,
455 const D& d, const E& e, const F& f) {
456 return Tuple6<A, B, C, D, E, F>(a, b, c, d, e, f);
459 template <class A, class B, class C, class D, class E, class F, class G>
460 inline Tuple7<A, B, C, D, E, F, G> MakeTuple(const A& a, const B& b, const C& c,
461 const D& d, const E& e, const F& f,
462 const G& g) {
463 return Tuple7<A, B, C, D, E, F, G>(a, b, c, d, e, f, g);
466 template <class A, class B, class C, class D, class E, class F, class G,
467 class H>
468 inline Tuple8<A, B, C, D, E, F, G, H> MakeTuple(const A& a, const B& b,
469 const C& c, const D& d,
470 const E& e, const F& f,
471 const G& g, const H& h) {
472 return Tuple8<A, B, C, D, E, F, G, H>(a, b, c, d, e, f, g, h);
475 // The following set of helpers make what Boost refers to as "Tiers" - a tuple
476 // of references.
478 template <class A>
479 inline Tuple1<A&> MakeRefTuple(A& a) {
480 return Tuple1<A&>(a);
483 template <class A, class B>
484 inline Tuple2<A&, B&> MakeRefTuple(A& a, B& b) {
485 return Tuple2<A&, B&>(a, b);
488 template <class A, class B, class C>
489 inline Tuple3<A&, B&, C&> MakeRefTuple(A& a, B& b, C& c) {
490 return Tuple3<A&, B&, C&>(a, b, c);
493 template <class A, class B, class C, class D>
494 inline Tuple4<A&, B&, C&, D&> MakeRefTuple(A& a, B& b, C& c, D& d) {
495 return Tuple4<A&, B&, C&, D&>(a, b, c, d);
498 template <class A, class B, class C, class D, class E>
499 inline Tuple5<A&, B&, C&, D&, E&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e) {
500 return Tuple5<A&, B&, C&, D&, E&>(a, b, c, d, e);
503 template <class A, class B, class C, class D, class E, class F>
504 inline Tuple6<A&, B&, C&, D&, E&, F&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e,
505 F& f) {
506 return Tuple6<A&, B&, C&, D&, E&, F&>(a, b, c, d, e, f);
509 template <class A, class B, class C, class D, class E, class F, class G>
510 inline Tuple7<A&, B&, C&, D&, E&, F&, G&> MakeRefTuple(A& a, B& b, C& c, D& d,
511 E& e, F& f, G& g) {
512 return Tuple7<A&, B&, C&, D&, E&, F&, G&>(a, b, c, d, e, f, g);
515 template <class A, class B, class C, class D, class E, class F, class G,
516 class H>
517 inline Tuple8<A&, B&, C&, D&, E&, F&, G&, H&> MakeRefTuple(A& a, B& b, C& c,
518 D& d, E& e, F& f,
519 G& g, H& h) {
520 return Tuple8<A&, B&, C&, D&, E&, F&, G&, H&>(a, b, c, d, e, f, g, h);
523 // Dispatchers ----------------------------------------------------------------
525 // Helper functions that call the given method on an object, with the unpacked
526 // tuple arguments. Notice that they all have the same number of arguments,
527 // so you need only write:
528 // DispatchToMethod(object, &Object::method, args);
529 // This is very useful for templated dispatchers, since they don't need to know
530 // what type |args| is.
532 // Non-Static Dispatchers with no out params.
534 template <class ObjT, class Method>
535 inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) {
536 (obj->*method)();
539 template <class ObjT, class Method, class A>
540 inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) {
541 (obj->*method)(arg);
544 template <class ObjT, class Method, class A>
545 inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) {
546 (obj->*method)(arg.a);
549 template<class ObjT, class Method, class A, class B>
550 inline void DispatchToMethod(ObjT* obj,
551 Method method,
552 const Tuple2<A, B>& arg) {
553 (obj->*method)(arg.a, arg.b);
556 template<class ObjT, class Method, class A, class B, class C>
557 inline void DispatchToMethod(ObjT* obj, Method method,
558 const Tuple3<A, B, C>& arg) {
559 (obj->*method)(arg.a, arg.b, arg.c);
562 template<class ObjT, class Method, class A, class B, class C, class D>
563 inline void DispatchToMethod(ObjT* obj, Method method,
564 const Tuple4<A, B, C, D>& arg) {
565 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
568 template<class ObjT, class Method, class A, class B, class C, class D, class E>
569 inline void DispatchToMethod(ObjT* obj, Method method,
570 const Tuple5<A, B, C, D, E>& arg) {
571 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
574 template<class ObjT, class Method, class A, class B, class C, class D, class E,
575 class F>
576 inline void DispatchToMethod(ObjT* obj, Method method,
577 const Tuple6<A, B, C, D, E, F>& arg) {
578 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
581 template<class ObjT, class Method, class A, class B, class C, class D, class E,
582 class F, class G>
583 inline void DispatchToMethod(ObjT* obj, Method method,
584 const Tuple7<A, B, C, D, E, F, G>& arg) {
585 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g);
588 template<class ObjT, class Method, class A, class B, class C, class D, class E,
589 class F, class G, class H>
590 inline void DispatchToMethod(ObjT* obj, Method method,
591 const Tuple8<A, B, C, D, E, F, G, H>& arg) {
592 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g, arg.h);
595 // Static Dispatchers with no out params.
597 template <class Function>
598 inline void DispatchToFunction(Function function, const Tuple0& arg) {
599 (*function)();
602 template <class Function, class A>
603 inline void DispatchToFunction(Function function, const A& arg) {
604 (*function)(arg);
607 template <class Function, class A>
608 inline void DispatchToFunction(Function function, const Tuple1<A>& arg) {
609 (*function)(arg.a);
612 template<class Function, class A, class B>
613 inline void DispatchToFunction(Function function, const Tuple2<A, B>& arg) {
614 (*function)(arg.a, arg.b);
617 template<class Function, class A, class B, class C>
618 inline void DispatchToFunction(Function function, const Tuple3<A, B, C>& arg) {
619 (*function)(arg.a, arg.b, arg.c);
622 template<class Function, class A, class B, class C, class D>
623 inline void DispatchToFunction(Function function,
624 const Tuple4<A, B, C, D>& arg) {
625 (*function)(arg.a, arg.b, arg.c, arg.d);
628 template<class Function, class A, class B, class C, class D, class E>
629 inline void DispatchToFunction(Function function,
630 const Tuple5<A, B, C, D, E>& arg) {
631 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e);
634 template<class Function, class A, class B, class C, class D, class E, class F>
635 inline void DispatchToFunction(Function function,
636 const Tuple6<A, B, C, D, E, F>& arg) {
637 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
640 template<class Function, class A, class B, class C, class D, class E, class F,
641 class G>
642 inline void DispatchToFunction(Function function,
643 const Tuple7<A, B, C, D, E, F, G>& arg) {
644 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g);
647 template<class Function, class A, class B, class C, class D, class E, class F,
648 class G, class H>
649 inline void DispatchToFunction(Function function,
650 const Tuple8<A, B, C, D, E, F, G, H>& arg) {
651 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g, arg.h);
654 // Dispatchers with 0 out param (as a Tuple0).
656 template <class ObjT, class Method>
657 inline void DispatchToMethod(ObjT* obj,
658 Method method,
659 const Tuple0& arg, Tuple0*) {
660 (obj->*method)();
663 template <class ObjT, class Method, class A>
664 inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) {
665 (obj->*method)(arg);
668 template <class ObjT, class Method, class A>
669 inline void DispatchToMethod(ObjT* obj,
670 Method method,
671 const Tuple1<A>& arg, Tuple0*) {
672 (obj->*method)(arg.a);
675 template<class ObjT, class Method, class A, class B>
676 inline void DispatchToMethod(ObjT* obj,
677 Method method,
678 const Tuple2<A, B>& arg, Tuple0*) {
679 (obj->*method)(arg.a, arg.b);
682 template<class ObjT, class Method, class A, class B, class C>
683 inline void DispatchToMethod(ObjT* obj, Method method,
684 const Tuple3<A, B, C>& arg, Tuple0*) {
685 (obj->*method)(arg.a, arg.b, arg.c);
688 template<class ObjT, class Method, class A, class B, class C, class D>
689 inline void DispatchToMethod(ObjT* obj, Method method,
690 const Tuple4<A, B, C, D>& arg, Tuple0*) {
691 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
694 template<class ObjT, class Method, class A, class B, class C, class D, class E>
695 inline void DispatchToMethod(ObjT* obj, Method method,
696 const Tuple5<A, B, C, D, E>& arg, Tuple0*) {
697 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
700 template<class ObjT, class Method, class A, class B, class C, class D, class E,
701 class F>
702 inline void DispatchToMethod(ObjT* obj, Method method,
703 const Tuple6<A, B, C, D, E, F>& arg, Tuple0*) {
704 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
707 // Dispatchers with 1 out param.
709 template<class ObjT, class Method,
710 class OutA>
711 inline void DispatchToMethod(ObjT* obj, Method method,
712 const Tuple0& in,
713 Tuple1<OutA>* out) {
714 (obj->*method)(&out->a);
717 template<class ObjT, class Method, class InA,
718 class OutA>
719 inline void DispatchToMethod(ObjT* obj, Method method,
720 const InA& in,
721 Tuple1<OutA>* out) {
722 (obj->*method)(in, &out->a);
725 template<class ObjT, class Method, class InA,
726 class OutA>
727 inline void DispatchToMethod(ObjT* obj, Method method,
728 const Tuple1<InA>& in,
729 Tuple1<OutA>* out) {
730 (obj->*method)(in.a, &out->a);
733 template<class ObjT, class Method, class InA, class InB,
734 class OutA>
735 inline void DispatchToMethod(ObjT* obj, Method method,
736 const Tuple2<InA, InB>& in,
737 Tuple1<OutA>* out) {
738 (obj->*method)(in.a, in.b, &out->a);
741 template<class ObjT, class Method, class InA, class InB, class InC,
742 class OutA>
743 inline void DispatchToMethod(ObjT* obj, Method method,
744 const Tuple3<InA, InB, InC>& in,
745 Tuple1<OutA>* out) {
746 (obj->*method)(in.a, in.b, in.c, &out->a);
749 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
750 class OutA>
751 inline void DispatchToMethod(ObjT* obj, Method method,
752 const Tuple4<InA, InB, InC, InD>& in,
753 Tuple1<OutA>* out) {
754 (obj->*method)(in.a, in.b, in.c, in.d, &out->a);
757 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
758 class InE, class OutA>
759 inline void DispatchToMethod(ObjT* obj, Method method,
760 const Tuple5<InA, InB, InC, InD, InE>& in,
761 Tuple1<OutA>* out) {
762 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a);
765 template<class ObjT, class Method,
766 class InA, class InB, class InC, class InD, class InE, class InF,
767 class OutA>
768 inline void DispatchToMethod(ObjT* obj, Method method,
769 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
770 Tuple1<OutA>* out) {
771 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a);
774 // Dispatchers with 2 out params.
776 template<class ObjT, class Method,
777 class OutA, class OutB>
778 inline void DispatchToMethod(ObjT* obj, Method method,
779 const Tuple0& in,
780 Tuple2<OutA, OutB>* out) {
781 (obj->*method)(&out->a, &out->b);
784 template<class ObjT, class Method, class InA,
785 class OutA, class OutB>
786 inline void DispatchToMethod(ObjT* obj, Method method,
787 const InA& in,
788 Tuple2<OutA, OutB>* out) {
789 (obj->*method)(in, &out->a, &out->b);
792 template<class ObjT, class Method, class InA,
793 class OutA, class OutB>
794 inline void DispatchToMethod(ObjT* obj, Method method,
795 const Tuple1<InA>& in,
796 Tuple2<OutA, OutB>* out) {
797 (obj->*method)(in.a, &out->a, &out->b);
800 template<class ObjT, class Method, class InA, class InB,
801 class OutA, class OutB>
802 inline void DispatchToMethod(ObjT* obj, Method method,
803 const Tuple2<InA, InB>& in,
804 Tuple2<OutA, OutB>* out) {
805 (obj->*method)(in.a, in.b, &out->a, &out->b);
808 template<class ObjT, class Method, class InA, class InB, class InC,
809 class OutA, class OutB>
810 inline void DispatchToMethod(ObjT* obj, Method method,
811 const Tuple3<InA, InB, InC>& in,
812 Tuple2<OutA, OutB>* out) {
813 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b);
816 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
817 class OutA, class OutB>
818 inline void DispatchToMethod(ObjT* obj, Method method,
819 const Tuple4<InA, InB, InC, InD>& in,
820 Tuple2<OutA, OutB>* out) {
821 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b);
824 template<class ObjT, class Method,
825 class InA, class InB, class InC, class InD, class InE,
826 class OutA, class OutB>
827 inline void DispatchToMethod(ObjT* obj, Method method,
828 const Tuple5<InA, InB, InC, InD, InE>& in,
829 Tuple2<OutA, OutB>* out) {
830 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b);
833 template<class ObjT, class Method,
834 class InA, class InB, class InC, class InD, class InE, class InF,
835 class OutA, class OutB>
836 inline void DispatchToMethod(ObjT* obj, Method method,
837 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
838 Tuple2<OutA, OutB>* out) {
839 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b);
842 // Dispatchers with 3 out params.
844 template<class ObjT, class Method,
845 class OutA, class OutB, class OutC>
846 inline void DispatchToMethod(ObjT* obj, Method method,
847 const Tuple0& in,
848 Tuple3<OutA, OutB, OutC>* out) {
849 (obj->*method)(&out->a, &out->b, &out->c);
852 template<class ObjT, class Method, class InA,
853 class OutA, class OutB, class OutC>
854 inline void DispatchToMethod(ObjT* obj, Method method,
855 const InA& in,
856 Tuple3<OutA, OutB, OutC>* out) {
857 (obj->*method)(in, &out->a, &out->b, &out->c);
860 template<class ObjT, class Method, class InA,
861 class OutA, class OutB, class OutC>
862 inline void DispatchToMethod(ObjT* obj, Method method,
863 const Tuple1<InA>& in,
864 Tuple3<OutA, OutB, OutC>* out) {
865 (obj->*method)(in.a, &out->a, &out->b, &out->c);
868 template<class ObjT, class Method, class InA, class InB,
869 class OutA, class OutB, class OutC>
870 inline void DispatchToMethod(ObjT* obj, Method method,
871 const Tuple2<InA, InB>& in,
872 Tuple3<OutA, OutB, OutC>* out) {
873 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c);
876 template<class ObjT, class Method, class InA, class InB, class InC,
877 class OutA, class OutB, class OutC>
878 inline void DispatchToMethod(ObjT* obj, Method method,
879 const Tuple3<InA, InB, InC>& in,
880 Tuple3<OutA, OutB, OutC>* out) {
881 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c);
884 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
885 class OutA, class OutB, class OutC>
886 inline void DispatchToMethod(ObjT* obj, Method method,
887 const Tuple4<InA, InB, InC, InD>& in,
888 Tuple3<OutA, OutB, OutC>* out) {
889 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c);
892 template<class ObjT, class Method,
893 class InA, class InB, class InC, class InD, class InE,
894 class OutA, class OutB, class OutC>
895 inline void DispatchToMethod(ObjT* obj, Method method,
896 const Tuple5<InA, InB, InC, InD, InE>& in,
897 Tuple3<OutA, OutB, OutC>* out) {
898 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c);
901 template<class ObjT, class Method,
902 class InA, class InB, class InC, class InD, class InE, class InF,
903 class OutA, class OutB, class OutC>
904 inline void DispatchToMethod(ObjT* obj, Method method,
905 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
906 Tuple3<OutA, OutB, OutC>* out) {
907 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b, &out->c);
910 // Dispatchers with 4 out params.
912 template<class ObjT, class Method,
913 class OutA, class OutB, class OutC, class OutD>
914 inline void DispatchToMethod(ObjT* obj, Method method,
915 const Tuple0& in,
916 Tuple4<OutA, OutB, OutC, OutD>* out) {
917 (obj->*method)(&out->a, &out->b, &out->c, &out->d);
920 template<class ObjT, class Method, class InA,
921 class OutA, class OutB, class OutC, class OutD>
922 inline void DispatchToMethod(ObjT* obj, Method method,
923 const InA& in,
924 Tuple4<OutA, OutB, OutC, OutD>* out) {
925 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d);
928 template<class ObjT, class Method, class InA,
929 class OutA, class OutB, class OutC, class OutD>
930 inline void DispatchToMethod(ObjT* obj, Method method,
931 const Tuple1<InA>& in,
932 Tuple4<OutA, OutB, OutC, OutD>* out) {
933 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d);
936 template<class ObjT, class Method, class InA, class InB,
937 class OutA, class OutB, class OutC, class OutD>
938 inline void DispatchToMethod(ObjT* obj, Method method,
939 const Tuple2<InA, InB>& in,
940 Tuple4<OutA, OutB, OutC, OutD>* out) {
941 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d);
944 template<class ObjT, class Method, class InA, class InB, class InC,
945 class OutA, class OutB, class OutC, class OutD>
946 inline void DispatchToMethod(ObjT* obj, Method method,
947 const Tuple3<InA, InB, InC>& in,
948 Tuple4<OutA, OutB, OutC, OutD>* out) {
949 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d);
952 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
953 class OutA, class OutB, class OutC, class OutD>
954 inline void DispatchToMethod(ObjT* obj, Method method,
955 const Tuple4<InA, InB, InC, InD>& in,
956 Tuple4<OutA, OutB, OutC, OutD>* out) {
957 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d);
960 template<class ObjT, class Method,
961 class InA, class InB, class InC, class InD, class InE,
962 class OutA, class OutB, class OutC, class OutD>
963 inline void DispatchToMethod(ObjT* obj, Method method,
964 const Tuple5<InA, InB, InC, InD, InE>& in,
965 Tuple4<OutA, OutB, OutC, OutD>* out) {
966 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
967 &out->a, &out->b, &out->c, &out->d);
970 template<class ObjT, class Method,
971 class InA, class InB, class InC, class InD, class InE, class InF,
972 class OutA, class OutB, class OutC, class OutD>
973 inline void DispatchToMethod(ObjT* obj, Method method,
974 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
975 Tuple4<OutA, OutB, OutC, OutD>* out) {
976 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f,
977 &out->a, &out->b, &out->c, &out->d);
980 // Dispatchers with 5 out params.
982 template<class ObjT, class Method,
983 class OutA, class OutB, class OutC, class OutD, class OutE>
984 inline void DispatchToMethod(ObjT* obj, Method method,
985 const Tuple0& in,
986 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
987 (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e);
990 template<class ObjT, class Method, class InA,
991 class OutA, class OutB, class OutC, class OutD, class OutE>
992 inline void DispatchToMethod(ObjT* obj, Method method,
993 const InA& in,
994 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
995 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d, &out->e);
998 template<class ObjT, class Method, class InA,
999 class OutA, class OutB, class OutC, class OutD, class OutE>
1000 inline void DispatchToMethod(ObjT* obj, Method method,
1001 const Tuple1<InA>& in,
1002 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1003 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d, &out->e);
1006 template<class ObjT, class Method, class InA, class InB,
1007 class OutA, class OutB, class OutC, class OutD, class OutE>
1008 inline void DispatchToMethod(ObjT* obj, Method method,
1009 const Tuple2<InA, InB>& in,
1010 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1011 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d, &out->e);
1014 template<class ObjT, class Method, class InA, class InB, class InC,
1015 class OutA, class OutB, class OutC, class OutD, class OutE>
1016 inline void DispatchToMethod(ObjT* obj, Method method,
1017 const Tuple3<InA, InB, InC>& in,
1018 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1019 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d, &out->e);
1022 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
1023 class OutA, class OutB, class OutC, class OutD, class OutE>
1024 inline void DispatchToMethod(ObjT* obj, Method method,
1025 const Tuple4<InA, InB, InC, InD>& in,
1026 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1027 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d,
1028 &out->e);
1031 template<class ObjT, class Method,
1032 class InA, class InB, class InC, class InD, class InE,
1033 class OutA, class OutB, class OutC, class OutD, class OutE>
1034 inline void DispatchToMethod(ObjT* obj, Method method,
1035 const Tuple5<InA, InB, InC, InD, InE>& in,
1036 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1037 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
1038 &out->a, &out->b, &out->c, &out->d, &out->e);
1041 template<class ObjT, class Method,
1042 class InA, class InB, class InC, class InD, class InE, class InF,
1043 class OutA, class OutB, class OutC, class OutD, class OutE>
1044 inline void DispatchToMethod(ObjT* obj, Method method,
1045 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
1046 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1047 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f,
1048 &out->a, &out->b, &out->c, &out->d, &out->e);
1051 #endif // BASE_TUPLE_H__