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