1 // Copyright (c) 2006-2008 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.
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__
33 #if defined(OS_CHROMEOS)
34 // To troubleshoot crosbug.com/7327.
35 #include "base/logging.h"
37 // Traits ----------------------------------------------------------------------
39 // A simple traits class for tuple arguments.
41 // ValueType: the bare, nonref version of a type (same as the type for nonrefs).
42 // RefType: the ref version of a type (same as the type for refs).
43 // ParamType: what type to pass to functions (refs should not be constified).
49 typedef const P& ParamType;
53 struct TupleTraits<P&> {
60 struct TupleTypes { };
62 // Tuple -----------------------------------------------------------------------
64 // This set of classes is useful for bundling 0 or more heterogeneous data types
65 // into a single variable. The advantage of this is that it greatly simplifies
66 // function objects that need to take an arbitrary number of parameters; see
67 // RunnableMethod and IPC::MessageWithTuple.
69 // Tuple0 is supplied to act as a 'void' type. It can be used, for example,
70 // when dispatching to a function that accepts no arguments (see the
71 // Dispatchers below).
72 // Tuple1<A> is rarely useful. One such use is when A is non-const ref that you
73 // want filled by the dispatchee, and the tuple is merely a container for that
74 // output (a "tier"). See MakeRefTuple and its usages.
77 typedef Tuple0 ValueTuple;
78 typedef Tuple0 RefTuple;
79 typedef Tuple0 ParamTuple;
88 explicit Tuple1(typename TupleTraits<A>::ParamType a) : a(a) {}
93 template <class A, class B>
100 Tuple2(typename TupleTraits<A>::ParamType a,
101 typename TupleTraits<B>::ParamType b)
109 template <class A, class B, class C>
117 Tuple3(typename TupleTraits<A>::ParamType a,
118 typename TupleTraits<B>::ParamType b,
119 typename TupleTraits<C>::ParamType c)
128 template <class A, class B, class C, class D>
137 Tuple4(typename TupleTraits<A>::ParamType a,
138 typename TupleTraits<B>::ParamType b,
139 typename TupleTraits<C>::ParamType c,
140 typename TupleTraits<D>::ParamType d)
141 : a(a), b(b), c(c), d(d) {
150 template <class A, class B, class C, class D, class E>
160 Tuple5(typename TupleTraits<A>::ParamType a,
161 typename TupleTraits<B>::ParamType b,
162 typename TupleTraits<C>::ParamType c,
163 typename TupleTraits<D>::ParamType d,
164 typename TupleTraits<E>::ParamType e)
165 : a(a), b(b), c(c), d(d), e(e) {
175 template <class A, class B, class C, class D, class E, class F>
186 Tuple6(typename TupleTraits<A>::ParamType a,
187 typename TupleTraits<B>::ParamType b,
188 typename TupleTraits<C>::ParamType c,
189 typename TupleTraits<D>::ParamType d,
190 typename TupleTraits<E>::ParamType e,
191 typename TupleTraits<F>::ParamType f)
192 : a(a), b(b), c(c), d(d), e(e), f(f) {
203 template <class A, class B, class C, class D, class E, class F, class G>
215 Tuple7(typename TupleTraits<A>::ParamType a,
216 typename TupleTraits<B>::ParamType b,
217 typename TupleTraits<C>::ParamType c,
218 typename TupleTraits<D>::ParamType d,
219 typename TupleTraits<E>::ParamType e,
220 typename TupleTraits<F>::ParamType f,
221 typename TupleTraits<G>::ParamType g)
222 : a(a), b(b), c(c), d(d), e(e), f(f), g(g) {
234 template <class A, class B, class C, class D, class E, class F, class G,
248 Tuple8(typename TupleTraits<A>::ParamType a,
249 typename TupleTraits<B>::ParamType b,
250 typename TupleTraits<C>::ParamType c,
251 typename TupleTraits<D>::ParamType d,
252 typename TupleTraits<E>::ParamType e,
253 typename TupleTraits<F>::ParamType f,
254 typename TupleTraits<G>::ParamType g,
255 typename TupleTraits<H>::ParamType h)
256 : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) {
269 // Tuple types ----------------------------------------------------------------
271 // Allows for selection of ValueTuple/RefTuple/ParamTuple without needing the
272 // definitions of class types the tuple takes as parameters.
275 struct TupleTypes< Tuple0 > {
276 typedef Tuple0 ValueTuple;
277 typedef Tuple0 RefTuple;
278 typedef Tuple0 ParamTuple;
282 struct TupleTypes< Tuple1<A> > {
283 typedef Tuple1<typename TupleTraits<A>::ValueType> ValueTuple;
284 typedef Tuple1<typename TupleTraits<A>::RefType> RefTuple;
285 typedef Tuple1<typename TupleTraits<A>::ParamType> ParamTuple;
288 template <class A, class B>
289 struct TupleTypes< Tuple2<A, B> > {
290 typedef Tuple2<typename TupleTraits<A>::ValueType,
291 typename TupleTraits<B>::ValueType> ValueTuple;
292 typedef Tuple2<typename TupleTraits<A>::RefType,
293 typename TupleTraits<B>::RefType> RefTuple;
294 typedef Tuple2<typename TupleTraits<A>::ParamType,
295 typename TupleTraits<B>::ParamType> ParamTuple;
298 template <class A, class B, class C>
299 struct TupleTypes< Tuple3<A, B, C> > {
300 typedef Tuple3<typename TupleTraits<A>::ValueType,
301 typename TupleTraits<B>::ValueType,
302 typename TupleTraits<C>::ValueType> ValueTuple;
303 typedef Tuple3<typename TupleTraits<A>::RefType,
304 typename TupleTraits<B>::RefType,
305 typename TupleTraits<C>::RefType> RefTuple;
306 typedef Tuple3<typename TupleTraits<A>::ParamType,
307 typename TupleTraits<B>::ParamType,
308 typename TupleTraits<C>::ParamType> ParamTuple;
311 template <class A, class B, class C, class D>
312 struct TupleTypes< Tuple4<A, B, C, D> > {
313 typedef Tuple4<typename TupleTraits<A>::ValueType,
314 typename TupleTraits<B>::ValueType,
315 typename TupleTraits<C>::ValueType,
316 typename TupleTraits<D>::ValueType> ValueTuple;
317 typedef Tuple4<typename TupleTraits<A>::RefType,
318 typename TupleTraits<B>::RefType,
319 typename TupleTraits<C>::RefType,
320 typename TupleTraits<D>::RefType> RefTuple;
321 typedef Tuple4<typename TupleTraits<A>::ParamType,
322 typename TupleTraits<B>::ParamType,
323 typename TupleTraits<C>::ParamType,
324 typename TupleTraits<D>::ParamType> ParamTuple;
327 template <class A, class B, class C, class D, class E>
328 struct TupleTypes< Tuple5<A, B, C, D, E> > {
329 typedef Tuple5<typename TupleTraits<A>::ValueType,
330 typename TupleTraits<B>::ValueType,
331 typename TupleTraits<C>::ValueType,
332 typename TupleTraits<D>::ValueType,
333 typename TupleTraits<E>::ValueType> ValueTuple;
334 typedef Tuple5<typename TupleTraits<A>::RefType,
335 typename TupleTraits<B>::RefType,
336 typename TupleTraits<C>::RefType,
337 typename TupleTraits<D>::RefType,
338 typename TupleTraits<E>::RefType> RefTuple;
339 typedef Tuple5<typename TupleTraits<A>::ParamType,
340 typename TupleTraits<B>::ParamType,
341 typename TupleTraits<C>::ParamType,
342 typename TupleTraits<D>::ParamType,
343 typename TupleTraits<E>::ParamType> ParamTuple;
346 template <class A, class B, class C, class D, class E, class F>
347 struct TupleTypes< Tuple6<A, B, C, D, E, F> > {
348 typedef Tuple6<typename TupleTraits<A>::ValueType,
349 typename TupleTraits<B>::ValueType,
350 typename TupleTraits<C>::ValueType,
351 typename TupleTraits<D>::ValueType,
352 typename TupleTraits<E>::ValueType,
353 typename TupleTraits<F>::ValueType> ValueTuple;
354 typedef Tuple6<typename TupleTraits<A>::RefType,
355 typename TupleTraits<B>::RefType,
356 typename TupleTraits<C>::RefType,
357 typename TupleTraits<D>::RefType,
358 typename TupleTraits<E>::RefType,
359 typename TupleTraits<F>::RefType> RefTuple;
360 typedef Tuple6<typename TupleTraits<A>::ParamType,
361 typename TupleTraits<B>::ParamType,
362 typename TupleTraits<C>::ParamType,
363 typename TupleTraits<D>::ParamType,
364 typename TupleTraits<E>::ParamType,
365 typename TupleTraits<F>::ParamType> ParamTuple;
368 template <class A, class B, class C, class D, class E, class F, class G>
369 struct TupleTypes< Tuple7<A, B, C, D, E, F, G> > {
370 typedef Tuple7<typename TupleTraits<A>::ValueType,
371 typename TupleTraits<B>::ValueType,
372 typename TupleTraits<C>::ValueType,
373 typename TupleTraits<D>::ValueType,
374 typename TupleTraits<E>::ValueType,
375 typename TupleTraits<F>::ValueType,
376 typename TupleTraits<G>::ValueType> ValueTuple;
377 typedef Tuple7<typename TupleTraits<A>::RefType,
378 typename TupleTraits<B>::RefType,
379 typename TupleTraits<C>::RefType,
380 typename TupleTraits<D>::RefType,
381 typename TupleTraits<E>::RefType,
382 typename TupleTraits<F>::RefType,
383 typename TupleTraits<G>::RefType> RefTuple;
384 typedef Tuple7<typename TupleTraits<A>::ParamType,
385 typename TupleTraits<B>::ParamType,
386 typename TupleTraits<C>::ParamType,
387 typename TupleTraits<D>::ParamType,
388 typename TupleTraits<E>::ParamType,
389 typename TupleTraits<F>::ParamType,
390 typename TupleTraits<G>::ParamType> ParamTuple;
393 template <class A, class B, class C, class D, class E, class F, class G,
395 struct TupleTypes< Tuple8<A, B, C, D, E, F, G, H> > {
396 typedef Tuple8<typename TupleTraits<A>::ValueType,
397 typename TupleTraits<B>::ValueType,
398 typename TupleTraits<C>::ValueType,
399 typename TupleTraits<D>::ValueType,
400 typename TupleTraits<E>::ValueType,
401 typename TupleTraits<F>::ValueType,
402 typename TupleTraits<G>::ValueType,
403 typename TupleTraits<H>::ValueType> ValueTuple;
404 typedef Tuple8<typename TupleTraits<A>::RefType,
405 typename TupleTraits<B>::RefType,
406 typename TupleTraits<C>::RefType,
407 typename TupleTraits<D>::RefType,
408 typename TupleTraits<E>::RefType,
409 typename TupleTraits<F>::RefType,
410 typename TupleTraits<G>::RefType,
411 typename TupleTraits<H>::RefType> RefTuple;
412 typedef Tuple8<typename TupleTraits<A>::ParamType,
413 typename TupleTraits<B>::ParamType,
414 typename TupleTraits<C>::ParamType,
415 typename TupleTraits<D>::ParamType,
416 typename TupleTraits<E>::ParamType,
417 typename TupleTraits<F>::ParamType,
418 typename TupleTraits<G>::ParamType,
419 typename TupleTraits<H>::ParamType> ParamTuple;
422 // Tuple creators -------------------------------------------------------------
424 // Helper functions for constructing tuples while inferring the template
427 inline Tuple0 MakeTuple() {
432 inline Tuple1<A> MakeTuple(const A& a) {
436 template <class A, class B>
437 inline Tuple2<A, B> MakeTuple(const A& a, const B& b) {
438 return Tuple2<A, B>(a, b);
441 template <class A, class B, class C>
442 inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c) {
443 return Tuple3<A, B, C>(a, b, c);
446 template <class A, class B, class C, class D>
447 inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c,
449 return Tuple4<A, B, C, D>(a, b, c, d);
452 template <class A, class B, class C, class D, class E>
453 inline Tuple5<A, B, C, D, E> MakeTuple(const A& a, const B& b, const C& c,
454 const D& d, const E& e) {
455 return Tuple5<A, B, C, D, E>(a, b, c, d, e);
458 template <class A, class B, class C, class D, class E, class F>
459 inline Tuple6<A, B, C, D, E, F> MakeTuple(const A& a, const B& b, const C& c,
460 const D& d, const E& e, const F& f) {
461 return Tuple6<A, B, C, D, E, F>(a, b, c, d, e, f);
464 template <class A, class B, class C, class D, class E, class F, class G>
465 inline Tuple7<A, B, C, D, E, F, G> MakeTuple(const A& a, const B& b, const C& c,
466 const D& d, const E& e, const F& f,
468 return Tuple7<A, B, C, D, E, F, G>(a, b, c, d, e, f, g);
471 template <class A, class B, class C, class D, class E, class F, class G,
473 inline Tuple8<A, B, C, D, E, F, G, H> MakeTuple(const A& a, const B& b,
474 const C& c, const D& d,
475 const E& e, const F& f,
476 const G& g, const H& h) {
477 return Tuple8<A, B, C, D, E, F, G, H>(a, b, c, d, e, f, g, h);
480 // The following set of helpers make what Boost refers to as "Tiers" - a tuple
484 inline Tuple1<A&> MakeRefTuple(A& a) {
485 return Tuple1<A&>(a);
488 template <class A, class B>
489 inline Tuple2<A&, B&> MakeRefTuple(A& a, B& b) {
490 return Tuple2<A&, B&>(a, b);
493 template <class A, class B, class C>
494 inline Tuple3<A&, B&, C&> MakeRefTuple(A& a, B& b, C& c) {
495 return Tuple3<A&, B&, C&>(a, b, c);
498 template <class A, class B, class C, class D>
499 inline Tuple4<A&, B&, C&, D&> MakeRefTuple(A& a, B& b, C& c, D& d) {
500 return Tuple4<A&, B&, C&, D&>(a, b, c, d);
503 template <class A, class B, class C, class D, class E>
504 inline Tuple5<A&, B&, C&, D&, E&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e) {
505 return Tuple5<A&, B&, C&, D&, E&>(a, b, c, d, e);
508 template <class A, class B, class C, class D, class E, class F>
509 inline Tuple6<A&, B&, C&, D&, E&, F&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e,
511 return Tuple6<A&, B&, C&, D&, E&, F&>(a, b, c, d, e, f);
514 template <class A, class B, class C, class D, class E, class F, class G>
515 inline Tuple7<A&, B&, C&, D&, E&, F&, G&> MakeRefTuple(A& a, B& b, C& c, D& d,
517 return Tuple7<A&, B&, C&, D&, E&, F&, G&>(a, b, c, d, e, f, g);
520 template <class A, class B, class C, class D, class E, class F, class G,
522 inline Tuple8<A&, B&, C&, D&, E&, F&, G&, H&> MakeRefTuple(A& a, B& b, C& c,
525 return Tuple8<A&, B&, C&, D&, E&, F&, G&, H&>(a, b, c, d, e, f, g, h);
528 // Dispatchers ----------------------------------------------------------------
530 // Helper functions that call the given method on an object, with the unpacked
531 // tuple arguments. Notice that they all have the same number of arguments,
532 // so you need only write:
533 // DispatchToMethod(object, &Object::method, args);
534 // This is very useful for templated dispatchers, since they don't need to know
535 // what type |args| is.
537 // Non-Static Dispatchers with no out params.
539 template <class ObjT, class Method>
540 inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) {
544 template <class ObjT, class Method, class A>
545 inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) {
549 template <class ObjT, class Method, class A>
550 inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) {
551 (obj->*method)(arg.a);
554 template<class ObjT, class Method, class A, class B>
555 inline void DispatchToMethod(ObjT* obj,
557 const Tuple2<A, B>& arg) {
558 (obj->*method)(arg.a, arg.b);
561 template<class ObjT, class Method, class A, class B, class C>
562 inline void DispatchToMethod(ObjT* obj, Method method,
563 const Tuple3<A, B, C>& arg) {
564 (obj->*method)(arg.a, arg.b, arg.c);
567 template<class ObjT, class Method, class A, class B, class C, class D>
568 inline void DispatchToMethod(ObjT* obj, Method method,
569 const Tuple4<A, B, C, D>& arg) {
570 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
573 template<class ObjT, class Method, class A, class B, class C, class D, class E>
574 inline void DispatchToMethod(ObjT* obj, Method method,
575 const Tuple5<A, B, C, D, E>& arg) {
576 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
579 template<class ObjT, class Method, class A, class B, class C, class D, class E,
581 inline void DispatchToMethod(ObjT* obj, Method method,
582 const Tuple6<A, B, C, D, E, F>& arg) {
583 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
586 template<class ObjT, class Method, class A, class B, class C, class D, class E,
588 inline void DispatchToMethod(ObjT* obj, Method method,
589 const Tuple7<A, B, C, D, E, F, G>& arg) {
590 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g);
593 template<class ObjT, class Method, class A, class B, class C, class D, class E,
594 class F, class G, class H>
595 inline void DispatchToMethod(ObjT* obj, Method method,
596 const Tuple8<A, B, C, D, E, F, G, H>& arg) {
597 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g, arg.h);
600 // Static Dispatchers with no out params.
602 template <class Function>
603 inline void DispatchToFunction(Function function, const Tuple0& arg) {
607 template <class Function, class A>
608 inline void DispatchToFunction(Function function, const A& arg) {
612 template <class Function, class A>
613 inline void DispatchToFunction(Function function, const Tuple1<A>& arg) {
617 template<class Function, class A, class B>
618 inline void DispatchToFunction(Function function, const Tuple2<A, B>& arg) {
619 (*function)(arg.a, arg.b);
622 template<class Function, class A, class B, class C>
623 inline void DispatchToFunction(Function function, const Tuple3<A, B, C>& arg) {
624 (*function)(arg.a, arg.b, arg.c);
627 template<class Function, class A, class B, class C, class D>
628 inline void DispatchToFunction(Function function,
629 const Tuple4<A, B, C, D>& arg) {
630 (*function)(arg.a, arg.b, arg.c, arg.d);
633 template<class Function, class A, class B, class C, class D, class E>
634 inline void DispatchToFunction(Function function,
635 const Tuple5<A, B, C, D, E>& arg) {
636 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e);
639 template<class Function, class A, class B, class C, class D, class E, class F>
640 inline void DispatchToFunction(Function function,
641 const Tuple6<A, B, C, D, E, F>& arg) {
642 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
645 template<class Function, class A, class B, class C, class D, class E, class F,
647 inline void DispatchToFunction(Function function,
648 const Tuple7<A, B, C, D, E, F, G>& arg) {
649 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g);
652 template<class Function, class A, class B, class C, class D, class E, class F,
654 inline void DispatchToFunction(Function function,
655 const Tuple8<A, B, C, D, E, F, G, H>& arg) {
656 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g, arg.h);
659 // Dispatchers with 0 out param (as a Tuple0).
661 template <class ObjT, class Method>
662 inline void DispatchToMethod(ObjT* obj,
664 const Tuple0& arg, Tuple0*) {
668 template <class ObjT, class Method, class A>
669 inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) {
673 template <class ObjT, class Method, class A>
674 inline void DispatchToMethod(ObjT* obj,
676 const Tuple1<A>& arg, Tuple0*) {
677 (obj->*method)(arg.a);
680 template<class ObjT, class Method, class A, class B>
681 inline void DispatchToMethod(ObjT* obj,
683 const Tuple2<A, B>& arg, Tuple0*) {
684 (obj->*method)(arg.a, arg.b);
687 template<class ObjT, class Method, class A, class B, class C>
688 inline void DispatchToMethod(ObjT* obj, Method method,
689 const Tuple3<A, B, C>& arg, Tuple0*) {
690 (obj->*method)(arg.a, arg.b, arg.c);
693 template<class ObjT, class Method, class A, class B, class C, class D>
694 inline void DispatchToMethod(ObjT* obj, Method method,
695 const Tuple4<A, B, C, D>& arg, Tuple0*) {
696 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
699 template<class ObjT, class Method, class A, class B, class C, class D, class E>
700 inline void DispatchToMethod(ObjT* obj, Method method,
701 const Tuple5<A, B, C, D, E>& arg, Tuple0*) {
702 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
705 template<class ObjT, class Method, class A, class B, class C, class D, class E,
707 inline void DispatchToMethod(ObjT* obj, Method method,
708 const Tuple6<A, B, C, D, E, F>& arg, Tuple0*) {
709 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
712 // Dispatchers with 1 out param.
714 template<class ObjT, class Method,
716 inline void DispatchToMethod(ObjT* obj, Method method,
719 (obj->*method)(&out->a);
722 template<class ObjT, class Method, class InA,
724 inline void DispatchToMethod(ObjT* obj, Method method,
727 (obj->*method)(in, &out->a);
730 template<class ObjT, class Method, class InA,
732 inline void DispatchToMethod(ObjT* obj, Method method,
733 const Tuple1<InA>& in,
735 (obj->*method)(in.a, &out->a);
738 template<class ObjT, class Method, class InA, class InB,
740 inline void DispatchToMethod(ObjT* obj, Method method,
741 const Tuple2<InA, InB>& in,
743 (obj->*method)(in.a, in.b, &out->a);
746 template<class ObjT, class Method, class InA, class InB, class InC,
748 inline void DispatchToMethod(ObjT* obj, Method method,
749 const Tuple3<InA, InB, InC>& in,
751 (obj->*method)(in.a, in.b, in.c, &out->a);
754 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
756 inline void DispatchToMethod(ObjT* obj, Method method,
757 const Tuple4<InA, InB, InC, InD>& in,
759 (obj->*method)(in.a, in.b, in.c, in.d, &out->a);
762 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
763 class InE, class OutA>
764 inline void DispatchToMethod(ObjT* obj, Method method,
765 const Tuple5<InA, InB, InC, InD, InE>& in,
767 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a);
770 template<class ObjT, class Method,
771 class InA, class InB, class InC, class InD, class InE, class InF,
773 inline void DispatchToMethod(ObjT* obj, Method method,
774 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
776 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a);
779 // Dispatchers with 2 out params.
781 template<class ObjT, class Method,
782 class OutA, class OutB>
783 inline void DispatchToMethod(ObjT* obj, Method method,
785 Tuple2<OutA, OutB>* out) {
786 (obj->*method)(&out->a, &out->b);
789 template<class ObjT, class Method, class InA,
790 class OutA, class OutB>
791 inline void DispatchToMethod(ObjT* obj, Method method,
793 Tuple2<OutA, OutB>* out) {
794 (obj->*method)(in, &out->a, &out->b);
797 template<class ObjT, class Method, class InA,
798 class OutA, class OutB>
799 inline void DispatchToMethod(ObjT* obj, Method method,
800 const Tuple1<InA>& in,
801 Tuple2<OutA, OutB>* out) {
802 (obj->*method)(in.a, &out->a, &out->b);
805 template<class ObjT, class Method, class InA, class InB,
806 class OutA, class OutB>
807 inline void DispatchToMethod(ObjT* obj, Method method,
808 const Tuple2<InA, InB>& in,
809 Tuple2<OutA, OutB>* out) {
810 (obj->*method)(in.a, in.b, &out->a, &out->b);
813 template<class ObjT, class Method, class InA, class InB, class InC,
814 class OutA, class OutB>
815 inline void DispatchToMethod(ObjT* obj, Method method,
816 const Tuple3<InA, InB, InC>& in,
817 Tuple2<OutA, OutB>* out) {
818 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b);
821 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
822 class OutA, class OutB>
823 inline void DispatchToMethod(ObjT* obj, Method method,
824 const Tuple4<InA, InB, InC, InD>& in,
825 Tuple2<OutA, OutB>* out) {
826 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b);
829 template<class ObjT, class Method,
830 class InA, class InB, class InC, class InD, class InE,
831 class OutA, class OutB>
832 inline void DispatchToMethod(ObjT* obj, Method method,
833 const Tuple5<InA, InB, InC, InD, InE>& in,
834 Tuple2<OutA, OutB>* out) {
835 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b);
838 template<class ObjT, class Method,
839 class InA, class InB, class InC, class InD, class InE, class InF,
840 class OutA, class OutB>
841 inline void DispatchToMethod(ObjT* obj, Method method,
842 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
843 Tuple2<OutA, OutB>* out) {
844 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b);
847 // Dispatchers with 3 out params.
849 template<class ObjT, class Method,
850 class OutA, class OutB, class OutC>
851 inline void DispatchToMethod(ObjT* obj, Method method,
853 Tuple3<OutA, OutB, OutC>* out) {
854 (obj->*method)(&out->a, &out->b, &out->c);
857 template<class ObjT, class Method, class InA,
858 class OutA, class OutB, class OutC>
859 inline void DispatchToMethod(ObjT* obj, Method method,
861 Tuple3<OutA, OutB, OutC>* out) {
862 (obj->*method)(in, &out->a, &out->b, &out->c);
865 template<class ObjT, class Method, class InA,
866 class OutA, class OutB, class OutC>
867 inline void DispatchToMethod(ObjT* obj, Method method,
868 const Tuple1<InA>& in,
869 Tuple3<OutA, OutB, OutC>* out) {
870 (obj->*method)(in.a, &out->a, &out->b, &out->c);
873 template<class ObjT, class Method, class InA, class InB,
874 class OutA, class OutB, class OutC>
875 inline void DispatchToMethod(ObjT* obj, Method method,
876 const Tuple2<InA, InB>& in,
877 Tuple3<OutA, OutB, OutC>* out) {
878 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c);
881 template<class ObjT, class Method, class InA, class InB, class InC,
882 class OutA, class OutB, class OutC>
883 inline void DispatchToMethod(ObjT* obj, Method method,
884 const Tuple3<InA, InB, InC>& in,
885 Tuple3<OutA, OutB, OutC>* out) {
886 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c);
889 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
890 class OutA, class OutB, class OutC>
891 inline void DispatchToMethod(ObjT* obj, Method method,
892 const Tuple4<InA, InB, InC, InD>& in,
893 Tuple3<OutA, OutB, OutC>* out) {
894 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c);
897 template<class ObjT, class Method,
898 class InA, class InB, class InC, class InD, class InE,
899 class OutA, class OutB, class OutC>
900 inline void DispatchToMethod(ObjT* obj, Method method,
901 const Tuple5<InA, InB, InC, InD, InE>& in,
902 Tuple3<OutA, OutB, OutC>* out) {
903 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c);
906 template<class ObjT, class Method,
907 class InA, class InB, class InC, class InD, class InE, class InF,
908 class OutA, class OutB, class OutC>
909 inline void DispatchToMethod(ObjT* obj, Method method,
910 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
911 Tuple3<OutA, OutB, OutC>* out) {
912 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b, &out->c);
915 // Dispatchers with 4 out params.
917 template<class ObjT, class Method,
918 class OutA, class OutB, class OutC, class OutD>
919 inline void DispatchToMethod(ObjT* obj, Method method,
921 Tuple4<OutA, OutB, OutC, OutD>* out) {
922 (obj->*method)(&out->a, &out->b, &out->c, &out->d);
925 template<class ObjT, class Method, class InA,
926 class OutA, class OutB, class OutC, class OutD>
927 inline void DispatchToMethod(ObjT* obj, Method method,
929 Tuple4<OutA, OutB, OutC, OutD>* out) {
930 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d);
933 template<class ObjT, class Method, class InA,
934 class OutA, class OutB, class OutC, class OutD>
935 inline void DispatchToMethod(ObjT* obj, Method method,
936 const Tuple1<InA>& in,
937 Tuple4<OutA, OutB, OutC, OutD>* out) {
938 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d);
941 template<class ObjT, class Method, class InA, class InB,
942 class OutA, class OutB, class OutC, class OutD>
943 inline void DispatchToMethod(ObjT* obj, Method method,
944 const Tuple2<InA, InB>& in,
945 Tuple4<OutA, OutB, OutC, OutD>* out) {
946 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d);
949 template<class ObjT, class Method, class InA, class InB, class InC,
950 class OutA, class OutB, class OutC, class OutD>
951 inline void DispatchToMethod(ObjT* obj, Method method,
952 const Tuple3<InA, InB, InC>& in,
953 Tuple4<OutA, OutB, OutC, OutD>* out) {
954 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d);
957 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
958 class OutA, class OutB, class OutC, class OutD>
959 inline void DispatchToMethod(ObjT* obj, Method method,
960 const Tuple4<InA, InB, InC, InD>& in,
961 Tuple4<OutA, OutB, OutC, OutD>* out) {
962 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d);
965 template<class ObjT, class Method,
966 class InA, class InB, class InC, class InD, class InE,
967 class OutA, class OutB, class OutC, class OutD>
968 inline void DispatchToMethod(ObjT* obj, Method method,
969 const Tuple5<InA, InB, InC, InD, InE>& in,
970 Tuple4<OutA, OutB, OutC, OutD>* out) {
971 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
972 &out->a, &out->b, &out->c, &out->d);
975 template<class ObjT, class Method,
976 class InA, class InB, class InC, class InD, class InE, class InF,
977 class OutA, class OutB, class OutC, class OutD>
978 inline void DispatchToMethod(ObjT* obj, Method method,
979 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
980 Tuple4<OutA, OutB, OutC, OutD>* out) {
981 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f,
982 &out->a, &out->b, &out->c, &out->d);
985 // Dispatchers with 5 out params.
987 template<class ObjT, class Method,
988 class OutA, class OutB, class OutC, class OutD, class OutE>
989 inline void DispatchToMethod(ObjT* obj, Method method,
991 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
992 (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e);
995 template<class ObjT, class Method, class InA,
996 class OutA, class OutB, class OutC, class OutD, class OutE>
997 inline void DispatchToMethod(ObjT* obj, Method method,
999 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1000 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d, &out->e);
1003 template<class ObjT, class Method, class InA,
1004 class OutA, class OutB, class OutC, class OutD, class OutE>
1005 inline void DispatchToMethod(ObjT* obj, Method method,
1006 const Tuple1<InA>& in,
1007 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1008 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d, &out->e);
1011 template<class ObjT, class Method, class InA, class InB,
1012 class OutA, class OutB, class OutC, class OutD, class OutE>
1013 inline void DispatchToMethod(ObjT* obj, Method method,
1014 const Tuple2<InA, InB>& in,
1015 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1016 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d, &out->e);
1019 template<class ObjT, class Method, class InA, class InB, class InC,
1020 class OutA, class OutB, class OutC, class OutD, class OutE>
1021 inline void DispatchToMethod(ObjT* obj, Method method,
1022 const Tuple3<InA, InB, InC>& in,
1023 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1024 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d, &out->e);
1027 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
1028 class OutA, class OutB, class OutC, class OutD, class OutE>
1029 inline void DispatchToMethod(ObjT* obj, Method method,
1030 const Tuple4<InA, InB, InC, InD>& in,
1031 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1032 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d,
1036 template<class ObjT, class Method,
1037 class InA, class InB, class InC, class InD, class InE,
1038 class OutA, class OutB, class OutC, class OutD, class OutE>
1039 inline void DispatchToMethod(ObjT* obj, Method method,
1040 const Tuple5<InA, InB, InC, InD, InE>& in,
1041 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1042 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
1043 &out->a, &out->b, &out->c, &out->d, &out->e);
1046 template<class ObjT, class Method,
1047 class InA, class InB, class InC, class InD, class InE, class InF,
1048 class OutA, class OutB, class OutC, class OutD, class OutE>
1049 inline void DispatchToMethod(ObjT* obj, Method method,
1050 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
1051 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
1052 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f,
1053 &out->a, &out->b, &out->c, &out->d, &out->e);
1056 #endif // BASE_TUPLE_H__