2 #if !defined(INCLUDED_FUNCTIONAL_H)
3 #define INCLUDED_FUNCTIONAL_H
5 template<typename Object, typename R, R (Object::*member)()>
9 typedef Object& first_argument_type;
10 typedef R result_type;
11 static result_type call(first_argument_type object)
13 return (object.*member)();
17 template<typename Object, typename R, R (Object::*member)() const>
21 typedef const Object& first_argument_type;
22 typedef R result_type;
23 static result_type call(first_argument_type object)
25 return (object.*member)();
29 template<typename Object, typename A1, typename R, R (Object::*member)(A1)>
33 typedef Object& first_argument_type;
34 typedef A1 second_argument_type;
35 typedef R result_type;
36 static result_type call(first_argument_type object, second_argument_type a1)
38 return (object.*member)(a1);
42 template<typename Object, typename A1, typename R, R (Object::*member)(A1) const>
46 typedef const Object& first_argument_type;
47 typedef A1 second_argument_type;
48 typedef R result_type;
49 static result_type call(first_argument_type object, second_argument_type a1)
51 return (object.*member)(a1);
55 template<typename Object, typename A2, typename A3, typename R, R (Object::*member)(A2, A3)>
59 typedef Object& first_argument_type;
60 typedef A2 second_argument_type;
61 typedef A3 third_argument_type;
62 typedef R result_type;
63 static result_type call(first_argument_type object, second_argument_type a2, third_argument_type a3)
65 return (object.*member)(a2, a3);
69 template<typename Object, typename A2, typename A3, typename R, R (Object::*member)(A2, A3) const>
73 typedef const Object& first_argument_type;
74 typedef A2 second_argument_type;
75 typedef A3 third_argument_type;
76 typedef R result_type;
77 static result_type call(first_argument_type object, second_argument_type a2, third_argument_type a3)
79 return (object.*member)(a2, a3);
83 template<typename Object, typename A2, typename A3, typename A4, typename R, R (Object::*member)(A2, A3, A4)>
87 typedef Object& first_argument_type;
88 typedef A2 second_argument_type;
89 typedef A3 third_argument_type;
90 typedef A4 fourth_argument_type;
91 typedef R result_type;
92 static result_type call(first_argument_type object, second_argument_type a2, third_argument_type a3, fourth_argument_type a4)
94 return (object.*member)(a2, a3, a4);
98 template<typename Object, typename A2, typename A3, typename A4, typename R, R (Object::*member)(A2, A3, A4) const>
102 typedef const Object& first_argument_type;
103 typedef A2 second_argument_type;
104 typedef A3 third_argument_type;
105 typedef A4 fourth_argument_type;
106 typedef R result_type;
107 static result_type call(first_argument_type object, second_argument_type a2, third_argument_type a3, fourth_argument_type a4)
109 return (object.*member)(a2, a3, a4);
113 template<typename R, R (*func)()>
117 typedef R result_type;
118 static result_type call()
124 template<typename A1, typename R, R (*func)(A1)>
128 typedef A1 first_argument_type;
129 typedef R result_type;
130 static result_type call(first_argument_type a1)
136 template<typename A1, typename A2, typename R, R (*func)(A1, A2)>
140 typedef A1 first_argument_type;
141 typedef A2 second_argument_type;
142 typedef R result_type;
143 static result_type call(first_argument_type a1, second_argument_type a2)
145 return (func)(a1, a2);
149 template<typename A1, typename A2, typename A3, typename R, R (*func)(A1, A2, A3)>
153 typedef A1 first_argument_type;
154 typedef A2 second_argument_type;
155 typedef A3 third_argument_type;
156 typedef R result_type;
157 static result_type call(first_argument_type a1, second_argument_type a2, third_argument_type a3)
159 return (func)(a1, a2, a3);
163 template<typename A1, typename A2, typename A3, typename A4, typename R, R (*func)(A1, A2, A3, A4)>
167 typedef A1 first_argument_type;
168 typedef A2 second_argument_type;
169 typedef A3 third_argument_type;
170 typedef A4 fourth_argument_type;
171 typedef R result_type;
172 static result_type call(first_argument_type a1, second_argument_type a2, third_argument_type a3, fourth_argument_type a4)
174 return (func)(a1, a2, a3, a4);
178 template<typename Caller, typename FirstArgument = void*>
182 typedef FirstArgument first_argument_type;
183 typedef typename Caller::result_type result_type;
184 static result_type call(first_argument_type)
186 return Caller::call();
190 template<typename Caller, typename FirstArgument = void*>
194 typedef FirstArgument first_argument_type;
195 typedef typename Caller::first_argument_type second_argument_type;
196 typedef typename Caller::result_type result_type;
197 static result_type call(first_argument_type, second_argument_type a2)
199 return Caller::call(a2);
203 template<typename Caller, typename FirstArgument = void*>
207 typedef FirstArgument first_argument_type;
208 typedef typename Caller::first_argument_type second_argument_type;
209 typedef typename Caller::second_argument_type third_argument_type;
210 typedef typename Caller::result_type result_type;
211 static result_type call(first_argument_type, second_argument_type a2, third_argument_type a3)
213 return Caller::call(a2, a3);
217 template<typename Caller, typename FirstArgument = void*>
221 typedef FirstArgument first_argument_type;
222 typedef typename Caller::first_argument_type second_argument_type;
223 typedef typename Caller::second_argument_type third_argument_type;
224 typedef typename Caller::third_argument_type fourth_argument_type;
225 typedef typename Caller::result_type result_type;
226 static result_type call(first_argument_type, second_argument_type a2, third_argument_type a3, fourth_argument_type a4)
228 return Caller::call(a2, a3, a4);
232 template<typename Functor>
236 typedef typename Functor::result_type result_type;
237 inline result_type operator()(Functor functor)
243 template<typename Functor>
246 typename Functor::first_argument_type a1;
248 typedef typename Functor::first_argument_type first_argument_type;
249 typedef typename Functor::result_type result_type;
250 Functor1Invoke(first_argument_type a1) : a1(a1)
253 inline result_type operator()(Functor functor)
259 template<typename Functor>
262 typename Functor::first_argument_type a1;
263 typename Functor::second_argument_type a2;
265 typedef typename Functor::first_argument_type first_argument_type;
266 typedef typename Functor::second_argument_type second_argument_type;
267 typedef typename Functor::result_type result_type;
268 Functor2Invoke(first_argument_type a1, second_argument_type a2)
272 inline result_type operator()(Functor functor)
274 return functor(a1, a2);
278 template<typename Functor>
281 typename Functor::first_argument_type a1;
282 typename Functor::second_argument_type a2;
283 typename Functor::third_argument_type a3;
285 typedef typename Functor::first_argument_type first_argument_type;
286 typedef typename Functor::second_argument_type second_argument_type;
287 typedef typename Functor::third_argument_type third_argument_type;
288 typedef typename Functor::result_type result_type;
289 Functor3Invoke(first_argument_type a1, second_argument_type a2, third_argument_type a3)
290 : a1(a1), a2(a2), a3(a3)
293 inline result_type operator()(Functor functor)
295 return functor(a1, a2, a3);
299 template<typename Other, typename True, typename False, typename Type>
305 template<typename Other, typename True, typename False>
306 class TypeEqual<Other, True, False, Other>