Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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.
11 //
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.
14 //
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");
19 //
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")
24 //
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 ----------------------------------------------------------------------
33 //
34 // A simple traits class for tuple arguments.
35 //
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;
45 };
47 template <class P>
48 struct TupleTraits<P&> {
49 typedef P ValueType;
50 typedef P& RefType;
51 typedef P& ParamType;
52 };
54 // Tuple -----------------------------------------------------------------------
55 //
56 // This set of classes is useful for bundling 0 or more heterogeneous data types
57 // into a single variable. The advantage of this is that it greatly simplifies
58 // function objects that need to take an arbitrary number of parameters; see
59 // RunnableMethod and IPC::MessageWithTuple.
60 //
61 // Tuple0 is supplied to act as a 'void' type. It can be used, for example,
62 // when dispatching to a function that accepts no arguments (see the
63 // Dispatchers below).
64 // Tuple1<A> is rarely useful. One such use is when A is non-const ref that you
65 // want filled by the dispatchee, and the tuple is merely a container for that
66 // output (a "tier"). See MakeRefTuple and its usages.
68 struct Tuple0 {
69 typedef Tuple0 ValueTuple;
70 typedef Tuple0 RefTuple;
71 };
73 template <class A>
74 struct Tuple1 {
75 public:
76 typedef A TypeA;
77 typedef Tuple1<typename TupleTraits<A>::ValueType> ValueTuple;
78 typedef Tuple1<typename TupleTraits<A>::RefType> RefTuple;
80 Tuple1() {}
81 explicit Tuple1(typename TupleTraits<A>::ParamType a) : a(a) {}
83 A a;
84 };
86 template <class A, class B>
87 struct Tuple2 {
88 public:
89 typedef A TypeA;
90 typedef B TypeB;
91 typedef Tuple2<typename TupleTraits<A>::ValueType,
92 typename TupleTraits<B>::ValueType> ValueTuple;
93 typedef Tuple2<typename TupleTraits<A>::RefType,
94 typename TupleTraits<B>::RefType> RefTuple;
96 Tuple2() {}
97 Tuple2(typename TupleTraits<A>::ParamType a,
98 typename TupleTraits<B>::ParamType b)
99 : a(a), b(b) {
100 }
102 A a;
103 B b;
104 };
106 template <class A, class B, class C>
107 struct Tuple3 {
108 public:
109 typedef A TypeA;
110 typedef B TypeB;
111 typedef C TypeC;
112 typedef Tuple3<typename TupleTraits<A>::ValueType,
113 typename TupleTraits<B>::ValueType,
114 typename TupleTraits<C>::ValueType> ValueTuple;
115 typedef Tuple3<typename TupleTraits<A>::RefType,
116 typename TupleTraits<B>::RefType,
117 typename TupleTraits<C>::RefType> RefTuple;
119 Tuple3() {}
120 Tuple3(typename TupleTraits<A>::ParamType a,
121 typename TupleTraits<B>::ParamType b,
122 typename TupleTraits<C>::ParamType c)
123 : a(a), b(b), c(c){
124 }
126 A a;
127 B b;
128 C c;
129 };
131 template <class A, class B, class C, class D>
132 struct Tuple4 {
133 public:
134 typedef A TypeA;
135 typedef B TypeB;
136 typedef C TypeC;
137 typedef D TypeD;
138 typedef Tuple4<typename TupleTraits<A>::ValueType,
139 typename TupleTraits<B>::ValueType,
140 typename TupleTraits<C>::ValueType,
141 typename TupleTraits<D>::ValueType> ValueTuple;
142 typedef Tuple4<typename TupleTraits<A>::RefType,
143 typename TupleTraits<B>::RefType,
144 typename TupleTraits<C>::RefType,
145 typename TupleTraits<D>::RefType> RefTuple;
147 Tuple4() {}
148 Tuple4(typename TupleTraits<A>::ParamType a,
149 typename TupleTraits<B>::ParamType b,
150 typename TupleTraits<C>::ParamType c,
151 typename TupleTraits<D>::ParamType d)
152 : a(a), b(b), c(c), d(d) {
153 }
155 A a;
156 B b;
157 C c;
158 D d;
159 };
161 template <class A, class B, class C, class D, class E>
162 struct Tuple5 {
163 public:
164 typedef A TypeA;
165 typedef B TypeB;
166 typedef C TypeC;
167 typedef D TypeD;
168 typedef E TypeE;
169 typedef Tuple5<typename TupleTraits<A>::ValueType,
170 typename TupleTraits<B>::ValueType,
171 typename TupleTraits<C>::ValueType,
172 typename TupleTraits<D>::ValueType,
173 typename TupleTraits<E>::ValueType> ValueTuple;
174 typedef Tuple5<typename TupleTraits<A>::RefType,
175 typename TupleTraits<B>::RefType,
176 typename TupleTraits<C>::RefType,
177 typename TupleTraits<D>::RefType,
178 typename TupleTraits<E>::RefType> RefTuple;
180 Tuple5() {}
181 Tuple5(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 : a(a), b(b), c(c), d(d), e(e) {
187 }
189 A a;
190 B b;
191 C c;
192 D d;
193 E e;
194 };
196 template <class A, class B, class C, class D, class E, class F>
197 struct Tuple6 {
198 public:
199 typedef A TypeA;
200 typedef B TypeB;
201 typedef C TypeC;
202 typedef D TypeD;
203 typedef E TypeE;
204 typedef F TypeF;
205 typedef Tuple6<typename TupleTraits<A>::ValueType,
206 typename TupleTraits<B>::ValueType,
207 typename TupleTraits<C>::ValueType,
208 typename TupleTraits<D>::ValueType,
209 typename TupleTraits<E>::ValueType,
210 typename TupleTraits<F>::ValueType> ValueTuple;
211 typedef Tuple6<typename TupleTraits<A>::RefType,
212 typename TupleTraits<B>::RefType,
213 typename TupleTraits<C>::RefType,
214 typename TupleTraits<D>::RefType,
215 typename TupleTraits<E>::RefType,
216 typename TupleTraits<F>::RefType> RefTuple;
218 Tuple6() {}
219 Tuple6(typename TupleTraits<A>::ParamType a,
220 typename TupleTraits<B>::ParamType b,
221 typename TupleTraits<C>::ParamType c,
222 typename TupleTraits<D>::ParamType d,
223 typename TupleTraits<E>::ParamType e,
224 typename TupleTraits<F>::ParamType f)
225 : a(a), b(b), c(c), d(d), e(e), f(f) {
226 }
228 A a;
229 B b;
230 C c;
231 D d;
232 E e;
233 F f;
234 };
236 template <class A, class B, class C, class D, class E, class F, class G>
237 struct Tuple7 {
238 public:
239 typedef A TypeA;
240 typedef B TypeB;
241 typedef C TypeC;
242 typedef D TypeD;
243 typedef E TypeE;
244 typedef F TypeF;
245 typedef G TypeG;
246 typedef Tuple7<typename TupleTraits<A>::ValueType,
247 typename TupleTraits<B>::ValueType,
248 typename TupleTraits<C>::ValueType,
249 typename TupleTraits<D>::ValueType,
250 typename TupleTraits<E>::ValueType,
251 typename TupleTraits<F>::ValueType,
252 typename TupleTraits<G>::ValueType> ValueTuple;
253 typedef Tuple7<typename TupleTraits<A>::RefType,
254 typename TupleTraits<B>::RefType,
255 typename TupleTraits<C>::RefType,
256 typename TupleTraits<D>::RefType,
257 typename TupleTraits<E>::RefType,
258 typename TupleTraits<F>::RefType,
259 typename TupleTraits<G>::RefType> RefTuple;
261 Tuple7() {}
262 Tuple7(typename TupleTraits<A>::ParamType a,
263 typename TupleTraits<B>::ParamType b,
264 typename TupleTraits<C>::ParamType c,
265 typename TupleTraits<D>::ParamType d,
266 typename TupleTraits<E>::ParamType e,
267 typename TupleTraits<F>::ParamType f,
268 typename TupleTraits<G>::ParamType g)
269 : a(a), b(b), c(c), d(d), e(e), f(f), g(g) {
270 }
272 A a;
273 B b;
274 C c;
275 D d;
276 E e;
277 F f;
278 G g;
279 };
281 // Tuple creators -------------------------------------------------------------
282 //
283 // Helper functions for constructing tuples while inferring the template
284 // argument types.
286 inline Tuple0 MakeTuple() {
287 return Tuple0();
288 }
290 template <class A>
291 inline Tuple1<A> MakeTuple(const A& a) {
292 return Tuple1<A>(a);
293 }
295 template <class A, class B>
296 inline Tuple2<A, B> MakeTuple(const A& a, const B& b) {
297 return Tuple2<A, B>(a, b);
298 }
300 template <class A, class B, class C>
301 inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c) {
302 return Tuple3<A, B, C>(a, b, c);
303 }
305 template <class A, class B, class C, class D>
306 inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c,
307 const D& d) {
308 return Tuple4<A, B, C, D>(a, b, c, d);
309 }
311 template <class A, class B, class C, class D, class E>
312 inline Tuple5<A, B, C, D, E> MakeTuple(const A& a, const B& b, const C& c,
313 const D& d, const E& e) {
314 return Tuple5<A, B, C, D, E>(a, b, c, d, e);
315 }
317 template <class A, class B, class C, class D, class E, class F>
318 inline Tuple6<A, B, C, D, E, F> MakeTuple(const A& a, const B& b, const C& c,
319 const D& d, const E& e, const F& f) {
320 return Tuple6<A, B, C, D, E, F>(a, b, c, d, e, f);
321 }
323 template <class A, class B, class C, class D, class E, class F, class G>
324 inline Tuple7<A, B, C, D, E, F, G> MakeTuple(const A& a, const B& b, const C& c,
325 const D& d, const E& e, const F& f,
326 const G& g) {
327 return Tuple7<A, B, C, D, E, F, G>(a, b, c, d, e, f, g);
328 }
330 // The following set of helpers make what Boost refers to as "Tiers" - a tuple
331 // of references.
333 template <class A>
334 inline Tuple1<A&> MakeRefTuple(A& a) {
335 return Tuple1<A&>(a);
336 }
338 template <class A, class B>
339 inline Tuple2<A&, B&> MakeRefTuple(A& a, B& b) {
340 return Tuple2<A&, B&>(a, b);
341 }
343 template <class A, class B, class C>
344 inline Tuple3<A&, B&, C&> MakeRefTuple(A& a, B& b, C& c) {
345 return Tuple3<A&, B&, C&>(a, b, c);
346 }
348 template <class A, class B, class C, class D>
349 inline Tuple4<A&, B&, C&, D&> MakeRefTuple(A& a, B& b, C& c, D& d) {
350 return Tuple4<A&, B&, C&, D&>(a, b, c, d);
351 }
353 template <class A, class B, class C, class D, class E>
354 inline Tuple5<A&, B&, C&, D&, E&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e) {
355 return Tuple5<A&, B&, C&, D&, E&>(a, b, c, d, e);
356 }
358 template <class A, class B, class C, class D, class E, class F>
359 inline Tuple6<A&, B&, C&, D&, E&, F&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e,
360 F& f) {
361 return Tuple6<A&, B&, C&, D&, E&, F&>(a, b, c, d, e, f);
362 }
364 template <class A, class B, class C, class D, class E, class F, class G>
365 inline Tuple7<A&, B&, C&, D&, E&, F&, G&> MakeRefTuple(A& a, B& b, C& c, D& d,
366 E& e, F& f, G& g) {
367 return Tuple7<A&, B&, C&, D&, E&, F&, G&>(a, b, c, d, e, f, g);
368 }
370 // Dispatchers ----------------------------------------------------------------
371 //
372 // Helper functions that call the given method on an object, with the unpacked
373 // tuple arguments. Notice that they all have the same number of arguments,
374 // so you need only write:
375 // DispatchToMethod(object, &Object::method, args);
376 // This is very useful for templated dispatchers, since they don't need to know
377 // what type |args| is.
379 // Non-Static Dispatchers with no out params.
381 template <class ObjT, class Method>
382 inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) {
383 (obj->*method)();
384 }
386 template <class ObjT, class Method, class A>
387 inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) {
388 (obj->*method)(arg);
389 }
391 template <class ObjT, class Method, class A>
392 inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) {
393 (obj->*method)(arg.a);
394 }
396 template<class ObjT, class Method, class A, class B>
397 inline void DispatchToMethod(ObjT* obj,
398 Method method,
399 const Tuple2<A, B>& arg) {
400 (obj->*method)(arg.a, arg.b);
401 }
403 template<class ObjT, class Method, class A, class B, class C>
404 inline void DispatchToMethod(ObjT* obj, Method method,
405 const Tuple3<A, B, C>& arg) {
406 (obj->*method)(arg.a, arg.b, arg.c);
407 }
409 template<class ObjT, class Method, class A, class B, class C, class D>
410 inline void DispatchToMethod(ObjT* obj, Method method,
411 const Tuple4<A, B, C, D>& arg) {
412 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
413 }
415 template<class ObjT, class Method, class A, class B, class C, class D, class E>
416 inline void DispatchToMethod(ObjT* obj, Method method,
417 const Tuple5<A, B, C, D, E>& arg) {
418 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
419 }
421 template<class ObjT, class Method, class A, class B, class C, class D, class E,
422 class F>
423 inline void DispatchToMethod(ObjT* obj, Method method,
424 const Tuple6<A, B, C, D, E, F>& arg) {
425 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
426 }
428 template<class ObjT, class Method, class A, class B, class C, class D, class E,
429 class F, class G>
430 inline void DispatchToMethod(ObjT* obj, Method method,
431 const Tuple7<A, B, C, D, E, F, G>& arg) {
432 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g);
433 }
435 // Static Dispatchers with no out params.
437 template <class Function>
438 inline void DispatchToFunction(Function function, const Tuple0& arg) {
439 (*function)();
440 }
442 template <class Function, class A>
443 inline void DispatchToFunction(Function function, const A& arg) {
444 (*function)(arg);
445 }
447 template <class Function, class A>
448 inline void DispatchToFunction(Function function, const Tuple1<A>& arg) {
449 (*function)(arg.a);
450 }
452 template<class Function, class A, class B>
453 inline void DispatchToFunction(Function function, const Tuple2<A, B>& arg) {
454 (*function)(arg.a, arg.b);
455 }
457 template<class Function, class A, class B, class C>
458 inline void DispatchToFunction(Function function, const Tuple3<A, B, C>& arg) {
459 (*function)(arg.a, arg.b, arg.c);
460 }
462 template<class Function, class A, class B, class C, class D>
463 inline void DispatchToFunction(Function function,
464 const Tuple4<A, B, C, D>& arg) {
465 (*function)(arg.a, arg.b, arg.c, arg.d);
466 }
468 template<class Function, class A, class B, class C, class D, class E>
469 inline void DispatchToFunction(Function function,
470 const Tuple5<A, B, C, D, E>& arg) {
471 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e);
472 }
474 template<class Function, class A, class B, class C, class D, class E, class F>
475 inline void DispatchToFunction(Function function,
476 const Tuple6<A, B, C, D, E, F>& arg) {
477 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
478 }
480 // Dispatchers with 0 out param (as a Tuple0).
482 template <class ObjT, class Method>
483 inline void DispatchToMethod(ObjT* obj,
484 Method method,
485 const Tuple0& arg, Tuple0*) {
486 (obj->*method)();
487 }
489 template <class ObjT, class Method, class A>
490 inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) {
491 (obj->*method)(arg);
492 }
494 template <class ObjT, class Method, class A>
495 inline void DispatchToMethod(ObjT* obj,
496 Method method,
497 const Tuple1<A>& arg, Tuple0*) {
498 (obj->*method)(arg.a);
499 }
501 template<class ObjT, class Method, class A, class B>
502 inline void DispatchToMethod(ObjT* obj,
503 Method method,
504 const Tuple2<A, B>& arg, Tuple0*) {
505 (obj->*method)(arg.a, arg.b);
506 }
508 template<class ObjT, class Method, class A, class B, class C>
509 inline void DispatchToMethod(ObjT* obj, Method method,
510 const Tuple3<A, B, C>& arg, Tuple0*) {
511 (obj->*method)(arg.a, arg.b, arg.c);
512 }
514 template<class ObjT, class Method, class A, class B, class C, class D>
515 inline void DispatchToMethod(ObjT* obj, Method method,
516 const Tuple4<A, B, C, D>& arg, Tuple0*) {
517 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
518 }
520 template<class ObjT, class Method, class A, class B, class C, class D, class E>
521 inline void DispatchToMethod(ObjT* obj, Method method,
522 const Tuple5<A, B, C, D, E>& arg, Tuple0*) {
523 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
524 }
526 template<class ObjT, class Method, class A, class B, class C, class D, class E,
527 class F>
528 inline void DispatchToMethod(ObjT* obj, Method method,
529 const Tuple6<A, B, C, D, E, F>& arg, Tuple0*) {
530 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
531 }
533 // Dispatchers with 1 out param.
535 template<class ObjT, class Method,
536 class OutA>
537 inline void DispatchToMethod(ObjT* obj, Method method,
538 const Tuple0& in,
539 Tuple1<OutA>* out) {
540 (obj->*method)(&out->a);
541 }
543 template<class ObjT, class Method, class InA,
544 class OutA>
545 inline void DispatchToMethod(ObjT* obj, Method method,
546 const InA& in,
547 Tuple1<OutA>* out) {
548 (obj->*method)(in, &out->a);
549 }
551 template<class ObjT, class Method, class InA,
552 class OutA>
553 inline void DispatchToMethod(ObjT* obj, Method method,
554 const Tuple1<InA>& in,
555 Tuple1<OutA>* out) {
556 (obj->*method)(in.a, &out->a);
557 }
559 template<class ObjT, class Method, class InA, class InB,
560 class OutA>
561 inline void DispatchToMethod(ObjT* obj, Method method,
562 const Tuple2<InA, InB>& in,
563 Tuple1<OutA>* out) {
564 (obj->*method)(in.a, in.b, &out->a);
565 }
567 template<class ObjT, class Method, class InA, class InB, class InC,
568 class OutA>
569 inline void DispatchToMethod(ObjT* obj, Method method,
570 const Tuple3<InA, InB, InC>& in,
571 Tuple1<OutA>* out) {
572 (obj->*method)(in.a, in.b, in.c, &out->a);
573 }
575 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
576 class OutA>
577 inline void DispatchToMethod(ObjT* obj, Method method,
578 const Tuple4<InA, InB, InC, InD>& in,
579 Tuple1<OutA>* out) {
580 (obj->*method)(in.a, in.b, in.c, in.d, &out->a);
581 }
583 template<class ObjT, class Method,
584 class InA, class InB, class InC, class InD, class InE,
585 class OutA>
586 inline void DispatchToMethod(ObjT* obj, Method method,
587 const Tuple5<InA, InB, InC, InD, InE>& in,
588 Tuple1<OutA>* out) {
589 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a);
590 }
592 template<class ObjT, class Method,
593 class InA, class InB, class InC, class InD, class InE, class InF,
594 class OutA>
595 inline void DispatchToMethod(ObjT* obj, Method method,
596 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
597 Tuple1<OutA>* out) {
598 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a);
599 }
601 // Dispatchers with 2 out params.
603 template<class ObjT, class Method,
604 class OutA, class OutB>
605 inline void DispatchToMethod(ObjT* obj, Method method,
606 const Tuple0& in,
607 Tuple2<OutA, OutB>* out) {
608 (obj->*method)(&out->a, &out->b);
609 }
611 template<class ObjT, class Method, class InA,
612 class OutA, class OutB>
613 inline void DispatchToMethod(ObjT* obj, Method method,
614 const InA& in,
615 Tuple2<OutA, OutB>* out) {
616 (obj->*method)(in, &out->a, &out->b);
617 }
619 template<class ObjT, class Method, class InA,
620 class OutA, class OutB>
621 inline void DispatchToMethod(ObjT* obj, Method method,
622 const Tuple1<InA>& in,
623 Tuple2<OutA, OutB>* out) {
624 (obj->*method)(in.a, &out->a, &out->b);
625 }
627 template<class ObjT, class Method, class InA, class InB,
628 class OutA, class OutB>
629 inline void DispatchToMethod(ObjT* obj, Method method,
630 const Tuple2<InA, InB>& in,
631 Tuple2<OutA, OutB>* out) {
632 (obj->*method)(in.a, in.b, &out->a, &out->b);
633 }
635 template<class ObjT, class Method, class InA, class InB, class InC,
636 class OutA, class OutB>
637 inline void DispatchToMethod(ObjT* obj, Method method,
638 const Tuple3<InA, InB, InC>& in,
639 Tuple2<OutA, OutB>* out) {
640 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b);
641 }
643 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
644 class OutA, class OutB>
645 inline void DispatchToMethod(ObjT* obj, Method method,
646 const Tuple4<InA, InB, InC, InD>& in,
647 Tuple2<OutA, OutB>* out) {
648 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b);
649 }
651 template<class ObjT, class Method,
652 class InA, class InB, class InC, class InD, class InE,
653 class OutA, class OutB>
654 inline void DispatchToMethod(ObjT* obj, Method method,
655 const Tuple5<InA, InB, InC, InD, InE>& in,
656 Tuple2<OutA, OutB>* out) {
657 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b);
658 }
660 template<class ObjT, class Method,
661 class InA, class InB, class InC, class InD, class InE, class InF,
662 class OutA, class OutB>
663 inline void DispatchToMethod(ObjT* obj, Method method,
664 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
665 Tuple2<OutA, OutB>* out) {
666 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b);
667 }
669 // Dispatchers with 3 out params.
671 template<class ObjT, class Method,
672 class OutA, class OutB, class OutC>
673 inline void DispatchToMethod(ObjT* obj, Method method,
674 const Tuple0& in,
675 Tuple3<OutA, OutB, OutC>* out) {
676 (obj->*method)(&out->a, &out->b, &out->c);
677 }
679 template<class ObjT, class Method, class InA,
680 class OutA, class OutB, class OutC>
681 inline void DispatchToMethod(ObjT* obj, Method method,
682 const InA& in,
683 Tuple3<OutA, OutB, OutC>* out) {
684 (obj->*method)(in, &out->a, &out->b, &out->c);
685 }
687 template<class ObjT, class Method, class InA,
688 class OutA, class OutB, class OutC>
689 inline void DispatchToMethod(ObjT* obj, Method method,
690 const Tuple1<InA>& in,
691 Tuple3<OutA, OutB, OutC>* out) {
692 (obj->*method)(in.a, &out->a, &out->b, &out->c);
693 }
695 template<class ObjT, class Method, class InA, class InB,
696 class OutA, class OutB, class OutC>
697 inline void DispatchToMethod(ObjT* obj, Method method,
698 const Tuple2<InA, InB>& in,
699 Tuple3<OutA, OutB, OutC>* out) {
700 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c);
701 }
703 template<class ObjT, class Method, class InA, class InB, class InC,
704 class OutA, class OutB, class OutC>
705 inline void DispatchToMethod(ObjT* obj, Method method,
706 const Tuple3<InA, InB, InC>& in,
707 Tuple3<OutA, OutB, OutC>* out) {
708 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c);
709 }
711 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
712 class OutA, class OutB, class OutC>
713 inline void DispatchToMethod(ObjT* obj, Method method,
714 const Tuple4<InA, InB, InC, InD>& in,
715 Tuple3<OutA, OutB, OutC>* out) {
716 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c);
717 }
719 template<class ObjT, class Method,
720 class InA, class InB, class InC, class InD, class InE,
721 class OutA, class OutB, class OutC>
722 inline void DispatchToMethod(ObjT* obj, Method method,
723 const Tuple5<InA, InB, InC, InD, InE>& in,
724 Tuple3<OutA, OutB, OutC>* out) {
725 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c);
726 }
728 template<class ObjT, class Method,
729 class InA, class InB, class InC, class InD, class InE, class InF,
730 class OutA, class OutB, class OutC>
731 inline void DispatchToMethod(ObjT* obj, Method method,
732 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
733 Tuple3<OutA, OutB, OutC>* out) {
734 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b, &out->c);
735 }
737 // Dispatchers with 4 out params.
739 template<class ObjT, class Method,
740 class OutA, class OutB, class OutC, class OutD>
741 inline void DispatchToMethod(ObjT* obj, Method method,
742 const Tuple0& in,
743 Tuple4<OutA, OutB, OutC, OutD>* out) {
744 (obj->*method)(&out->a, &out->b, &out->c, &out->d);
745 }
747 template<class ObjT, class Method, class InA,
748 class OutA, class OutB, class OutC, class OutD>
749 inline void DispatchToMethod(ObjT* obj, Method method,
750 const InA& in,
751 Tuple4<OutA, OutB, OutC, OutD>* out) {
752 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d);
753 }
755 template<class ObjT, class Method, class InA,
756 class OutA, class OutB, class OutC, class OutD>
757 inline void DispatchToMethod(ObjT* obj, Method method,
758 const Tuple1<InA>& in,
759 Tuple4<OutA, OutB, OutC, OutD>* out) {
760 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d);
761 }
763 template<class ObjT, class Method, class InA, class InB,
764 class OutA, class OutB, class OutC, class OutD>
765 inline void DispatchToMethod(ObjT* obj, Method method,
766 const Tuple2<InA, InB>& in,
767 Tuple4<OutA, OutB, OutC, OutD>* out) {
768 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d);
769 }
771 template<class ObjT, class Method, class InA, class InB, class InC,
772 class OutA, class OutB, class OutC, class OutD>
773 inline void DispatchToMethod(ObjT* obj, Method method,
774 const Tuple3<InA, InB, InC>& in,
775 Tuple4<OutA, OutB, OutC, OutD>* out) {
776 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d);
777 }
779 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
780 class OutA, class OutB, class OutC, class OutD>
781 inline void DispatchToMethod(ObjT* obj, Method method,
782 const Tuple4<InA, InB, InC, InD>& in,
783 Tuple4<OutA, OutB, OutC, OutD>* out) {
784 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d);
785 }
787 template<class ObjT, class Method,
788 class InA, class InB, class InC, class InD, class InE,
789 class OutA, class OutB, class OutC, class OutD>
790 inline void DispatchToMethod(ObjT* obj, Method method,
791 const Tuple5<InA, InB, InC, InD, InE>& in,
792 Tuple4<OutA, OutB, OutC, OutD>* out) {
793 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
794 &out->a, &out->b, &out->c, &out->d);
795 }
797 template<class ObjT, class Method,
798 class InA, class InB, class InC, class InD, class InE, class InF,
799 class OutA, class OutB, class OutC, class OutD>
800 inline void DispatchToMethod(ObjT* obj, Method method,
801 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
802 Tuple4<OutA, OutB, OutC, OutD>* out) {
803 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f,
804 &out->a, &out->b, &out->c, &out->d);
805 }
807 // Dispatchers with 5 out params.
809 template<class ObjT, class Method,
810 class OutA, class OutB, class OutC, class OutD, class OutE>
811 inline void DispatchToMethod(ObjT* obj, Method method,
812 const Tuple0& in,
813 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
814 (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e);
815 }
817 template<class ObjT, class Method, class InA,
818 class OutA, class OutB, class OutC, class OutD, class OutE>
819 inline void DispatchToMethod(ObjT* obj, Method method,
820 const InA& in,
821 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
822 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d, &out->e);
823 }
825 template<class ObjT, class Method, class InA,
826 class OutA, class OutB, class OutC, class OutD, class OutE>
827 inline void DispatchToMethod(ObjT* obj, Method method,
828 const Tuple1<InA>& in,
829 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
830 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d, &out->e);
831 }
833 template<class ObjT, class Method, class InA, class InB,
834 class OutA, class OutB, class OutC, class OutD, class OutE>
835 inline void DispatchToMethod(ObjT* obj, Method method,
836 const Tuple2<InA, InB>& in,
837 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
838 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d, &out->e);
839 }
841 template<class ObjT, class Method, class InA, class InB, class InC,
842 class OutA, class OutB, class OutC, class OutD, class OutE>
843 inline void DispatchToMethod(ObjT* obj, Method method,
844 const Tuple3<InA, InB, InC>& in,
845 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
846 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d, &out->e);
847 }
849 template<class ObjT, class Method, class InA, class InB, class InC, class InD,
850 class OutA, class OutB, class OutC, class OutD, class OutE>
851 inline void DispatchToMethod(ObjT* obj, Method method,
852 const Tuple4<InA, InB, InC, InD>& in,
853 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
854 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d,
855 &out->e);
856 }
858 template<class ObjT, class Method,
859 class InA, class InB, class InC, class InD, class InE,
860 class OutA, class OutB, class OutC, class OutD, class OutE>
861 inline void DispatchToMethod(ObjT* obj, Method method,
862 const Tuple5<InA, InB, InC, InD, InE>& in,
863 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
864 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
865 &out->a, &out->b, &out->c, &out->d, &out->e);
866 }
868 template<class ObjT, class Method,
869 class InA, class InB, class InC, class InD, class InE, class InF,
870 class OutA, class OutB, class OutC, class OutD, class OutE>
871 inline void DispatchToMethod(ObjT* obj, Method method,
872 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
873 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
874 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f,
875 &out->a, &out->b, &out->c, &out->d, &out->e);
876 }
878 #endif // BASE_TUPLE_H__