1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // A Tuple is a generic templatized container, similar in concept to std::pair.
6 // There are classes Tuple0 to Tuple6, cooresponding to the number of elements
7 // it contains. The convenient MakeTuple() function takes 0 to 6 arguments,
8 // and will construct and return the appropriate Tuple object. The functions
9 // DispatchToMethod and DispatchToFunction take a function pointer or instance
10 // and method pointer, and unpack a tuple into arguments to the call.
12 // Tuple elements are copied by value, and stored in the tuple. See the unit
13 // tests for more details of how/when the values are copied.
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 // Traits ----------------------------------------------------------------------
35 // A simple traits class for tuple arguments.
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).
45 typedef const P
& ParamType
;
49 struct TupleTraits
<P
&> {
56 struct TupleTypes
{ };
58 // Tuple -----------------------------------------------------------------------
60 // This set of classes is useful for bundling 0 or more heterogeneous data types
61 // into a single variable. The advantage of this is that it greatly simplifies
62 // function objects that need to take an arbitrary number of parameters; see
63 // RunnableMethod and IPC::MessageWithTuple.
65 // Tuple0 is supplied to act as a 'void' type. It can be used, for example,
66 // when dispatching to a function that accepts no arguments (see the
67 // Dispatchers below).
68 // Tuple1<A> is rarely useful. One such use is when A is non-const ref that you
69 // want filled by the dispatchee, and the tuple is merely a container for that
70 // output (a "tier"). See MakeRefTuple and its usages.
73 typedef Tuple0 ValueTuple
;
74 typedef Tuple0 RefTuple
;
75 typedef Tuple0 ParamTuple
;
84 explicit Tuple1(typename TupleTraits
<A
>::ParamType a
) : a(a
) {}
89 template <class A
, class B
>
96 Tuple2(typename TupleTraits
<A
>::ParamType a
,
97 typename TupleTraits
<B
>::ParamType b
)
105 template <class A
, class B
, class C
>
113 Tuple3(typename TupleTraits
<A
>::ParamType a
,
114 typename TupleTraits
<B
>::ParamType b
,
115 typename TupleTraits
<C
>::ParamType c
)
124 template <class A
, class B
, class C
, class D
>
133 Tuple4(typename TupleTraits
<A
>::ParamType a
,
134 typename TupleTraits
<B
>::ParamType b
,
135 typename TupleTraits
<C
>::ParamType c
,
136 typename TupleTraits
<D
>::ParamType d
)
137 : a(a
), b(b
), c(c
), d(d
) {
146 template <class A
, class B
, class C
, class D
, class E
>
156 Tuple5(typename TupleTraits
<A
>::ParamType a
,
157 typename TupleTraits
<B
>::ParamType b
,
158 typename TupleTraits
<C
>::ParamType c
,
159 typename TupleTraits
<D
>::ParamType d
,
160 typename TupleTraits
<E
>::ParamType e
)
161 : a(a
), b(b
), c(c
), d(d
), e(e
) {
171 template <class A
, class B
, class C
, class D
, class E
, class F
>
182 Tuple6(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 typename TupleTraits
<F
>::ParamType f
)
188 : a(a
), b(b
), c(c
), d(d
), e(e
), f(f
) {
199 template <class A
, class B
, class C
, class D
, class E
, class F
, class G
>
211 Tuple7(typename TupleTraits
<A
>::ParamType a
,
212 typename TupleTraits
<B
>::ParamType b
,
213 typename TupleTraits
<C
>::ParamType c
,
214 typename TupleTraits
<D
>::ParamType d
,
215 typename TupleTraits
<E
>::ParamType e
,
216 typename TupleTraits
<F
>::ParamType f
,
217 typename TupleTraits
<G
>::ParamType g
)
218 : a(a
), b(b
), c(c
), d(d
), e(e
), f(f
), g(g
) {
230 template <class A
, class B
, class C
, class D
, class E
, class F
, class G
,
244 Tuple8(typename TupleTraits
<A
>::ParamType a
,
245 typename TupleTraits
<B
>::ParamType b
,
246 typename TupleTraits
<C
>::ParamType c
,
247 typename TupleTraits
<D
>::ParamType d
,
248 typename TupleTraits
<E
>::ParamType e
,
249 typename TupleTraits
<F
>::ParamType f
,
250 typename TupleTraits
<G
>::ParamType g
,
251 typename TupleTraits
<H
>::ParamType h
)
252 : a(a
), b(b
), c(c
), d(d
), e(e
), f(f
), g(g
), h(h
) {
265 // Tuple types ----------------------------------------------------------------
267 // Allows for selection of ValueTuple/RefTuple/ParamTuple without needing the
268 // definitions of class types the tuple takes as parameters.
271 struct TupleTypes
< Tuple0
> {
272 typedef Tuple0 ValueTuple
;
273 typedef Tuple0 RefTuple
;
274 typedef Tuple0 ParamTuple
;
278 struct TupleTypes
< Tuple1
<A
> > {
279 typedef Tuple1
<typename TupleTraits
<A
>::ValueType
> ValueTuple
;
280 typedef Tuple1
<typename TupleTraits
<A
>::RefType
> RefTuple
;
281 typedef Tuple1
<typename TupleTraits
<A
>::ParamType
> ParamTuple
;
284 template <class A
, class B
>
285 struct TupleTypes
< Tuple2
<A
, B
> > {
286 typedef Tuple2
<typename TupleTraits
<A
>::ValueType
,
287 typename TupleTraits
<B
>::ValueType
> ValueTuple
;
288 typedef Tuple2
<typename TupleTraits
<A
>::RefType
,
289 typename TupleTraits
<B
>::RefType
> RefTuple
;
290 typedef Tuple2
<typename TupleTraits
<A
>::ParamType
,
291 typename TupleTraits
<B
>::ParamType
> ParamTuple
;
294 template <class A
, class B
, class C
>
295 struct TupleTypes
< Tuple3
<A
, B
, C
> > {
296 typedef Tuple3
<typename TupleTraits
<A
>::ValueType
,
297 typename TupleTraits
<B
>::ValueType
,
298 typename TupleTraits
<C
>::ValueType
> ValueTuple
;
299 typedef Tuple3
<typename TupleTraits
<A
>::RefType
,
300 typename TupleTraits
<B
>::RefType
,
301 typename TupleTraits
<C
>::RefType
> RefTuple
;
302 typedef Tuple3
<typename TupleTraits
<A
>::ParamType
,
303 typename TupleTraits
<B
>::ParamType
,
304 typename TupleTraits
<C
>::ParamType
> ParamTuple
;
307 template <class A
, class B
, class C
, class D
>
308 struct TupleTypes
< Tuple4
<A
, B
, C
, D
> > {
309 typedef Tuple4
<typename TupleTraits
<A
>::ValueType
,
310 typename TupleTraits
<B
>::ValueType
,
311 typename TupleTraits
<C
>::ValueType
,
312 typename TupleTraits
<D
>::ValueType
> ValueTuple
;
313 typedef Tuple4
<typename TupleTraits
<A
>::RefType
,
314 typename TupleTraits
<B
>::RefType
,
315 typename TupleTraits
<C
>::RefType
,
316 typename TupleTraits
<D
>::RefType
> RefTuple
;
317 typedef Tuple4
<typename TupleTraits
<A
>::ParamType
,
318 typename TupleTraits
<B
>::ParamType
,
319 typename TupleTraits
<C
>::ParamType
,
320 typename TupleTraits
<D
>::ParamType
> ParamTuple
;
323 template <class A
, class B
, class C
, class D
, class E
>
324 struct TupleTypes
< Tuple5
<A
, B
, C
, D
, E
> > {
325 typedef Tuple5
<typename TupleTraits
<A
>::ValueType
,
326 typename TupleTraits
<B
>::ValueType
,
327 typename TupleTraits
<C
>::ValueType
,
328 typename TupleTraits
<D
>::ValueType
,
329 typename TupleTraits
<E
>::ValueType
> ValueTuple
;
330 typedef Tuple5
<typename TupleTraits
<A
>::RefType
,
331 typename TupleTraits
<B
>::RefType
,
332 typename TupleTraits
<C
>::RefType
,
333 typename TupleTraits
<D
>::RefType
,
334 typename TupleTraits
<E
>::RefType
> RefTuple
;
335 typedef Tuple5
<typename TupleTraits
<A
>::ParamType
,
336 typename TupleTraits
<B
>::ParamType
,
337 typename TupleTraits
<C
>::ParamType
,
338 typename TupleTraits
<D
>::ParamType
,
339 typename TupleTraits
<E
>::ParamType
> ParamTuple
;
342 template <class A
, class B
, class C
, class D
, class E
, class F
>
343 struct TupleTypes
< Tuple6
<A
, B
, C
, D
, E
, F
> > {
344 typedef Tuple6
<typename TupleTraits
<A
>::ValueType
,
345 typename TupleTraits
<B
>::ValueType
,
346 typename TupleTraits
<C
>::ValueType
,
347 typename TupleTraits
<D
>::ValueType
,
348 typename TupleTraits
<E
>::ValueType
,
349 typename TupleTraits
<F
>::ValueType
> ValueTuple
;
350 typedef Tuple6
<typename TupleTraits
<A
>::RefType
,
351 typename TupleTraits
<B
>::RefType
,
352 typename TupleTraits
<C
>::RefType
,
353 typename TupleTraits
<D
>::RefType
,
354 typename TupleTraits
<E
>::RefType
,
355 typename TupleTraits
<F
>::RefType
> RefTuple
;
356 typedef Tuple6
<typename TupleTraits
<A
>::ParamType
,
357 typename TupleTraits
<B
>::ParamType
,
358 typename TupleTraits
<C
>::ParamType
,
359 typename TupleTraits
<D
>::ParamType
,
360 typename TupleTraits
<E
>::ParamType
,
361 typename TupleTraits
<F
>::ParamType
> ParamTuple
;
364 template <class A
, class B
, class C
, class D
, class E
, class F
, class G
>
365 struct TupleTypes
< Tuple7
<A
, B
, C
, D
, E
, F
, G
> > {
366 typedef Tuple7
<typename TupleTraits
<A
>::ValueType
,
367 typename TupleTraits
<B
>::ValueType
,
368 typename TupleTraits
<C
>::ValueType
,
369 typename TupleTraits
<D
>::ValueType
,
370 typename TupleTraits
<E
>::ValueType
,
371 typename TupleTraits
<F
>::ValueType
,
372 typename TupleTraits
<G
>::ValueType
> ValueTuple
;
373 typedef Tuple7
<typename TupleTraits
<A
>::RefType
,
374 typename TupleTraits
<B
>::RefType
,
375 typename TupleTraits
<C
>::RefType
,
376 typename TupleTraits
<D
>::RefType
,
377 typename TupleTraits
<E
>::RefType
,
378 typename TupleTraits
<F
>::RefType
,
379 typename TupleTraits
<G
>::RefType
> RefTuple
;
380 typedef Tuple7
<typename TupleTraits
<A
>::ParamType
,
381 typename TupleTraits
<B
>::ParamType
,
382 typename TupleTraits
<C
>::ParamType
,
383 typename TupleTraits
<D
>::ParamType
,
384 typename TupleTraits
<E
>::ParamType
,
385 typename TupleTraits
<F
>::ParamType
,
386 typename TupleTraits
<G
>::ParamType
> ParamTuple
;
389 template <class A
, class B
, class C
, class D
, class E
, class F
, class G
,
391 struct TupleTypes
< Tuple8
<A
, B
, C
, D
, E
, F
, G
, H
> > {
392 typedef Tuple8
<typename TupleTraits
<A
>::ValueType
,
393 typename TupleTraits
<B
>::ValueType
,
394 typename TupleTraits
<C
>::ValueType
,
395 typename TupleTraits
<D
>::ValueType
,
396 typename TupleTraits
<E
>::ValueType
,
397 typename TupleTraits
<F
>::ValueType
,
398 typename TupleTraits
<G
>::ValueType
,
399 typename TupleTraits
<H
>::ValueType
> ValueTuple
;
400 typedef Tuple8
<typename TupleTraits
<A
>::RefType
,
401 typename TupleTraits
<B
>::RefType
,
402 typename TupleTraits
<C
>::RefType
,
403 typename TupleTraits
<D
>::RefType
,
404 typename TupleTraits
<E
>::RefType
,
405 typename TupleTraits
<F
>::RefType
,
406 typename TupleTraits
<G
>::RefType
,
407 typename TupleTraits
<H
>::RefType
> RefTuple
;
408 typedef Tuple8
<typename TupleTraits
<A
>::ParamType
,
409 typename TupleTraits
<B
>::ParamType
,
410 typename TupleTraits
<C
>::ParamType
,
411 typename TupleTraits
<D
>::ParamType
,
412 typename TupleTraits
<E
>::ParamType
,
413 typename TupleTraits
<F
>::ParamType
,
414 typename TupleTraits
<G
>::ParamType
,
415 typename TupleTraits
<H
>::ParamType
> ParamTuple
;
418 // Tuple creators -------------------------------------------------------------
420 // Helper functions for constructing tuples while inferring the template
423 inline Tuple0
MakeTuple() {
428 inline Tuple1
<A
> MakeTuple(const A
& a
) {
432 template <class A
, class B
>
433 inline Tuple2
<A
, B
> MakeTuple(const A
& a
, const B
& b
) {
434 return Tuple2
<A
, B
>(a
, b
);
437 template <class A
, class B
, class C
>
438 inline Tuple3
<A
, B
, C
> MakeTuple(const A
& a
, const B
& b
, const C
& c
) {
439 return Tuple3
<A
, B
, C
>(a
, b
, c
);
442 template <class A
, class B
, class C
, class D
>
443 inline Tuple4
<A
, B
, C
, D
> MakeTuple(const A
& a
, const B
& b
, const C
& c
,
445 return Tuple4
<A
, B
, C
, D
>(a
, b
, c
, d
);
448 template <class A
, class B
, class C
, class D
, class E
>
449 inline Tuple5
<A
, B
, C
, D
, E
> MakeTuple(const A
& a
, const B
& b
, const C
& c
,
450 const D
& d
, const E
& e
) {
451 return Tuple5
<A
, B
, C
, D
, E
>(a
, b
, c
, d
, e
);
454 template <class A
, class B
, class C
, class D
, class E
, class F
>
455 inline Tuple6
<A
, B
, C
, D
, E
, F
> MakeTuple(const A
& a
, const B
& b
, const C
& c
,
456 const D
& d
, const E
& e
, const F
& f
) {
457 return Tuple6
<A
, B
, C
, D
, E
, F
>(a
, b
, c
, d
, e
, f
);
460 template <class A
, class B
, class C
, class D
, class E
, class F
, class G
>
461 inline Tuple7
<A
, B
, C
, D
, E
, F
, G
> MakeTuple(const A
& a
, const B
& b
, const C
& c
,
462 const D
& d
, const E
& e
, const F
& f
,
464 return Tuple7
<A
, B
, C
, D
, E
, F
, G
>(a
, b
, c
, d
, e
, f
, g
);
467 template <class A
, class B
, class C
, class D
, class E
, class F
, class G
,
469 inline Tuple8
<A
, B
, C
, D
, E
, F
, G
, H
> MakeTuple(const A
& a
, const B
& b
,
470 const C
& c
, const D
& d
,
471 const E
& e
, const F
& f
,
472 const G
& g
, const H
& h
) {
473 return Tuple8
<A
, B
, C
, D
, E
, F
, G
, H
>(a
, b
, c
, d
, e
, f
, g
, h
);
476 // The following set of helpers make what Boost refers to as "Tiers" - a tuple
480 inline Tuple1
<A
&> MakeRefTuple(A
& a
) {
481 return Tuple1
<A
&>(a
);
484 template <class A
, class B
>
485 inline Tuple2
<A
&, B
&> MakeRefTuple(A
& a
, B
& b
) {
486 return Tuple2
<A
&, B
&>(a
, b
);
489 template <class A
, class B
, class C
>
490 inline Tuple3
<A
&, B
&, C
&> MakeRefTuple(A
& a
, B
& b
, C
& c
) {
491 return Tuple3
<A
&, B
&, C
&>(a
, b
, c
);
494 template <class A
, class B
, class C
, class D
>
495 inline Tuple4
<A
&, B
&, C
&, D
&> MakeRefTuple(A
& a
, B
& b
, C
& c
, D
& d
) {
496 return Tuple4
<A
&, B
&, C
&, D
&>(a
, b
, c
, d
);
499 template <class A
, class B
, class C
, class D
, class E
>
500 inline Tuple5
<A
&, B
&, C
&, D
&, E
&> MakeRefTuple(A
& a
, B
& b
, C
& c
, D
& d
, E
& e
) {
501 return Tuple5
<A
&, B
&, C
&, D
&, E
&>(a
, b
, c
, d
, e
);
504 template <class A
, class B
, class C
, class D
, class E
, class F
>
505 inline Tuple6
<A
&, B
&, C
&, D
&, E
&, F
&> MakeRefTuple(A
& a
, B
& b
, C
& c
, D
& d
, E
& e
,
507 return Tuple6
<A
&, B
&, C
&, D
&, E
&, F
&>(a
, b
, c
, d
, e
, f
);
510 template <class A
, class B
, class C
, class D
, class E
, class F
, class G
>
511 inline Tuple7
<A
&, B
&, C
&, D
&, E
&, F
&, G
&> MakeRefTuple(A
& a
, B
& b
, C
& c
, D
& d
,
513 return Tuple7
<A
&, B
&, C
&, D
&, E
&, F
&, G
&>(a
, b
, c
, d
, e
, f
, g
);
516 template <class A
, class B
, class C
, class D
, class E
, class F
, class G
,
518 inline Tuple8
<A
&, B
&, C
&, D
&, E
&, F
&, G
&, H
&> MakeRefTuple(A
& a
, B
& b
, C
& c
,
521 return Tuple8
<A
&, B
&, C
&, D
&, E
&, F
&, G
&, H
&>(a
, b
, c
, d
, e
, f
, g
, h
);
524 // Dispatchers ----------------------------------------------------------------
526 // Helper functions that call the given method on an object, with the unpacked
527 // tuple arguments. Notice that they all have the same number of arguments,
528 // so you need only write:
529 // DispatchToMethod(object, &Object::method, args);
530 // This is very useful for templated dispatchers, since they don't need to know
531 // what type |args| is.
533 // Non-Static Dispatchers with no out params.
535 template <class ObjT
, class Method
>
536 inline void DispatchToMethod(ObjT
* obj
, Method method
, const Tuple0
& arg
) {
540 template <class ObjT
, class Method
, class A
>
541 inline void DispatchToMethod(ObjT
* obj
, Method method
, const A
& arg
) {
545 template <class ObjT
, class Method
, class A
>
546 inline void DispatchToMethod(ObjT
* obj
, Method method
, const Tuple1
<A
>& arg
) {
547 (obj
->*method
)(arg
.a
);
550 template<class ObjT
, class Method
, class A
, class B
>
551 inline void DispatchToMethod(ObjT
* obj
,
553 const Tuple2
<A
, B
>& arg
) {
554 (obj
->*method
)(arg
.a
, arg
.b
);
557 template<class ObjT
, class Method
, class A
, class B
, class C
>
558 inline void DispatchToMethod(ObjT
* obj
, Method method
,
559 const Tuple3
<A
, B
, C
>& arg
) {
560 (obj
->*method
)(arg
.a
, arg
.b
, arg
.c
);
563 template<class ObjT
, class Method
, class A
, class B
, class C
, class D
>
564 inline void DispatchToMethod(ObjT
* obj
, Method method
,
565 const Tuple4
<A
, B
, C
, D
>& arg
) {
566 (obj
->*method
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
);
569 template<class ObjT
, class Method
, class A
, class B
, class C
, class D
, class E
>
570 inline void DispatchToMethod(ObjT
* obj
, Method method
,
571 const Tuple5
<A
, B
, C
, D
, E
>& arg
) {
572 (obj
->*method
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
, arg
.e
);
575 template<class ObjT
, class Method
, class A
, class B
, class C
, class D
, class E
,
577 inline void DispatchToMethod(ObjT
* obj
, Method method
,
578 const Tuple6
<A
, B
, C
, D
, E
, F
>& arg
) {
579 (obj
->*method
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
, arg
.e
, arg
.f
);
582 template<class ObjT
, class Method
, class A
, class B
, class C
, class D
, class E
,
584 inline void DispatchToMethod(ObjT
* obj
, Method method
,
585 const Tuple7
<A
, B
, C
, D
, E
, F
, G
>& arg
) {
586 (obj
->*method
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
, arg
.e
, arg
.f
, arg
.g
);
589 template<class ObjT
, class Method
, class A
, class B
, class C
, class D
, class E
,
590 class F
, class G
, class H
>
591 inline void DispatchToMethod(ObjT
* obj
, Method method
,
592 const Tuple8
<A
, B
, C
, D
, E
, F
, G
, H
>& arg
) {
593 (obj
->*method
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
, arg
.e
, arg
.f
, arg
.g
, arg
.h
);
596 // Static Dispatchers with no out params.
598 template <class Function
>
599 inline void DispatchToFunction(Function function
, const Tuple0
& arg
) {
603 template <class Function
, class A
>
604 inline void DispatchToFunction(Function function
, const A
& arg
) {
608 template <class Function
, class A
>
609 inline void DispatchToFunction(Function function
, const Tuple1
<A
>& arg
) {
613 template<class Function
, class A
, class B
>
614 inline void DispatchToFunction(Function function
, const Tuple2
<A
, B
>& arg
) {
615 (*function
)(arg
.a
, arg
.b
);
618 template<class Function
, class A
, class B
, class C
>
619 inline void DispatchToFunction(Function function
, const Tuple3
<A
, B
, C
>& arg
) {
620 (*function
)(arg
.a
, arg
.b
, arg
.c
);
623 template<class Function
, class A
, class B
, class C
, class D
>
624 inline void DispatchToFunction(Function function
,
625 const Tuple4
<A
, B
, C
, D
>& arg
) {
626 (*function
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
);
629 template<class Function
, class A
, class B
, class C
, class D
, class E
>
630 inline void DispatchToFunction(Function function
,
631 const Tuple5
<A
, B
, C
, D
, E
>& arg
) {
632 (*function
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
, arg
.e
);
635 template<class Function
, class A
, class B
, class C
, class D
, class E
, class F
>
636 inline void DispatchToFunction(Function function
,
637 const Tuple6
<A
, B
, C
, D
, E
, F
>& arg
) {
638 (*function
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
, arg
.e
, arg
.f
);
641 template<class Function
, class A
, class B
, class C
, class D
, class E
, class F
,
643 inline void DispatchToFunction(Function function
,
644 const Tuple7
<A
, B
, C
, D
, E
, F
, G
>& arg
) {
645 (*function
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
, arg
.e
, arg
.f
, arg
.g
);
648 template<class Function
, class A
, class B
, class C
, class D
, class E
, class F
,
650 inline void DispatchToFunction(Function function
,
651 const Tuple8
<A
, B
, C
, D
, E
, F
, G
, H
>& arg
) {
652 (*function
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
, arg
.e
, arg
.f
, arg
.g
, arg
.h
);
655 // Dispatchers with 0 out param (as a Tuple0).
657 template <class ObjT
, class Method
>
658 inline void DispatchToMethod(ObjT
* obj
,
660 const Tuple0
& arg
, Tuple0
*) {
664 template <class ObjT
, class Method
, class A
>
665 inline void DispatchToMethod(ObjT
* obj
, Method method
, const A
& arg
, Tuple0
*) {
669 template <class ObjT
, class Method
, class A
>
670 inline void DispatchToMethod(ObjT
* obj
,
672 const Tuple1
<A
>& arg
, Tuple0
*) {
673 (obj
->*method
)(arg
.a
);
676 template<class ObjT
, class Method
, class A
, class B
>
677 inline void DispatchToMethod(ObjT
* obj
,
679 const Tuple2
<A
, B
>& arg
, Tuple0
*) {
680 (obj
->*method
)(arg
.a
, arg
.b
);
683 template<class ObjT
, class Method
, class A
, class B
, class C
>
684 inline void DispatchToMethod(ObjT
* obj
, Method method
,
685 const Tuple3
<A
, B
, C
>& arg
, Tuple0
*) {
686 (obj
->*method
)(arg
.a
, arg
.b
, arg
.c
);
689 template<class ObjT
, class Method
, class A
, class B
, class C
, class D
>
690 inline void DispatchToMethod(ObjT
* obj
, Method method
,
691 const Tuple4
<A
, B
, C
, D
>& arg
, Tuple0
*) {
692 (obj
->*method
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
);
695 template<class ObjT
, class Method
, class A
, class B
, class C
, class D
, class E
>
696 inline void DispatchToMethod(ObjT
* obj
, Method method
,
697 const Tuple5
<A
, B
, C
, D
, E
>& arg
, Tuple0
*) {
698 (obj
->*method
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
, arg
.e
);
701 template<class ObjT
, class Method
, class A
, class B
, class C
, class D
, class E
,
703 inline void DispatchToMethod(ObjT
* obj
, Method method
,
704 const Tuple6
<A
, B
, C
, D
, E
, F
>& arg
, Tuple0
*) {
705 (obj
->*method
)(arg
.a
, arg
.b
, arg
.c
, arg
.d
, arg
.e
, arg
.f
);
708 // Dispatchers with 1 out param.
710 template<class ObjT
, class Method
,
712 inline void DispatchToMethod(ObjT
* obj
, Method method
,
715 (obj
->*method
)(&out
->a
);
718 template<class ObjT
, class Method
, class InA
,
720 inline void DispatchToMethod(ObjT
* obj
, Method method
,
723 (obj
->*method
)(in
, &out
->a
);
726 template<class ObjT
, class Method
, class InA
,
728 inline void DispatchToMethod(ObjT
* obj
, Method method
,
729 const Tuple1
<InA
>& in
,
731 (obj
->*method
)(in
.a
, &out
->a
);
734 template<class ObjT
, class Method
, class InA
, class InB
,
736 inline void DispatchToMethod(ObjT
* obj
, Method method
,
737 const Tuple2
<InA
, InB
>& in
,
739 (obj
->*method
)(in
.a
, in
.b
, &out
->a
);
742 template<class ObjT
, class Method
, class InA
, class InB
, class InC
,
744 inline void DispatchToMethod(ObjT
* obj
, Method method
,
745 const Tuple3
<InA
, InB
, InC
>& in
,
747 (obj
->*method
)(in
.a
, in
.b
, in
.c
, &out
->a
);
750 template<class ObjT
, class Method
, class InA
, class InB
, class InC
, class InD
,
752 inline void DispatchToMethod(ObjT
* obj
, Method method
,
753 const Tuple4
<InA
, InB
, InC
, InD
>& in
,
755 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, &out
->a
);
758 template<class ObjT
, class Method
, class InA
, class InB
, class InC
, class InD
,
759 class InE
, class OutA
>
760 inline void DispatchToMethod(ObjT
* obj
, Method method
,
761 const Tuple5
<InA
, InB
, InC
, InD
, InE
>& in
,
763 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, in
.e
, &out
->a
);
766 template<class ObjT
, class Method
,
767 class InA
, class InB
, class InC
, class InD
, class InE
, class InF
,
769 inline void DispatchToMethod(ObjT
* obj
, Method method
,
770 const Tuple6
<InA
, InB
, InC
, InD
, InE
, InF
>& in
,
772 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, in
.e
, in
.f
, &out
->a
);
775 // Dispatchers with 2 out params.
777 template<class ObjT
, class Method
,
778 class OutA
, class OutB
>
779 inline void DispatchToMethod(ObjT
* obj
, Method method
,
781 Tuple2
<OutA
, OutB
>* out
) {
782 (obj
->*method
)(&out
->a
, &out
->b
);
785 template<class ObjT
, class Method
, class InA
,
786 class OutA
, class OutB
>
787 inline void DispatchToMethod(ObjT
* obj
, Method method
,
789 Tuple2
<OutA
, OutB
>* out
) {
790 (obj
->*method
)(in
, &out
->a
, &out
->b
);
793 template<class ObjT
, class Method
, class InA
,
794 class OutA
, class OutB
>
795 inline void DispatchToMethod(ObjT
* obj
, Method method
,
796 const Tuple1
<InA
>& in
,
797 Tuple2
<OutA
, OutB
>* out
) {
798 (obj
->*method
)(in
.a
, &out
->a
, &out
->b
);
801 template<class ObjT
, class Method
, class InA
, class InB
,
802 class OutA
, class OutB
>
803 inline void DispatchToMethod(ObjT
* obj
, Method method
,
804 const Tuple2
<InA
, InB
>& in
,
805 Tuple2
<OutA
, OutB
>* out
) {
806 (obj
->*method
)(in
.a
, in
.b
, &out
->a
, &out
->b
);
809 template<class ObjT
, class Method
, class InA
, class InB
, class InC
,
810 class OutA
, class OutB
>
811 inline void DispatchToMethod(ObjT
* obj
, Method method
,
812 const Tuple3
<InA
, InB
, InC
>& in
,
813 Tuple2
<OutA
, OutB
>* out
) {
814 (obj
->*method
)(in
.a
, in
.b
, in
.c
, &out
->a
, &out
->b
);
817 template<class ObjT
, class Method
, class InA
, class InB
, class InC
, class InD
,
818 class OutA
, class OutB
>
819 inline void DispatchToMethod(ObjT
* obj
, Method method
,
820 const Tuple4
<InA
, InB
, InC
, InD
>& in
,
821 Tuple2
<OutA
, OutB
>* out
) {
822 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, &out
->a
, &out
->b
);
825 template<class ObjT
, class Method
,
826 class InA
, class InB
, class InC
, class InD
, class InE
,
827 class OutA
, class OutB
>
828 inline void DispatchToMethod(ObjT
* obj
, Method method
,
829 const Tuple5
<InA
, InB
, InC
, InD
, InE
>& in
,
830 Tuple2
<OutA
, OutB
>* out
) {
831 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, in
.e
, &out
->a
, &out
->b
);
834 template<class ObjT
, class Method
,
835 class InA
, class InB
, class InC
, class InD
, class InE
, class InF
,
836 class OutA
, class OutB
>
837 inline void DispatchToMethod(ObjT
* obj
, Method method
,
838 const Tuple6
<InA
, InB
, InC
, InD
, InE
, InF
>& in
,
839 Tuple2
<OutA
, OutB
>* out
) {
840 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, in
.e
, in
.f
, &out
->a
, &out
->b
);
843 // Dispatchers with 3 out params.
845 template<class ObjT
, class Method
,
846 class OutA
, class OutB
, class OutC
>
847 inline void DispatchToMethod(ObjT
* obj
, Method method
,
849 Tuple3
<OutA
, OutB
, OutC
>* out
) {
850 (obj
->*method
)(&out
->a
, &out
->b
, &out
->c
);
853 template<class ObjT
, class Method
, class InA
,
854 class OutA
, class OutB
, class OutC
>
855 inline void DispatchToMethod(ObjT
* obj
, Method method
,
857 Tuple3
<OutA
, OutB
, OutC
>* out
) {
858 (obj
->*method
)(in
, &out
->a
, &out
->b
, &out
->c
);
861 template<class ObjT
, class Method
, class InA
,
862 class OutA
, class OutB
, class OutC
>
863 inline void DispatchToMethod(ObjT
* obj
, Method method
,
864 const Tuple1
<InA
>& in
,
865 Tuple3
<OutA
, OutB
, OutC
>* out
) {
866 (obj
->*method
)(in
.a
, &out
->a
, &out
->b
, &out
->c
);
869 template<class ObjT
, class Method
, class InA
, class InB
,
870 class OutA
, class OutB
, class OutC
>
871 inline void DispatchToMethod(ObjT
* obj
, Method method
,
872 const Tuple2
<InA
, InB
>& in
,
873 Tuple3
<OutA
, OutB
, OutC
>* out
) {
874 (obj
->*method
)(in
.a
, in
.b
, &out
->a
, &out
->b
, &out
->c
);
877 template<class ObjT
, class Method
, class InA
, class InB
, class InC
,
878 class OutA
, class OutB
, class OutC
>
879 inline void DispatchToMethod(ObjT
* obj
, Method method
,
880 const Tuple3
<InA
, InB
, InC
>& in
,
881 Tuple3
<OutA
, OutB
, OutC
>* out
) {
882 (obj
->*method
)(in
.a
, in
.b
, in
.c
, &out
->a
, &out
->b
, &out
->c
);
885 template<class ObjT
, class Method
, class InA
, class InB
, class InC
, class InD
,
886 class OutA
, class OutB
, class OutC
>
887 inline void DispatchToMethod(ObjT
* obj
, Method method
,
888 const Tuple4
<InA
, InB
, InC
, InD
>& in
,
889 Tuple3
<OutA
, OutB
, OutC
>* out
) {
890 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, &out
->a
, &out
->b
, &out
->c
);
893 template<class ObjT
, class Method
,
894 class InA
, class InB
, class InC
, class InD
, class InE
,
895 class OutA
, class OutB
, class OutC
>
896 inline void DispatchToMethod(ObjT
* obj
, Method method
,
897 const Tuple5
<InA
, InB
, InC
, InD
, InE
>& in
,
898 Tuple3
<OutA
, OutB
, OutC
>* out
) {
899 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, in
.e
, &out
->a
, &out
->b
, &out
->c
);
902 template<class ObjT
, class Method
,
903 class InA
, class InB
, class InC
, class InD
, class InE
, class InF
,
904 class OutA
, class OutB
, class OutC
>
905 inline void DispatchToMethod(ObjT
* obj
, Method method
,
906 const Tuple6
<InA
, InB
, InC
, InD
, InE
, InF
>& in
,
907 Tuple3
<OutA
, OutB
, OutC
>* out
) {
908 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, in
.e
, in
.f
, &out
->a
, &out
->b
, &out
->c
);
911 // Dispatchers with 4 out params.
913 template<class ObjT
, class Method
,
914 class OutA
, class OutB
, class OutC
, class OutD
>
915 inline void DispatchToMethod(ObjT
* obj
, Method method
,
917 Tuple4
<OutA
, OutB
, OutC
, OutD
>* out
) {
918 (obj
->*method
)(&out
->a
, &out
->b
, &out
->c
, &out
->d
);
921 template<class ObjT
, class Method
, class InA
,
922 class OutA
, class OutB
, class OutC
, class OutD
>
923 inline void DispatchToMethod(ObjT
* obj
, Method method
,
925 Tuple4
<OutA
, OutB
, OutC
, OutD
>* out
) {
926 (obj
->*method
)(in
, &out
->a
, &out
->b
, &out
->c
, &out
->d
);
929 template<class ObjT
, class Method
, class InA
,
930 class OutA
, class OutB
, class OutC
, class OutD
>
931 inline void DispatchToMethod(ObjT
* obj
, Method method
,
932 const Tuple1
<InA
>& in
,
933 Tuple4
<OutA
, OutB
, OutC
, OutD
>* out
) {
934 (obj
->*method
)(in
.a
, &out
->a
, &out
->b
, &out
->c
, &out
->d
);
937 template<class ObjT
, class Method
, class InA
, class InB
,
938 class OutA
, class OutB
, class OutC
, class OutD
>
939 inline void DispatchToMethod(ObjT
* obj
, Method method
,
940 const Tuple2
<InA
, InB
>& in
,
941 Tuple4
<OutA
, OutB
, OutC
, OutD
>* out
) {
942 (obj
->*method
)(in
.a
, in
.b
, &out
->a
, &out
->b
, &out
->c
, &out
->d
);
945 template<class ObjT
, class Method
, class InA
, class InB
, class InC
,
946 class OutA
, class OutB
, class OutC
, class OutD
>
947 inline void DispatchToMethod(ObjT
* obj
, Method method
,
948 const Tuple3
<InA
, InB
, InC
>& in
,
949 Tuple4
<OutA
, OutB
, OutC
, OutD
>* out
) {
950 (obj
->*method
)(in
.a
, in
.b
, in
.c
, &out
->a
, &out
->b
, &out
->c
, &out
->d
);
953 template<class ObjT
, class Method
, class InA
, class InB
, class InC
, class InD
,
954 class OutA
, class OutB
, class OutC
, class OutD
>
955 inline void DispatchToMethod(ObjT
* obj
, Method method
,
956 const Tuple4
<InA
, InB
, InC
, InD
>& in
,
957 Tuple4
<OutA
, OutB
, OutC
, OutD
>* out
) {
958 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, &out
->a
, &out
->b
, &out
->c
, &out
->d
);
961 template<class ObjT
, class Method
,
962 class InA
, class InB
, class InC
, class InD
, class InE
,
963 class OutA
, class OutB
, class OutC
, class OutD
>
964 inline void DispatchToMethod(ObjT
* obj
, Method method
,
965 const Tuple5
<InA
, InB
, InC
, InD
, InE
>& in
,
966 Tuple4
<OutA
, OutB
, OutC
, OutD
>* out
) {
967 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, in
.e
,
968 &out
->a
, &out
->b
, &out
->c
, &out
->d
);
971 template<class ObjT
, class Method
,
972 class InA
, class InB
, class InC
, class InD
, class InE
, class InF
,
973 class OutA
, class OutB
, class OutC
, class OutD
>
974 inline void DispatchToMethod(ObjT
* obj
, Method method
,
975 const Tuple6
<InA
, InB
, InC
, InD
, InE
, InF
>& in
,
976 Tuple4
<OutA
, OutB
, OutC
, OutD
>* out
) {
977 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, in
.e
, in
.f
,
978 &out
->a
, &out
->b
, &out
->c
, &out
->d
);
981 // Dispatchers with 5 out params.
983 template<class ObjT
, class Method
,
984 class OutA
, class OutB
, class OutC
, class OutD
, class OutE
>
985 inline void DispatchToMethod(ObjT
* obj
, Method method
,
987 Tuple5
<OutA
, OutB
, OutC
, OutD
, OutE
>* out
) {
988 (obj
->*method
)(&out
->a
, &out
->b
, &out
->c
, &out
->d
, &out
->e
);
991 template<class ObjT
, class Method
, class InA
,
992 class OutA
, class OutB
, class OutC
, class OutD
, class OutE
>
993 inline void DispatchToMethod(ObjT
* obj
, Method method
,
995 Tuple5
<OutA
, OutB
, OutC
, OutD
, OutE
>* out
) {
996 (obj
->*method
)(in
, &out
->a
, &out
->b
, &out
->c
, &out
->d
, &out
->e
);
999 template<class ObjT
, class Method
, class InA
,
1000 class OutA
, class OutB
, class OutC
, class OutD
, class OutE
>
1001 inline void DispatchToMethod(ObjT
* obj
, Method method
,
1002 const Tuple1
<InA
>& in
,
1003 Tuple5
<OutA
, OutB
, OutC
, OutD
, OutE
>* out
) {
1004 (obj
->*method
)(in
.a
, &out
->a
, &out
->b
, &out
->c
, &out
->d
, &out
->e
);
1007 template<class ObjT
, class Method
, class InA
, class InB
,
1008 class OutA
, class OutB
, class OutC
, class OutD
, class OutE
>
1009 inline void DispatchToMethod(ObjT
* obj
, Method method
,
1010 const Tuple2
<InA
, InB
>& in
,
1011 Tuple5
<OutA
, OutB
, OutC
, OutD
, OutE
>* out
) {
1012 (obj
->*method
)(in
.a
, in
.b
, &out
->a
, &out
->b
, &out
->c
, &out
->d
, &out
->e
);
1015 template<class ObjT
, class Method
, class InA
, class InB
, class InC
,
1016 class OutA
, class OutB
, class OutC
, class OutD
, class OutE
>
1017 inline void DispatchToMethod(ObjT
* obj
, Method method
,
1018 const Tuple3
<InA
, InB
, InC
>& in
,
1019 Tuple5
<OutA
, OutB
, OutC
, OutD
, OutE
>* out
) {
1020 (obj
->*method
)(in
.a
, in
.b
, in
.c
, &out
->a
, &out
->b
, &out
->c
, &out
->d
, &out
->e
);
1023 template<class ObjT
, class Method
, class InA
, class InB
, class InC
, class InD
,
1024 class OutA
, class OutB
, class OutC
, class OutD
, class OutE
>
1025 inline void DispatchToMethod(ObjT
* obj
, Method method
,
1026 const Tuple4
<InA
, InB
, InC
, InD
>& in
,
1027 Tuple5
<OutA
, OutB
, OutC
, OutD
, OutE
>* out
) {
1028 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, &out
->a
, &out
->b
, &out
->c
, &out
->d
,
1032 template<class ObjT
, class Method
,
1033 class InA
, class InB
, class InC
, class InD
, class InE
,
1034 class OutA
, class OutB
, class OutC
, class OutD
, class OutE
>
1035 inline void DispatchToMethod(ObjT
* obj
, Method method
,
1036 const Tuple5
<InA
, InB
, InC
, InD
, InE
>& in
,
1037 Tuple5
<OutA
, OutB
, OutC
, OutD
, OutE
>* out
) {
1038 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, in
.e
,
1039 &out
->a
, &out
->b
, &out
->c
, &out
->d
, &out
->e
);
1042 template<class ObjT
, class Method
,
1043 class InA
, class InB
, class InC
, class InD
, class InE
, class InF
,
1044 class OutA
, class OutB
, class OutC
, class OutD
, class OutE
>
1045 inline void DispatchToMethod(ObjT
* obj
, Method method
,
1046 const Tuple6
<InA
, InB
, InC
, InD
, InE
, InF
>& in
,
1047 Tuple5
<OutA
, OutB
, OutC
, OutD
, OutE
>* out
) {
1048 (obj
->*method
)(in
.a
, in
.b
, in
.c
, in
.d
, in
.e
, in
.f
,
1049 &out
->a
, &out
->b
, &out
->c
, &out
->d
, &out
->e
);
1052 #endif // BASE_TUPLE_H__