blob: 1b4b36aa89c5278ee099a9da32bc14d750aa8537 [file] [log] [blame]
initial.commitd7cae122008-07-26 21:49:381// Copyright 2008, Google Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14// * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30#ifndef BASE_TUPLE_H__
31#define BASE_TUPLE_H__
32
33// Traits ----------------------------------------------------------------------
34//
35// A simple traits class for tuple arguments.
36//
37// ValueType: the bare, nonref version of a type (same as the type for nonrefs).
38// RefType: the ref version of a type (same as the type for refs).
39// ParamType: what type to pass to functions (refs should not be constified).
40
41template <class P>
42struct TupleTraits {
43 typedef P ValueType;
44 typedef P& RefType;
45 typedef const P& ParamType;
46};
47
48template <class P>
49struct TupleTraits<P&> {
50 typedef P ValueType;
51 typedef P& RefType;
52 typedef P& ParamType;
53};
54
55// Tuple -----------------------------------------------------------------------
56//
57// This set of classes is useful for bundling 0 or more heterogeneous data types
58// into a single variable. The advantage of this is that it greatly simplifies
59// function objects that need to take an arbitrary number of parameters; see
60// RunnableMethod and IPC::MessageWithTuple.
61//
[email protected]458711982008-08-21 10:58:0862// Tuple0 is supplied to act as a 'void' type. It can be used, for example,
63// when dispatching to a function that accepts no arguments (see the
64// Dispatchers below).
initial.commitd7cae122008-07-26 21:49:3865// Tuple1<A> is rarely useful. One such use is when A is non-const ref that you
66// want filled by the dispatchee, and the tuple is merely a container for that
67// output (a "tier"). See MakeRefTuple and its usages.
68
69struct Tuple0 {
70 typedef Tuple0 ValueTuple;
71 typedef Tuple0 RefTuple;
72};
73
74template <class A>
75struct Tuple1 {
76 public:
77 typedef A TypeA;
78 typedef Tuple1<typename TupleTraits<A>::ValueType> ValueTuple;
79 typedef Tuple1<typename TupleTraits<A>::RefType> RefTuple;
80
81 Tuple1() {}
82 explicit Tuple1(typename TupleTraits<A>::ParamType a) : a(a) {}
83
84 A a;
85};
86
87template <class A, class B>
88struct Tuple2 {
89 public:
90 typedef A TypeA;
91 typedef B TypeB;
92 typedef Tuple2<typename TupleTraits<A>::ValueType,
93 typename TupleTraits<B>::ValueType> ValueTuple;
94 typedef Tuple2<typename TupleTraits<A>::RefType,
95 typename TupleTraits<B>::RefType> RefTuple;
96
97 Tuple2() {}
98 Tuple2(typename TupleTraits<A>::ParamType a,
99 typename TupleTraits<B>::ParamType b)
100 : a(a), b(b) {
101 }
102
103 A a;
104 B b;
105};
106
107template <class A, class B, class C>
108struct Tuple3 {
109 public:
110 typedef A TypeA;
111 typedef B TypeB;
112 typedef C TypeC;
113 typedef Tuple3<typename TupleTraits<A>::ValueType,
114 typename TupleTraits<B>::ValueType,
115 typename TupleTraits<C>::ValueType> ValueTuple;
116 typedef Tuple3<typename TupleTraits<A>::RefType,
117 typename TupleTraits<B>::RefType,
118 typename TupleTraits<C>::RefType> RefTuple;
119
120 Tuple3() {}
121 Tuple3(typename TupleTraits<A>::ParamType a,
122 typename TupleTraits<B>::ParamType b,
123 typename TupleTraits<C>::ParamType c)
124 : a(a), b(b), c(c){
125 }
126
127 A a;
128 B b;
129 C c;
130};
131
132template <class A, class B, class C, class D>
133struct Tuple4 {
134 public:
135 typedef A TypeA;
136 typedef B TypeB;
137 typedef C TypeC;
138 typedef D TypeD;
139 typedef Tuple4<typename TupleTraits<A>::ValueType,
140 typename TupleTraits<B>::ValueType,
141 typename TupleTraits<C>::ValueType,
142 typename TupleTraits<D>::ValueType> ValueTuple;
143 typedef Tuple4<typename TupleTraits<A>::RefType,
144 typename TupleTraits<B>::RefType,
145 typename TupleTraits<C>::RefType,
146 typename TupleTraits<D>::RefType> RefTuple;
147
148 Tuple4() {}
149 Tuple4(typename TupleTraits<A>::ParamType a,
150 typename TupleTraits<B>::ParamType b,
151 typename TupleTraits<C>::ParamType c,
152 typename TupleTraits<D>::ParamType d)
153 : a(a), b(b), c(c), d(d) {
154 }
155
156 A a;
157 B b;
158 C c;
159 D d;
160};
161
162template <class A, class B, class C, class D, class E>
163struct Tuple5 {
164public:
165 typedef A TypeA;
166 typedef B TypeB;
167 typedef C TypeC;
168 typedef D TypeD;
169 typedef E TypeE;
170 typedef Tuple5<typename TupleTraits<A>::ValueType,
171 typename TupleTraits<B>::ValueType,
172 typename TupleTraits<C>::ValueType,
173 typename TupleTraits<D>::ValueType,
174 typename TupleTraits<E>::ValueType> ValueTuple;
175 typedef Tuple5<typename TupleTraits<A>::RefType,
176 typename TupleTraits<B>::RefType,
177 typename TupleTraits<C>::RefType,
178 typename TupleTraits<D>::RefType,
179 typename TupleTraits<E>::RefType> RefTuple;
180
181 Tuple5() {}
182 Tuple5(typename TupleTraits<A>::ParamType a,
183 typename TupleTraits<B>::ParamType b,
184 typename TupleTraits<C>::ParamType c,
185 typename TupleTraits<D>::ParamType d,
186 typename TupleTraits<E>::ParamType e)
187 : a(a), b(b), c(c), d(d), e(e) {
188 }
189
190 A a;
191 B b;
192 C c;
193 D d;
194 E e;
195};
196
197// Tuple creators -------------------------------------------------------------
198//
199// Helper functions for constructing tuples while inferring the template
200// argument types.
201
202inline Tuple0 MakeTuple() {
203 return Tuple0();
204}
205
206template <class A>
207inline Tuple1<A> MakeTuple(const A& a) {
208 return Tuple1<A>(a);
209}
210
211template <class A, class B>
212inline Tuple2<A, B> MakeTuple(const A& a, const B& b) {
213 return Tuple2<A, B>(a, b);
214}
215
216template <class A, class B, class C>
217inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c) {
218 return Tuple3<A, B, C>(a, b, c);
219}
220
221template <class A, class B, class C, class D>
222inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c,
223 const D& d) {
224 return Tuple4<A, B, C, D>(a, b, c, d);
225}
226
227template <class A, class B, class C, class D, class E>
228inline Tuple5<A, B, C, D, E> MakeTuple(const A& a, const B& b, const C& c,
229 const D& d, const E& e) {
230 return Tuple5<A, B, C, D, E>(a, b, c, d, e);
231}
232
233// The following set of helpers make what Boost refers to as "Tiers" - a tuple
234// of references.
235
236template <class A>
237inline Tuple1<A&> MakeRefTuple(A& a) {
238 return Tuple1<A&>(a);
239}
240
241template <class A, class B>
242inline Tuple2<A&, B&> MakeRefTuple(A& a, B& b) {
243 return Tuple2<A&, B&>(a, b);
244}
245
246template <class A, class B, class C>
247inline Tuple3<A&, B&, C&> MakeRefTuple(A& a, B& b, C& c) {
248 return Tuple3<A&, B&, C&>(a, b, c);
249}
250
251template <class A, class B, class C, class D>
252inline Tuple4<A&, B&, C&, D&> MakeRefTuple(A& a, B& b, C& c, D& d) {
253 return Tuple4<A&, B&, C&, D&>(a, b, c, d);
254}
255
256template <class A, class B, class C, class D, class E>
257inline Tuple5<A&, B&, C&, D&, E&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e) {
258 return Tuple5<A&, B&, C&, D&, E&>(a, b, c, d, e);
259}
260
261// Dispatchers ----------------------------------------------------------------
262//
263// Helper functions that call the given method on an object, with the unpacked
264// tuple arguments. Notice that they all have the same number of arguments,
265// so you need only write:
266// DispatchToMethod(object, &Object::method, args);
267// This is very useful for templated dispatchers, since they don't need to know
268// what type |args| is.
269
270// Non-Static Dispatchers with no out params.
271
272template <class ObjT, class Method>
273inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) {
274 (obj->*method)();
275}
276
277template <class ObjT, class Method, class A>
278inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) {
279 (obj->*method)(arg);
280}
281
282template <class ObjT, class Method, class A>
283inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) {
284 (obj->*method)(arg.a);
285}
286
287template<class ObjT, class Method, class A, class B>
288inline void DispatchToMethod(ObjT* obj, Method method, const Tuple2<A, B>& arg) {
289 (obj->*method)(arg.a, arg.b);
290}
291
292template<class ObjT, class Method, class A, class B, class C>
293inline void DispatchToMethod(ObjT* obj, Method method,
294 const Tuple3<A, B, C>& arg) {
295 (obj->*method)(arg.a, arg.b, arg.c);
296}
297
298template<class ObjT, class Method, class A, class B, class C, class D>
299inline void DispatchToMethod(ObjT* obj, Method method,
300 const Tuple4<A, B, C, D>& arg) {
301 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
302}
303
304template<class ObjT, class Method, class A, class B, class C, class D, class E>
305inline void DispatchToMethod(ObjT* obj, Method method,
306 const Tuple5<A, B, C, D, E>& arg) {
307 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
308}
309
310// Static Dispatchers with no out params.
311
312template <class Function>
313inline void DispatchToFunction(Function function, const Tuple0& arg) {
314 (*function)();
315}
316
317template <class Function, class A>
318inline void DispatchToFunction(Function function, const A& arg) {
319 (*function)(arg);
320}
321
322template <class Function, class A>
323inline void DispatchToFunction(Function function, const Tuple1<A>& arg) {
324 (*function)(arg.a);
325}
326
327template<class Function, class A, class B>
328inline void DispatchToFunction(Function function, const Tuple2<A, B>& arg) {
329 (*function)(arg.a, arg.b);
330}
331
332template<class Function, class A, class B, class C>
333inline void DispatchToFunction(Function function, const Tuple3<A, B, C>& arg) {
334 (*function)(arg.a, arg.b, arg.c);
335}
336
337template<class Function, class A, class B, class C, class D>
338inline void DispatchToFunction(Function function,
339 const Tuple4<A, B, C, D>& arg) {
340 (*function)(arg.a, arg.b, arg.c, arg.d);
341}
342
343template<class Function, class A, class B, class C, class D, class E>
344inline void DispatchToFunction(Function function,
345 const Tuple5<A, B, C, D, E>& arg) {
346 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e);
347}
348
349// Dispatchers with 0 out param (as a Tuple0).
350
351template <class ObjT, class Method>
352inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg, Tuple0*) {
353 (obj->*method)();
354}
355
356template <class ObjT, class Method, class A>
357inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) {
358 (obj->*method)(arg);
359}
360
361template <class ObjT, class Method, class A>
362inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg, Tuple0*) {
363 (obj->*method)(arg.a);
364}
365
366template<class ObjT, class Method, class A, class B>
367inline void DispatchToMethod(ObjT* obj, Method method, const Tuple2<A, B>& arg, Tuple0*) {
368 (obj->*method)(arg.a, arg.b);
369}
370
371template<class ObjT, class Method, class A, class B, class C>
372inline void DispatchToMethod(ObjT* obj, Method method,
373 const Tuple3<A, B, C>& arg, Tuple0*) {
374 (obj->*method)(arg.a, arg.b, arg.c);
375}
376
377template<class ObjT, class Method, class A, class B, class C, class D>
378inline void DispatchToMethod(ObjT* obj, Method method,
379 const Tuple4<A, B, C, D>& arg, Tuple0*) {
380 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
381}
382
383template<class ObjT, class Method, class A, class B, class C, class D, class E>
384inline void DispatchToMethod(ObjT* obj, Method method,
385 const Tuple5<A, B, C, D, E>& arg, Tuple0*) {
386 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
387}
388
389// Dispatchers with 1 out param.
390
391template<class ObjT, class Method,
392 class OutA>
393inline void DispatchToMethod(ObjT* obj, Method method,
394 const Tuple0& in,
395 Tuple1<OutA>* out) {
396 (obj->*method)(&out->a);
397}
398
399template<class ObjT, class Method, class InA,
400 class OutA>
401inline void DispatchToMethod(ObjT* obj, Method method,
402 const InA& in,
403 Tuple1<OutA>* out) {
404 (obj->*method)(in, &out->a);
405}
406
407template<class ObjT, class Method, class InA,
408 class OutA>
409inline void DispatchToMethod(ObjT* obj, Method method,
410 const Tuple1<InA>& in,
411 Tuple1<OutA>* out) {
412 (obj->*method)(in.a, &out->a);
413}
414
415template<class ObjT, class Method, class InA, class InB,
416 class OutA>
417inline void DispatchToMethod(ObjT* obj, Method method,
418 const Tuple2<InA, InB>& in,
419 Tuple1<OutA>* out) {
420 (obj->*method)(in.a, in.b, &out->a);
421}
422
423template<class ObjT, class Method, class InA, class InB, class InC,
424 class OutA>
425inline void DispatchToMethod(ObjT* obj, Method method,
426 const Tuple3<InA, InB, InC>& in,
427 Tuple1<OutA>* out) {
428 (obj->*method)(in.a, in.b, in.c, &out->a);
429}
430
431template<class ObjT, class Method, class InA, class InB, class InC, class InD,
432 class OutA>
433inline void DispatchToMethod(ObjT* obj, Method method,
434 const Tuple4<InA, InB, InC, InD>& in,
435 Tuple1<OutA>* out) {
436 (obj->*method)(in.a, in.b, in.c, in.d, &out->a);
437}
438
439template<class ObjT, class Method,
440 class InA, class InB, class InC, class InD, class InE,
441 class OutA>
442inline void DispatchToMethod(ObjT* obj, Method method,
443 const Tuple5<InA, InB, InC, InD, InE>& in,
444 Tuple1<OutA>* out) {
445 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a);
446}
447
448// Dispatchers with 2 out params.
449
450template<class ObjT, class Method,
451 class OutA, class OutB>
452inline void DispatchToMethod(ObjT* obj, Method method,
453 const Tuple0& in,
454 Tuple2<OutA, OutB>* out) {
455 (obj->*method)(&out->a, &out->b);
456}
457
458template<class ObjT, class Method, class InA,
459 class OutA, class OutB>
460inline void DispatchToMethod(ObjT* obj, Method method,
461 const InA& in,
462 Tuple2<OutA, OutB>* out) {
463 (obj->*method)(in, &out->a, &out->b);
464}
465
466template<class ObjT, class Method, class InA,
467 class OutA, class OutB>
468inline void DispatchToMethod(ObjT* obj, Method method,
469 const Tuple1<InA>& in,
470 Tuple2<OutA, OutB>* out) {
471 (obj->*method)(in.a, &out->a, &out->b);
472}
473
474template<class ObjT, class Method, class InA, class InB,
475 class OutA, class OutB>
476inline void DispatchToMethod(ObjT* obj, Method method,
477 const Tuple2<InA, InB>& in,
478 Tuple2<OutA, OutB>* out) {
479 (obj->*method)(in.a, in.b, &out->a, &out->b);
480}
481
482template<class ObjT, class Method, class InA, class InB, class InC,
483 class OutA, class OutB>
484inline void DispatchToMethod(ObjT* obj, Method method,
485 const Tuple3<InA, InB, InC>& in,
486 Tuple2<OutA, OutB>* out) {
487 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b);
488}
489
490template<class ObjT, class Method, class InA, class InB, class InC, class InD,
491 class OutA, class OutB>
492inline void DispatchToMethod(ObjT* obj, Method method,
493 const Tuple4<InA, InB, InC, InD>& in,
494 Tuple2<OutA, OutB>* out) {
495 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b);
496}
497
498template<class ObjT, class Method,
499 class InA, class InB, class InC, class InD, class InE,
500 class OutA, class OutB>
501inline void DispatchToMethod(ObjT* obj, Method method,
502 const Tuple5<InA, InB, InC, InD, InE>& in,
503 Tuple2<OutA, OutB>* out) {
504 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b);
505}
506
507// Dispatchers with 3 out params.
508
509template<class ObjT, class Method,
510 class OutA, class OutB, class OutC>
511inline void DispatchToMethod(ObjT* obj, Method method,
512 const Tuple0& in,
513 Tuple3<OutA, OutB, OutC>* out) {
514 (obj->*method)(&out->a, &out->b, &out->c);
515}
516
517template<class ObjT, class Method, class InA,
518 class OutA, class OutB, class OutC>
519inline void DispatchToMethod(ObjT* obj, Method method,
520 const InA& in,
521 Tuple3<OutA, OutB, OutC>* out) {
522 (obj->*method)(in, &out->a, &out->b, &out->c);
523}
524
525template<class ObjT, class Method, class InA,
526 class OutA, class OutB, class OutC>
527inline void DispatchToMethod(ObjT* obj, Method method,
528 const Tuple1<InA>& in,
529 Tuple3<OutA, OutB, OutC>* out) {
530 (obj->*method)(in.a, &out->a, &out->b, &out->c);
531}
532
533template<class ObjT, class Method, class InA, class InB,
534 class OutA, class OutB, class OutC>
535inline void DispatchToMethod(ObjT* obj, Method method,
536 const Tuple2<InA, InB>& in,
537 Tuple3<OutA, OutB, OutC>* out) {
538 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c);
539}
540
541template<class ObjT, class Method, class InA, class InB, class InC,
542 class OutA, class OutB, class OutC>
543inline void DispatchToMethod(ObjT* obj, Method method,
544 const Tuple3<InA, InB, InC>& in,
545 Tuple3<OutA, OutB, OutC>* out) {
546 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c);
547}
548
549template<class ObjT, class Method, class InA, class InB, class InC, class InD,
550 class OutA, class OutB, class OutC>
551inline void DispatchToMethod(ObjT* obj, Method method,
552 const Tuple4<InA, InB, InC, InD>& in,
553 Tuple3<OutA, OutB, OutC>* out) {
554 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c);
555}
556
557template<class ObjT, class Method,
558 class InA, class InB, class InC, class InD, class InE,
559 class OutA, class OutB, class OutC>
560inline void DispatchToMethod(ObjT* obj, Method method,
561 const Tuple5<InA, InB, InC, InD, InE>& in,
562 Tuple3<OutA, OutB, OutC>* out) {
563 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c);
564}
565
566// Dispatchers with 4 out params.
567
568template<class ObjT, class Method,
569 class OutA, class OutB, class OutC, class OutD>
570inline void DispatchToMethod(ObjT* obj, Method method,
571 const Tuple0& in,
572 Tuple4<OutA, OutB, OutC, OutD>* out) {
573 (obj->*method)(&out->a, &out->b, &out->c, &out->d);
574}
575
576template<class ObjT, class Method, class InA,
577 class OutA, class OutB, class OutC, class OutD>
578inline void DispatchToMethod(ObjT* obj, Method method,
579 const InA& in,
580 Tuple4<OutA, OutB, OutC, OutD>* out) {
581 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d);
582}
583
584template<class ObjT, class Method, class InA,
585 class OutA, class OutB, class OutC, class OutD>
586inline void DispatchToMethod(ObjT* obj, Method method,
587 const Tuple1<InA>& in,
588 Tuple4<OutA, OutB, OutC, OutD>* out) {
589 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d);
590}
591
592template<class ObjT, class Method, class InA, class InB,
593 class OutA, class OutB, class OutC, class OutD>
594inline void DispatchToMethod(ObjT* obj, Method method,
595 const Tuple2<InA, InB>& in,
596 Tuple4<OutA, OutB, OutC, OutD>* out) {
597 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d);
598}
599
600template<class ObjT, class Method, class InA, class InB, class InC,
601 class OutA, class OutB, class OutC, class OutD>
602inline void DispatchToMethod(ObjT* obj, Method method,
603 const Tuple3<InA, InB, InC>& in,
604 Tuple4<OutA, OutB, OutC, OutD>* out) {
605 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d);
606}
607
608template<class ObjT, class Method, class InA, class InB, class InC, class InD,
609 class OutA, class OutB, class OutC, class OutD>
610inline void DispatchToMethod(ObjT* obj, Method method,
611 const Tuple4<InA, InB, InC, InD>& in,
612 Tuple4<OutA, OutB, OutC, OutD>* out) {
613 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d);
614}
615
616template<class ObjT, class Method,
617 class InA, class InB, class InC, class InD, class InE,
618 class OutA, class OutB, class OutC, class OutD>
619inline void DispatchToMethod(ObjT* obj, Method method,
620 const Tuple5<InA, InB, InC, InD, InE>& in,
621 Tuple4<OutA, OutB, OutC, OutD>* out) {
622 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
623 &out->a, &out->b, &out->c, &out->d);
624}
625
626// Dispatchers with 5 out params.
627
628template<class ObjT, class Method,
629 class OutA, class OutB, class OutC, class OutD, class OutE>
630inline void DispatchToMethod(ObjT* obj, Method method,
631 const Tuple0& in,
632 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
633 (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e);
634}
635
636template<class ObjT, class Method, class InA,
637 class OutA, class OutB, class OutC, class OutD, class OutE>
638inline void DispatchToMethod(ObjT* obj, Method method,
639 const InA& in,
640 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
641 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d, &out->e);
642}
643
644template<class ObjT, class Method, class InA,
645 class OutA, class OutB, class OutC, class OutD, class OutE>
646inline void DispatchToMethod(ObjT* obj, Method method,
647 const Tuple1<InA>& in,
648 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
649 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d, &out->e);
650}
651
652template<class ObjT, class Method, class InA, class InB,
653 class OutA, class OutB, class OutC, class OutD, class OutE>
654inline void DispatchToMethod(ObjT* obj, Method method,
655 const Tuple2<InA, InB>& in,
656 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
657 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d, &out->e);
658}
659
660template<class ObjT, class Method, class InA, class InB, class InC,
661 class OutA, class OutB, class OutC, class OutD, class OutE>
662inline void DispatchToMethod(ObjT* obj, Method method,
663 const Tuple3<InA, InB, InC>& in,
664 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
665 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d, &out->e);
666}
667
668template<class ObjT, class Method, class InA, class InB, class InC, class InD,
669 class OutA, class OutB, class OutC, class OutD, class OutE>
670inline void DispatchToMethod(ObjT* obj, Method method,
671 const Tuple4<InA, InB, InC, InD>& in,
672 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
673 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d,
674 &out->e);
675}
676
677template<class ObjT, class Method,
678 class InA, class InB, class InC, class InD, class InE,
679 class OutA, class OutB, class OutC, class OutD, class OutE>
680inline void DispatchToMethod(ObjT* obj, Method method,
681 const Tuple5<InA, InB, InC, InD, InE>& in,
682 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
683 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
684 &out->a, &out->b, &out->c, &out->d, &out->e);
685}
686
687#endif // BASE_TUPLE_H__