source: NonGTP/Boost/boost/lambda/detail/function_adaptors.hpp @ 857

Revision 857, 26.0 KB checked in by igarcia, 19 years ago (diff)
Line 
1// Boost Lambda Library -  function_adaptors.hpp ----------------------------
2 
3// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi)
4//
5// Distributed under the Boost Software License, Version 1.0. (See
6// accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9// For more information, see www.boost.org
10
11
12#ifndef BOOST_LAMBDA_FUNCTION_ADAPTORS_HPP
13#define BOOST_LAMBDA_FUNCTION_ADAPTORS_HPP
14
15#include "boost/type_traits/same_traits.hpp"
16
17namespace boost {
18namespace lambda {
19
20template <class Func> struct function_adaptor {
21
22  // we do not know the return type off-hand, we must ask it from Func
23  template <class Args> class sig {
24    typedef typename Args::head_type F;
25    typedef typename detail::remove_reference_and_cv<Func>::type plainF;
26  public:
27    // To sig we pass a cons list, where the head is the function object type
28    // itself (potentially cv-qualified)
29    // and the tail contains the types of the actual arguments to be passed
30    // to the function object. The arguments can be cv qualified
31    // as well.
32    typedef typename plainF::template sig<Args>::type type;
33  };
34
35  template<class RET, class A1>
36  static RET apply(A1& a1) {
37    return a1();
38  }
39  template<class RET, class A1, class A2>
40  static RET apply(A1& a1, A2& a2) {
41    return a1(a2);
42  }
43  template<class RET, class A1, class A2, class A3>
44  static RET apply(A1& a1, A2& a2, A3& a3) {
45    return a1(a2, a3);
46  }
47  template<class RET, class A1, class A2, class A3, class A4>
48  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4) {
49    return a1(a2, a3, a4);
50  }
51  template<class RET, class A1, class A2, class A3, class A4, class A5>
52  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
53    return a1(a2, a3, a4, a5);
54  }
55  template<class RET, class A1, class A2, class A3, class A4, class A5, class A6>
56  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6) {
57    return a1(a2, a3, a4, a5, a6);
58  }
59  template<class RET, class A1, class A2, class A3, class A4, class A5, class A6,
60           class A7>
61  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6,
62                           A7& a7) {
63    return a1(a2, a3, a4, a5, a6, a7);
64  }
65  template<class RET, class A1, class A2, class A3, class A4, class A5, class A6,
66           class A7, class A8>
67  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6,
68                           A7& a7, A8& a8) {
69    return a1(a2, a3, a4, a5, a6, a7, a8);
70  }
71  template<class RET, class A1, class A2, class A3, class A4, class A5, class A6,
72           class A7, class A8, class A9>
73  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6,
74                           A7& a7, A8& a8, A9& a9) {
75    return a1(a2, a3, a4, a5, a6, a7, a8, a9);
76  }
77  template<class RET, class A1, class A2, class A3, class A4, class A5, class A6,
78           class A7, class A8, class A9, class A10>
79  static RET apply(A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6,
80                           A7& a7, A8& a8, A9& a9, A10& a10) {
81    return a1(a2, a3, a4, a5, a6, a7, a8, a9, a10);
82  }
83};
84
85template <class Func> struct function_adaptor<const Func>; // error
86
87// -- function adaptors with data member access
88template <class Object, class T>
89struct function_adaptor<T Object::*> {
90
91  //  typedef detail::unspecified type;
92
93  // T can have qualifiers and can be a reference type
94  // We get the return type by adding const, if the object through which
95  // the data member is accessed is const, and finally adding a reference
96  template<class Args> class sig {
97    typedef typename boost::tuples::element<1, Args>::type argument_type;
98
99    typedef typename detail::IF<boost::is_const<argument_type>::value,
100      typename boost::add_const<T>::type,
101      T
102    >::RET properly_consted_return_type;
103
104    typedef typename detail::IF<
105        boost::is_volatile<properly_consted_return_type>::value,
106      typename boost::add_volatile<properly_consted_return_type>::type,
107      properly_consted_return_type
108    >::RET properly_cvd_return_type;
109
110
111  public:
112    typedef typename
113      boost::add_reference<properly_cvd_return_type>::type type;
114  };
115
116  template <class RET>
117  static RET apply( T Object::*data, Object& o) {
118    return o.*data;
119  }
120  template <class RET>
121  static RET apply( T Object::*data, const Object& o) {
122    return o.*data;
123  }
124  template <class RET>
125  static RET apply( T Object::*data, volatile Object& o) {
126    return o.*data;
127  }
128  template <class RET>
129  static RET apply( T Object::*data, const volatile Object& o) {
130    return o.*data;
131  }
132  template <class RET>
133  static RET apply( T Object::*data, Object* o) {
134    return o->*data;
135  }
136  template <class RET>
137  static RET apply( T Object::*data, const Object* o) {
138    return o->*data;
139  }
140  template <class RET>
141  static RET apply( T Object::*data, volatile Object* o) {
142    return o->*data;
143  }
144  template <class RET>
145  static RET apply( T Object::*data, const volatile Object* o) {
146    return o->*data;
147  }
148};
149
150// -- function adaptors with 1 argument apply
151   
152template <class Result>
153struct function_adaptor<Result (void)> {
154 
155  template<class T> struct sig { typedef Result type; };
156  template <class RET>
157  static Result apply(Result (*func)()) {
158    return func();
159  }
160};
161
162template <class Result>
163struct function_adaptor<Result (*)(void)> {
164
165  template<class T> struct sig { typedef Result type; };
166  template <class RET>
167  static Result apply(Result (*func)()) {
168    return func();
169  }
170};
171
172
173// -- function adaptors with 2 argument apply
174template <class Object, class Result>
175struct function_adaptor<Result (Object::*)() const> {
176
177  template<class T> struct sig { typedef Result type; };
178  template <class RET>
179  static Result apply( Result (Object::*func)() const, const Object* o) {
180    return (o->*func)();
181  }
182  template <class RET>
183  static Result apply( Result (Object::*func)() const, const Object& o) {
184    return (o.*func)();
185  }
186};
187
188template <class Object, class Result>
189struct function_adaptor<Result (Object::*)()> {
190
191  template<class T> struct sig { typedef Result type; };
192  template <class RET>
193  static Result apply( Result (Object::*func)(), Object* o) {
194    return (o->*func)();
195  }
196  template <class RET>
197  static Result apply( Result (Object::*func)(), Object& o) {
198    return (o.*func)();
199  }
200};
201
202template <class Arg1, class Result>
203struct function_adaptor<Result (Arg1)> {
204
205  template<class T> struct sig { typedef Result type; };
206  template <class RET, class A1>
207  static Result apply(Result (*func)(Arg1), A1& a1) {
208    return func(a1);
209  }
210};
211
212template <class Arg1, class Result>
213struct function_adaptor<Result (*)(Arg1)> {
214
215  template<class T> struct sig { typedef Result type; };
216  template <class RET, class A1>
217  static Result apply(Result (*func)(Arg1), A1& a1) {
218    return func(a1);
219  }
220};
221
222
223// -- function adaptors with 3 argument apply
224template <class Object, class Arg1, class Result>
225struct function_adaptor<Result (Object::*)(Arg1) const> {
226
227  template<class T> struct sig { typedef Result type; };
228  template <class RET, class A1>
229  static Result apply( Result (Object::*func)(Arg1) const, const Object* o,
230    A1& a1) {
231    return (o->*func)(a1);
232  }
233  template <class RET, class A1>
234  static Result apply( Result (Object::*func)(Arg1) const, const Object& o,
235    A1& a1) {
236    return (o.*func)(a1);
237  }
238};
239
240template <class Object, class Arg1, class Result>
241struct function_adaptor<Result (Object::*)(Arg1)> {
242
243  template<class T> struct sig { typedef Result type; };
244  template <class RET, class A1>
245  static Result apply( Result (Object::*func)(Arg1), Object* o, A1& a1) {
246    return (o->*func)(a1);
247  }
248  template <class RET, class A1>
249  static Result apply( Result (Object::*func)(Arg1), Object& o, A1& a1) {
250    return (o.*func)(a1);
251  }
252};
253
254template <class Arg1, class Arg2, class Result>
255struct function_adaptor<Result (Arg1, Arg2)> {
256
257  template<class T> struct sig { typedef Result type; };
258  template <class RET, class A1, class A2>
259  static Result apply(Result (*func)(Arg1, Arg2), A1& a1, A2& a2) {
260    return func(a1, a2);
261  }
262};
263
264template <class Arg1, class Arg2, class Result>
265struct function_adaptor<Result (*)(Arg1, Arg2)> {
266
267  template<class T> struct sig { typedef Result type; };
268  template <class RET, class A1, class A2>
269  static Result apply(Result (*func)(Arg1, Arg2), A1& a1, A2& a2) {
270    return func(a1, a2);
271  }
272};
273
274
275// -- function adaptors with 4 argument apply
276template <class Object, class Arg1, class Arg2, class Result>
277struct function_adaptor<Result (Object::*)(Arg1, Arg2) const> {
278
279  template<class T> struct sig { typedef Result type; };
280  template <class RET, class A1, class A2>
281  static Result apply( Result (Object::*func)(Arg1, Arg2) const, const Object* o, A1& a1, A2& a2) {
282    return (o->*func)(a1, a2);
283  }
284  template <class RET, class A1, class A2>
285  static Result apply( Result (Object::*func)(Arg1, Arg2) const, const Object& o, A1& a1, A2& a2) {
286    return (o.*func)(a1, a2);
287  }
288};
289
290template <class Object, class Arg1, class Arg2, class Result>
291struct function_adaptor<Result (Object::*)(Arg1, Arg2)> {
292
293  template<class T> struct sig { typedef Result type; };
294  template <class RET, class A1, class A2>
295  static Result apply( Result (Object::*func)(Arg1, Arg2), Object* o, A1& a1, A2& a2) {
296    return (o->*func)(a1, a2);
297  }
298  template <class RET, class A1, class A2>
299  static Result apply( Result (Object::*func)(Arg1, Arg2), Object& o, A1& a1, A2& a2) {
300    return (o.*func)(a1, a2);
301  }
302};
303
304template <class Arg1, class Arg2, class Arg3, class Result>
305struct function_adaptor<Result (Arg1, Arg2, Arg3)> {
306
307  template<class T> struct sig { typedef Result type; };
308  template <class RET, class A1, class A2, class A3>
309  static Result apply(Result (*func)(Arg1, Arg2, Arg3), A1& a1, A2& a2, A3& a3) {
310    return func(a1, a2, a3);
311  }
312};
313
314template <class Arg1, class Arg2, class Arg3, class Result>
315struct function_adaptor<Result (*)(Arg1, Arg2, Arg3)> {
316
317  template<class T> struct sig { typedef Result type; };
318  template <class RET, class A1, class A2, class A3>
319  static Result apply(Result (*func)(Arg1, Arg2, Arg3), A1& a1, A2& a2, A3& a3) {
320    return func(a1, a2, a3);
321  }
322};
323
324
325// -- function adaptors with 5 argument apply
326template <class Object, class Arg1, class Arg2, class Arg3, class Result>
327struct function_adaptor<Result (Object::*)(Arg1, Arg2, Arg3) const> {
328
329  template<class T> struct sig { typedef Result type; };
330  template <class RET, class A1, class A2, class A3>
331  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3) const, const Object* o, A1& a1, A2& a2, A3& a3) {
332    return (o->*func)(a1, a2, a3);
333  }
334  template <class RET, class A1, class A2, class A3>
335  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3) const, const Object& o, A1& a1, A2& a2, A3& a3) {
336    return (o.*func)(a1, a2, a3);
337  }
338};
339
340template <class Object, class Arg1, class Arg2, class Arg3, class Result>
341struct function_adaptor<Result (Object::*)(Arg1, Arg2, Arg3)> {
342
343  template<class T> struct sig { typedef Result type; };
344  template <class RET, class A1, class A2, class A3>
345  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3), Object* o, A1& a1, A2& a2, A3& a3) {
346    return (o->*func)(a1, a2, a3);
347  }
348  template <class RET, class A1, class A2, class A3>
349  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3), Object& o, A1& a1, A2& a2, A3& a3) {
350    return (o.*func)(a1, a2, a3);
351  }
352};
353
354template <class Arg1, class Arg2, class Arg3, class Arg4, class Result>
355struct function_adaptor<Result (Arg1, Arg2, Arg3, Arg4)> {
356
357  template<class T> struct sig { typedef Result type; };
358  template <class RET, class A1, class A2, class A3, class A4>
359  static Result apply(Result (*func)(Arg1, Arg2, Arg3, Arg4), A1& a1, A2& a2, A3& a3, A4& a4) {
360    return func(a1, a2, a3, a4);
361  }
362};
363
364template <class Arg1, class Arg2, class Arg3, class Arg4, class Result>
365struct function_adaptor<Result (*)(Arg1, Arg2, Arg3, Arg4)> {
366
367  template<class T> struct sig { typedef Result type; };
368  template <class RET, class A1, class A2, class A3, class A4>
369  static Result apply(Result (*func)(Arg1, Arg2, Arg3, Arg4), A1& a1, A2& a2, A3& a3, A4& a4) {
370    return func(a1, a2, a3, a4);
371  }
372};
373
374
375// -- function adaptors with 6 argument apply
376template <class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Result>
377struct function_adaptor<Result (Object::*)(Arg1, Arg2, Arg3, Arg4) const> {
378
379  template<class T> struct sig { typedef Result type; };
380  template <class RET, class A1, class A2, class A3, class A4>
381  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4) const, const Object* o, A1& a1, A2& a2, A3& a3, A4& a4) {
382    return (o->*func)(a1, a2, a3, a4);
383  }
384  template <class RET, class A1, class A2, class A3, class A4>
385  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4) const, const Object& o, A1& a1, A2& a2, A3& a3, A4& a4) {
386    return (o.*func)(a1, a2, a3, a4);
387  }
388};
389
390template <class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Result>
391struct function_adaptor<Result (Object::*)(Arg1, Arg2, Arg3, Arg4)> {
392
393  template<class T> struct sig { typedef Result type; };
394  template <class RET, class A1, class A2, class A3, class A4>
395  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4), Object* o, A1& a1, A2& a2, A3& a3, A4& a4) {
396    return (o->*func)(a1, a2, a3, a4);
397  }
398  template <class RET, class A1, class A2, class A3, class A4>
399  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4), Object& o, A1& a1, A2& a2, A3& a3, A4& a4) {
400    return (o.*func)(a1, a2, a3, a4);
401  }
402};
403
404template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Result>
405struct function_adaptor<Result (Arg1, Arg2, Arg3, Arg4, Arg5)> {
406
407  template<class T> struct sig { typedef Result type; };
408  template <class RET, class A1, class A2, class A3, class A4, class A5>
409  static Result apply(Result (*func)(Arg1, Arg2, Arg3, Arg4, Arg5), A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
410    return func(a1, a2, a3, a4, a5);
411  }
412};
413
414template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Result>
415struct function_adaptor<Result (*)(Arg1, Arg2, Arg3, Arg4, Arg5)> {
416
417  template<class T> struct sig { typedef Result type; };
418  template <class RET, class A1, class A2, class A3, class A4, class A5>
419  static Result apply(Result (*func)(Arg1, Arg2, Arg3, Arg4, Arg5), A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
420    return func(a1, a2, a3, a4, a5);
421  }
422};
423
424
425// -- function adaptors with 7 argument apply
426template <class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Result>
427struct function_adaptor<Result (Object::*)(Arg1, Arg2, Arg3, Arg4, Arg5) const> {
428
429  template<class T> struct sig { typedef Result type; };
430  template <class RET, class A1, class A2, class A3, class A4, class A5>
431  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5) const, const Object* o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
432    return (o->*func)(a1, a2, a3, a4, a5);
433  }
434  template <class RET, class A1, class A2, class A3, class A4, class A5>
435  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5) const, const Object& o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
436    return (o.*func)(a1, a2, a3, a4, a5);
437  }
438};
439
440template <class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Result>
441struct function_adaptor<Result (Object::*)(Arg1, Arg2, Arg3, Arg4, Arg5)> {
442
443  template<class T> struct sig { typedef Result type; };
444  template <class RET, class A1, class A2, class A3, class A4, class A5>
445  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5), Object* o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
446    return (o->*func)(a1, a2, a3, a4, a5);
447  }
448  template <class RET, class A1, class A2, class A3, class A4, class A5>
449  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5), Object& o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5) {
450    return (o.*func)(a1, a2, a3, a4, a5);
451  }
452};
453
454template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Result>
455struct function_adaptor<Result (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)> {
456
457  template<class T> struct sig { typedef Result type; };
458  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6>
459  static Result apply(Result (*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6) {
460    return func(a1, a2, a3, a4, a5, a6);
461  }
462};
463
464template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Result>
465struct function_adaptor<Result (*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)> {
466
467  template<class T> struct sig { typedef Result type; };
468  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6>
469  static Result apply(Result (*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6) {
470    return func(a1, a2, a3, a4, a5, a6);
471  }
472};
473
474
475// -- function adaptors with 8 argument apply
476template <class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Result>
477struct function_adaptor<Result (Object::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) const> {
478
479  template<class T> struct sig { typedef Result type; };
480  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6>
481  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) const, const Object* o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6) {
482    return (o->*func)(a1, a2, a3, a4, a5, a6);
483  }
484  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6>
485  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) const, const Object& o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6) {
486    return (o.*func)(a1, a2, a3, a4, a5, a6);
487  }
488};
489
490template <class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Result>
491struct function_adaptor<Result (Object::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)> {
492
493  template<class T> struct sig { typedef Result type; };
494  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6>
495  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), Object* o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6) {
496    return (o->*func)(a1, a2, a3, a4, a5, a6);
497  }
498  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6>
499  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), Object& o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6) {
500    return (o.*func)(a1, a2, a3, a4, a5, a6);
501  }
502};
503
504template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Result>
505struct function_adaptor<Result (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)> {
506
507  template<class T> struct sig { typedef Result type; };
508  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
509  static Result apply(Result (*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7), A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7) {
510    return func(a1, a2, a3, a4, a5, a6, a7);
511  }
512};
513
514template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Result>
515struct function_adaptor<Result (*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)> {
516
517  template<class T> struct sig { typedef Result type; };
518  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
519  static Result apply(Result (*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7), A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7) {
520    return func(a1, a2, a3, a4, a5, a6, a7);
521  }
522};
523
524
525// -- function adaptors with 9 argument apply
526template <class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Result>
527struct function_adaptor<Result (Object::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) const> {
528
529  template<class T> struct sig { typedef Result type; };
530  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
531  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) const, const Object* o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7) {
532    return (o->*func)(a1, a2, a3, a4, a5, a6, a7);
533  }
534  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
535  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) const, const Object& o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7) {
536    return (o.*func)(a1, a2, a3, a4, a5, a6, a7);
537  }
538};
539
540template <class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Result>
541struct function_adaptor<Result (Object::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7)> {
542
543  template<class T> struct sig { typedef Result type; };
544  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
545  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7), Object* o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7) {
546    return (o->*func)(a1, a2, a3, a4, a5, a6, a7);
547  }
548  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
549  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7), Object& o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7) {
550    return (o.*func)(a1, a2, a3, a4, a5, a6, a7);
551  }
552};
553
554template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Result>
555struct function_adaptor<Result (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8)> {
556
557  template<class T> struct sig { typedef Result type; };
558  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
559  static Result apply(Result (*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8), A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, A8& a8) {
560    return func(a1, a2, a3, a4, a5, a6, a7, a8);
561  }
562};
563
564template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Result>
565struct function_adaptor<Result (*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8)> {
566
567  template<class T> struct sig { typedef Result type; };
568  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
569  static Result apply(Result (*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8), A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, A8& a8) {
570    return func(a1, a2, a3, a4, a5, a6, a7, a8);
571  }
572};
573
574
575// -- function adaptors with 10 argument apply
576template <class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Result>
577struct function_adaptor<Result (Object::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) const> {
578
579  template<class T> struct sig { typedef Result type; };
580  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
581  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) const, const Object* o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, A8& a8) {
582    return (o->*func)(a1, a2, a3, a4, a5, a6, a7, a8);
583  }
584  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
585  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) const, const Object& o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, A8& a8) {
586    return (o.*func)(a1, a2, a3, a4, a5, a6, a7, a8);
587  }
588};
589
590template <class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Result>
591struct function_adaptor<Result (Object::*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8)> {
592
593  template<class T> struct sig { typedef Result type; };
594  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
595  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8), Object* o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, A8& a8) {
596    return (o->*func)(a1, a2, a3, a4, a5, a6, a7, a8);
597  }
598  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
599  static Result apply( Result (Object::*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8), Object& o, A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, A8& a8) {
600    return (o.*func)(a1, a2, a3, a4, a5, a6, a7, a8);
601  }
602};
603
604template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Arg9, class Result>
605struct function_adaptor<Result (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9)> {
606
607  template<class T> struct sig { typedef Result type; };
608  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
609  static Result apply(Result (*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9), A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, A8& a8, A9& a9) {
610    return func(a1, a2, a3, a4, a5, a6, a7, a8, a9);
611  }
612};
613
614template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Arg9, class Result>
615struct function_adaptor<Result (*)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9)> {
616
617  template<class T> struct sig { typedef Result type; };
618  template <class RET, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
619  static Result apply(Result (*func)(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9), A1& a1, A2& a2, A3& a3, A4& a4, A5& a5, A6& a6, A7& a7, A8& a8, A9& a9) {
620    return func(a1, a2, a3, a4, a5, a6, a7, a8, a9);
621  }
622};
623
624} // namespace lambda
625} // namespace boost
626
627#endif
628
629
630
631
632
633
634
635
636
637
638
639
640
Note: See TracBrowser for help on using the repository browser.