OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // A Tuple is a generic templatized container, similar in concept to std::pair. | 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 | 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, | 7 // it contains. The convenient MakeTuple() function takes 0 to 6 arguments, |
8 // and will construct and return the appropriate Tuple object. The functions | 8 // and will construct and return the appropriate Tuple object. The functions |
9 // DispatchToMethod and DispatchToFunction take a function pointer or instance | 9 // DispatchToMethod and DispatchToFunction take a function pointer or instance |
10 // and method pointer, and unpack a tuple into arguments to the call. | 10 // and method pointer, and unpack a tuple into arguments to the call. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 typedef const P& ParamType; | 45 typedef const P& ParamType; |
46 }; | 46 }; |
47 | 47 |
48 template <class P> | 48 template <class P> |
49 struct TupleTraits<P&> { | 49 struct TupleTraits<P&> { |
50 typedef P ValueType; | 50 typedef P ValueType; |
51 typedef P& RefType; | 51 typedef P& RefType; |
52 typedef P& ParamType; | 52 typedef P& ParamType; |
53 }; | 53 }; |
54 | 54 |
| 55 template <class P> |
| 56 struct TupleTypes { }; |
| 57 |
55 // Tuple ----------------------------------------------------------------------- | 58 // Tuple ----------------------------------------------------------------------- |
56 // | 59 // |
57 // This set of classes is useful for bundling 0 or more heterogeneous data types | 60 // 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 | 61 // 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 | 62 // function objects that need to take an arbitrary number of parameters; see |
60 // RunnableMethod and IPC::MessageWithTuple. | 63 // RunnableMethod and IPC::MessageWithTuple. |
61 // | 64 // |
62 // Tuple0 is supplied to act as a 'void' type. It can be used, for example, | 65 // 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 | 66 // when dispatching to a function that accepts no arguments (see the |
64 // Dispatchers below). | 67 // Dispatchers below). |
65 // Tuple1<A> is rarely useful. One such use is when A is non-const ref that you | 68 // 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 | 69 // want filled by the dispatchee, and the tuple is merely a container for that |
67 // output (a "tier"). See MakeRefTuple and its usages. | 70 // output (a "tier"). See MakeRefTuple and its usages. |
68 | 71 |
69 struct Tuple0 { | 72 struct Tuple0 { |
70 typedef Tuple0 ValueTuple; | 73 typedef Tuple0 ValueTuple; |
71 typedef Tuple0 RefTuple; | 74 typedef Tuple0 RefTuple; |
72 typedef Tuple0 ParamTuple; | 75 typedef Tuple0 ParamTuple; |
73 }; | 76 }; |
74 | 77 |
75 template <class A> | 78 template <class A> |
76 struct Tuple1 { | 79 struct Tuple1 { |
77 public: | 80 public: |
78 typedef A TypeA; | 81 typedef A TypeA; |
79 typedef Tuple1<typename TupleTraits<A>::ValueType> ValueTuple; | |
80 typedef Tuple1<typename TupleTraits<A>::RefType> RefTuple; | |
81 typedef Tuple1<typename TupleTraits<A>::ParamType> ParamTuple; | |
82 | 82 |
83 Tuple1() {} | 83 Tuple1() {} |
84 explicit Tuple1(typename TupleTraits<A>::ParamType a) : a(a) {} | 84 explicit Tuple1(typename TupleTraits<A>::ParamType a) : a(a) {} |
85 | 85 |
86 A a; | 86 A a; |
87 }; | 87 }; |
88 | 88 |
89 template <class A, class B> | 89 template <class A, class B> |
90 struct Tuple2 { | 90 struct Tuple2 { |
91 public: | 91 public: |
92 typedef A TypeA; | 92 typedef A TypeA; |
93 typedef B TypeB; | 93 typedef B TypeB; |
94 typedef Tuple2<typename TupleTraits<A>::ValueType, | |
95 typename TupleTraits<B>::ValueType> ValueTuple; | |
96 typedef Tuple2<typename TupleTraits<A>::RefType, | |
97 typename TupleTraits<B>::RefType> RefTuple; | |
98 typedef Tuple2<typename TupleTraits<A>::ParamType, | |
99 typename TupleTraits<B>::ParamType> ParamTuple; | |
100 | 94 |
101 Tuple2() {} | 95 Tuple2() {} |
102 Tuple2(typename TupleTraits<A>::ParamType a, | 96 Tuple2(typename TupleTraits<A>::ParamType a, |
103 typename TupleTraits<B>::ParamType b) | 97 typename TupleTraits<B>::ParamType b) |
104 : a(a), b(b) { | 98 : a(a), b(b) { |
105 } | 99 } |
106 | 100 |
107 A a; | 101 A a; |
108 B b; | 102 B b; |
109 }; | 103 }; |
110 | 104 |
111 template <class A, class B, class C> | 105 template <class A, class B, class C> |
112 struct Tuple3 { | 106 struct Tuple3 { |
113 public: | 107 public: |
114 typedef A TypeA; | 108 typedef A TypeA; |
115 typedef B TypeB; | 109 typedef B TypeB; |
116 typedef C TypeC; | 110 typedef C TypeC; |
117 typedef Tuple3<typename TupleTraits<A>::ValueType, | |
118 typename TupleTraits<B>::ValueType, | |
119 typename TupleTraits<C>::ValueType> ValueTuple; | |
120 typedef Tuple3<typename TupleTraits<A>::RefType, | |
121 typename TupleTraits<B>::RefType, | |
122 typename TupleTraits<C>::RefType> RefTuple; | |
123 typedef Tuple3<typename TupleTraits<A>::ParamType, | |
124 typename TupleTraits<B>::ParamType, | |
125 typename TupleTraits<C>::ParamType> ParamTuple; | |
126 | 111 |
127 Tuple3() {} | 112 Tuple3() {} |
128 Tuple3(typename TupleTraits<A>::ParamType a, | 113 Tuple3(typename TupleTraits<A>::ParamType a, |
129 typename TupleTraits<B>::ParamType b, | 114 typename TupleTraits<B>::ParamType b, |
130 typename TupleTraits<C>::ParamType c) | 115 typename TupleTraits<C>::ParamType c) |
131 : a(a), b(b), c(c){ | 116 : a(a), b(b), c(c){ |
132 } | 117 } |
133 | 118 |
134 A a; | 119 A a; |
135 B b; | 120 B b; |
136 C c; | 121 C c; |
137 }; | 122 }; |
138 | 123 |
139 template <class A, class B, class C, class D> | 124 template <class A, class B, class C, class D> |
140 struct Tuple4 { | 125 struct Tuple4 { |
141 public: | 126 public: |
142 typedef A TypeA; | 127 typedef A TypeA; |
143 typedef B TypeB; | 128 typedef B TypeB; |
144 typedef C TypeC; | 129 typedef C TypeC; |
145 typedef D TypeD; | 130 typedef D TypeD; |
146 typedef Tuple4<typename TupleTraits<A>::ValueType, | |
147 typename TupleTraits<B>::ValueType, | |
148 typename TupleTraits<C>::ValueType, | |
149 typename TupleTraits<D>::ValueType> ValueTuple; | |
150 typedef Tuple4<typename TupleTraits<A>::RefType, | |
151 typename TupleTraits<B>::RefType, | |
152 typename TupleTraits<C>::RefType, | |
153 typename TupleTraits<D>::RefType> RefTuple; | |
154 typedef Tuple4<typename TupleTraits<A>::ParamType, | |
155 typename TupleTraits<B>::ParamType, | |
156 typename TupleTraits<C>::ParamType, | |
157 typename TupleTraits<D>::ParamType> ParamTuple; | |
158 | 131 |
159 Tuple4() {} | 132 Tuple4() {} |
160 Tuple4(typename TupleTraits<A>::ParamType a, | 133 Tuple4(typename TupleTraits<A>::ParamType a, |
161 typename TupleTraits<B>::ParamType b, | 134 typename TupleTraits<B>::ParamType b, |
162 typename TupleTraits<C>::ParamType c, | 135 typename TupleTraits<C>::ParamType c, |
163 typename TupleTraits<D>::ParamType d) | 136 typename TupleTraits<D>::ParamType d) |
164 : a(a), b(b), c(c), d(d) { | 137 : a(a), b(b), c(c), d(d) { |
165 } | 138 } |
166 | 139 |
167 A a; | 140 A a; |
168 B b; | 141 B b; |
169 C c; | 142 C c; |
170 D d; | 143 D d; |
171 }; | 144 }; |
172 | 145 |
173 template <class A, class B, class C, class D, class E> | 146 template <class A, class B, class C, class D, class E> |
174 struct Tuple5 { | 147 struct Tuple5 { |
175 public: | 148 public: |
176 typedef A TypeA; | 149 typedef A TypeA; |
177 typedef B TypeB; | 150 typedef B TypeB; |
178 typedef C TypeC; | 151 typedef C TypeC; |
179 typedef D TypeD; | 152 typedef D TypeD; |
180 typedef E TypeE; | 153 typedef E TypeE; |
181 typedef Tuple5<typename TupleTraits<A>::ValueType, | |
182 typename TupleTraits<B>::ValueType, | |
183 typename TupleTraits<C>::ValueType, | |
184 typename TupleTraits<D>::ValueType, | |
185 typename TupleTraits<E>::ValueType> ValueTuple; | |
186 typedef Tuple5<typename TupleTraits<A>::RefType, | |
187 typename TupleTraits<B>::RefType, | |
188 typename TupleTraits<C>::RefType, | |
189 typename TupleTraits<D>::RefType, | |
190 typename TupleTraits<E>::RefType> RefTuple; | |
191 typedef Tuple5<typename TupleTraits<A>::ParamType, | |
192 typename TupleTraits<B>::ParamType, | |
193 typename TupleTraits<C>::ParamType, | |
194 typename TupleTraits<D>::ParamType, | |
195 typename TupleTraits<E>::ParamType> ParamTuple; | |
196 | 154 |
197 Tuple5() {} | 155 Tuple5() {} |
198 Tuple5(typename TupleTraits<A>::ParamType a, | 156 Tuple5(typename TupleTraits<A>::ParamType a, |
199 typename TupleTraits<B>::ParamType b, | 157 typename TupleTraits<B>::ParamType b, |
200 typename TupleTraits<C>::ParamType c, | 158 typename TupleTraits<C>::ParamType c, |
201 typename TupleTraits<D>::ParamType d, | 159 typename TupleTraits<D>::ParamType d, |
202 typename TupleTraits<E>::ParamType e) | 160 typename TupleTraits<E>::ParamType e) |
203 : a(a), b(b), c(c), d(d), e(e) { | 161 : a(a), b(b), c(c), d(d), e(e) { |
204 } | 162 } |
205 | 163 |
206 A a; | 164 A a; |
207 B b; | 165 B b; |
208 C c; | 166 C c; |
209 D d; | 167 D d; |
210 E e; | 168 E e; |
211 }; | 169 }; |
212 | 170 |
213 template <class A, class B, class C, class D, class E, class F> | 171 template <class A, class B, class C, class D, class E, class F> |
214 struct Tuple6 { | 172 struct Tuple6 { |
215 public: | 173 public: |
216 typedef A TypeA; | 174 typedef A TypeA; |
217 typedef B TypeB; | 175 typedef B TypeB; |
218 typedef C TypeC; | 176 typedef C TypeC; |
219 typedef D TypeD; | 177 typedef D TypeD; |
220 typedef E TypeE; | 178 typedef E TypeE; |
221 typedef F TypeF; | 179 typedef F TypeF; |
222 typedef Tuple6<typename TupleTraits<A>::ValueType, | |
223 typename TupleTraits<B>::ValueType, | |
224 typename TupleTraits<C>::ValueType, | |
225 typename TupleTraits<D>::ValueType, | |
226 typename TupleTraits<E>::ValueType, | |
227 typename TupleTraits<F>::ValueType> ValueTuple; | |
228 typedef Tuple6<typename TupleTraits<A>::RefType, | |
229 typename TupleTraits<B>::RefType, | |
230 typename TupleTraits<C>::RefType, | |
231 typename TupleTraits<D>::RefType, | |
232 typename TupleTraits<E>::RefType, | |
233 typename TupleTraits<F>::RefType> RefTuple; | |
234 typedef Tuple6<typename TupleTraits<A>::ParamType, | |
235 typename TupleTraits<B>::ParamType, | |
236 typename TupleTraits<C>::ParamType, | |
237 typename TupleTraits<D>::ParamType, | |
238 typename TupleTraits<E>::ParamType, | |
239 typename TupleTraits<F>::ParamType> ParamTuple; | |
240 | 180 |
241 Tuple6() {} | 181 Tuple6() {} |
242 Tuple6(typename TupleTraits<A>::ParamType a, | 182 Tuple6(typename TupleTraits<A>::ParamType a, |
243 typename TupleTraits<B>::ParamType b, | 183 typename TupleTraits<B>::ParamType b, |
244 typename TupleTraits<C>::ParamType c, | 184 typename TupleTraits<C>::ParamType c, |
245 typename TupleTraits<D>::ParamType d, | 185 typename TupleTraits<D>::ParamType d, |
246 typename TupleTraits<E>::ParamType e, | 186 typename TupleTraits<E>::ParamType e, |
247 typename TupleTraits<F>::ParamType f) | 187 typename TupleTraits<F>::ParamType f) |
248 : a(a), b(b), c(c), d(d), e(e), f(f) { | 188 : a(a), b(b), c(c), d(d), e(e), f(f) { |
249 } | 189 } |
250 | 190 |
251 A a; | 191 A a; |
252 B b; | 192 B b; |
253 C c; | 193 C c; |
254 D d; | 194 D d; |
255 E e; | 195 E e; |
256 F f; | 196 F f; |
257 }; | 197 }; |
258 | 198 |
259 template <class A, class B, class C, class D, class E, class F, class G> | 199 template <class A, class B, class C, class D, class E, class F, class G> |
260 struct Tuple7 { | 200 struct Tuple7 { |
261 public: | 201 public: |
262 typedef A TypeA; | 202 typedef A TypeA; |
263 typedef B TypeB; | 203 typedef B TypeB; |
264 typedef C TypeC; | 204 typedef C TypeC; |
265 typedef D TypeD; | 205 typedef D TypeD; |
266 typedef E TypeE; | 206 typedef E TypeE; |
267 typedef F TypeF; | 207 typedef F TypeF; |
268 typedef G TypeG; | 208 typedef G TypeG; |
269 typedef Tuple7<typename TupleTraits<A>::ValueType, | |
270 typename TupleTraits<B>::ValueType, | |
271 typename TupleTraits<C>::ValueType, | |
272 typename TupleTraits<D>::ValueType, | |
273 typename TupleTraits<E>::ValueType, | |
274 typename TupleTraits<F>::ValueType, | |
275 typename TupleTraits<G>::ValueType> ValueTuple; | |
276 typedef Tuple7<typename TupleTraits<A>::RefType, | |
277 typename TupleTraits<B>::RefType, | |
278 typename TupleTraits<C>::RefType, | |
279 typename TupleTraits<D>::RefType, | |
280 typename TupleTraits<E>::RefType, | |
281 typename TupleTraits<F>::RefType, | |
282 typename TupleTraits<G>::RefType> RefTuple; | |
283 typedef Tuple7<typename TupleTraits<A>::ParamType, | |
284 typename TupleTraits<B>::ParamType, | |
285 typename TupleTraits<C>::ParamType, | |
286 typename TupleTraits<D>::ParamType, | |
287 typename TupleTraits<E>::ParamType, | |
288 typename TupleTraits<F>::ParamType, | |
289 typename TupleTraits<G>::ParamType> ParamTuple; | |
290 | 209 |
291 Tuple7() {} | 210 Tuple7() {} |
292 Tuple7(typename TupleTraits<A>::ParamType a, | 211 Tuple7(typename TupleTraits<A>::ParamType a, |
293 typename TupleTraits<B>::ParamType b, | 212 typename TupleTraits<B>::ParamType b, |
294 typename TupleTraits<C>::ParamType c, | 213 typename TupleTraits<C>::ParamType c, |
295 typename TupleTraits<D>::ParamType d, | 214 typename TupleTraits<D>::ParamType d, |
296 typename TupleTraits<E>::ParamType e, | 215 typename TupleTraits<E>::ParamType e, |
297 typename TupleTraits<F>::ParamType f, | 216 typename TupleTraits<F>::ParamType f, |
298 typename TupleTraits<G>::ParamType g) | 217 typename TupleTraits<G>::ParamType g) |
299 : a(a), b(b), c(c), d(d), e(e), f(f), g(g) { | 218 : a(a), b(b), c(c), d(d), e(e), f(f), g(g) { |
(...skipping 13 matching lines...) Expand all Loading... |
313 struct Tuple8 { | 232 struct Tuple8 { |
314 public: | 233 public: |
315 typedef A TypeA; | 234 typedef A TypeA; |
316 typedef B TypeB; | 235 typedef B TypeB; |
317 typedef C TypeC; | 236 typedef C TypeC; |
318 typedef D TypeD; | 237 typedef D TypeD; |
319 typedef E TypeE; | 238 typedef E TypeE; |
320 typedef F TypeF; | 239 typedef F TypeF; |
321 typedef G TypeG; | 240 typedef G TypeG; |
322 typedef H TypeH; | 241 typedef H TypeH; |
323 typedef Tuple8<typename TupleTraits<A>::ValueType, | |
324 typename TupleTraits<B>::ValueType, | |
325 typename TupleTraits<C>::ValueType, | |
326 typename TupleTraits<D>::ValueType, | |
327 typename TupleTraits<E>::ValueType, | |
328 typename TupleTraits<F>::ValueType, | |
329 typename TupleTraits<G>::ValueType, | |
330 typename TupleTraits<H>::ValueType> ValueTuple; | |
331 typedef Tuple8<typename TupleTraits<A>::RefType, | |
332 typename TupleTraits<B>::RefType, | |
333 typename TupleTraits<C>::RefType, | |
334 typename TupleTraits<D>::RefType, | |
335 typename TupleTraits<E>::RefType, | |
336 typename TupleTraits<F>::RefType, | |
337 typename TupleTraits<G>::RefType, | |
338 typename TupleTraits<H>::RefType> RefTuple; | |
339 typedef Tuple8<typename TupleTraits<A>::ParamType, | |
340 typename TupleTraits<B>::ParamType, | |
341 typename TupleTraits<C>::ParamType, | |
342 typename TupleTraits<D>::ParamType, | |
343 typename TupleTraits<E>::ParamType, | |
344 typename TupleTraits<F>::ParamType, | |
345 typename TupleTraits<G>::ParamType, | |
346 typename TupleTraits<H>::ParamType> ParamTuple; | |
347 | 242 |
348 Tuple8() {} | 243 Tuple8() {} |
349 Tuple8(typename TupleTraits<A>::ParamType a, | 244 Tuple8(typename TupleTraits<A>::ParamType a, |
350 typename TupleTraits<B>::ParamType b, | 245 typename TupleTraits<B>::ParamType b, |
351 typename TupleTraits<C>::ParamType c, | 246 typename TupleTraits<C>::ParamType c, |
352 typename TupleTraits<D>::ParamType d, | 247 typename TupleTraits<D>::ParamType d, |
353 typename TupleTraits<E>::ParamType e, | 248 typename TupleTraits<E>::ParamType e, |
354 typename TupleTraits<F>::ParamType f, | 249 typename TupleTraits<F>::ParamType f, |
355 typename TupleTraits<G>::ParamType g, | 250 typename TupleTraits<G>::ParamType g, |
356 typename TupleTraits<H>::ParamType h) | 251 typename TupleTraits<H>::ParamType h) |
357 : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) { | 252 : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) { |
358 } | 253 } |
359 | 254 |
360 A a; | 255 A a; |
361 B b; | 256 B b; |
362 C c; | 257 C c; |
363 D d; | 258 D d; |
364 E e; | 259 E e; |
365 F f; | 260 F f; |
366 G g; | 261 G g; |
367 H h; | 262 H h; |
368 }; | 263 }; |
369 | 264 |
| 265 // Tuple types ---------------------------------------------------------------- |
| 266 // |
| 267 // Allows for selection of ValueTuple/RefTuple/ParamTuple without needing the |
| 268 // definitions of class types the tuple takes as parameters. |
| 269 |
| 270 template <> |
| 271 struct TupleTypes< Tuple0 > { |
| 272 typedef Tuple0 ValueTuple; |
| 273 typedef Tuple0 RefTuple; |
| 274 typedef Tuple0 ParamTuple; |
| 275 }; |
| 276 |
| 277 template <class A> |
| 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; |
| 282 }; |
| 283 |
| 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; |
| 292 }; |
| 293 |
| 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; |
| 305 }; |
| 306 |
| 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; |
| 321 }; |
| 322 |
| 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; |
| 340 }; |
| 341 |
| 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; |
| 362 }; |
| 363 |
| 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; |
| 387 }; |
| 388 |
| 389 template <class A, class B, class C, class D, class E, class F, class G, |
| 390 class H> |
| 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; |
| 416 }; |
| 417 |
370 // Tuple creators ------------------------------------------------------------- | 418 // Tuple creators ------------------------------------------------------------- |
371 // | 419 // |
372 // Helper functions for constructing tuples while inferring the template | 420 // Helper functions for constructing tuples while inferring the template |
373 // argument types. | 421 // argument types. |
374 | 422 |
375 inline Tuple0 MakeTuple() { | 423 inline Tuple0 MakeTuple() { |
376 return Tuple0(); | 424 return Tuple0(); |
377 } | 425 } |
378 | 426 |
379 template <class A> | 427 template <class A> |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 class InA, class InB, class InC, class InD, class InE, class InF, | 1036 class InA, class InB, class InC, class InD, class InE, class InF, |
989 class OutA, class OutB, class OutC, class OutD, class OutE> | 1037 class OutA, class OutB, class OutC, class OutD, class OutE> |
990 inline void DispatchToMethod(ObjT* obj, Method method, | 1038 inline void DispatchToMethod(ObjT* obj, Method method, |
991 const Tuple6<InA, InB, InC, InD, InE, InF>& in, | 1039 const Tuple6<InA, InB, InC, InD, InE, InF>& in, |
992 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { | 1040 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { |
993 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, | 1041 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, |
994 &out->a, &out->b, &out->c, &out->d, &out->e); | 1042 &out->a, &out->b, &out->c, &out->d, &out->e); |
995 } | 1043 } |
996 | 1044 |
997 #endif // BASE_TUPLE_H__ | 1045 #endif // BASE_TUPLE_H__ |
OLD | NEW |