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 ){
12 return ( object.*member )();
16 template<typename Object, typename R, R( Object::*member ) ( ) const>
20 typedef const Object& first_argument_type;
21 typedef R result_type;
22 static result_type call( first_argument_type object ){
23 return ( object.*member )();
27 template<typename Object, typename A1, typename R, R( Object::*member ) (A1)>
31 typedef Object& first_argument_type;
32 typedef A1 second_argument_type;
33 typedef R result_type;
34 static result_type call( first_argument_type object, second_argument_type a1 ){
35 return ( object.*member )( a1 );
39 template<typename Object, typename A1, typename R, R( Object::*member ) (A1) const>
43 typedef const Object& first_argument_type;
44 typedef A1 second_argument_type;
45 typedef R result_type;
46 static result_type call( first_argument_type object, second_argument_type a1 ){
47 return ( object.*member )( a1 );
51 template<typename Object, typename A2, typename A3, typename R, R( Object::*member ) ( A2, A3 )>
55 typedef Object& first_argument_type;
56 typedef A2 second_argument_type;
57 typedef A3 third_argument_type;
58 typedef R result_type;
59 static result_type call( first_argument_type object, second_argument_type a2, third_argument_type a3 ){
60 return ( object.*member )( a2, a3 );
64 template<typename Object, typename A2, typename A3, typename R, R( Object::*member ) ( A2, A3 ) const>
68 typedef const Object& first_argument_type;
69 typedef A2 second_argument_type;
70 typedef A3 third_argument_type;
71 typedef R result_type;
72 static result_type call( first_argument_type object, second_argument_type a2, third_argument_type a3 ){
73 return ( object.*member )( a2, a3 );
77 template<typename Object, typename A2, typename A3, typename A4, typename R, R( Object::*member ) ( A2, A3, A4 )>
81 typedef Object& first_argument_type;
82 typedef A2 second_argument_type;
83 typedef A3 third_argument_type;
84 typedef A4 fourth_argument_type;
85 typedef R result_type;
86 static result_type call( first_argument_type object, second_argument_type a2, third_argument_type a3, fourth_argument_type a4 ){
87 return ( object.*member )( a2, a3, a4 );
91 template<typename Object, typename A2, typename A3, typename A4, typename R, R( Object::*member ) ( A2, A3, A4 ) const>
95 typedef const Object& first_argument_type;
96 typedef A2 second_argument_type;
97 typedef A3 third_argument_type;
98 typedef A4 fourth_argument_type;
99 typedef R result_type;
100 static result_type call( first_argument_type object, second_argument_type a2, third_argument_type a3, fourth_argument_type a4 ){
101 return ( object.*member )( a2, a3, a4 );
105 template<typename R, R( *func ) ( )>
109 typedef R result_type;
110 static result_type call(){
115 template<typename A1, typename R, R( *func ) (A1)>
119 typedef A1 first_argument_type;
120 typedef R result_type;
121 static result_type call( first_argument_type a1 ){
126 template<typename A1, typename A2, typename R, R( *func ) ( A1, A2 )>
130 typedef A1 first_argument_type;
131 typedef A2 second_argument_type;
132 typedef R result_type;
133 static result_type call( first_argument_type a1, second_argument_type a2 ){
134 return (func)( a1, a2 );
138 template<typename A1, typename A2, typename A3, typename R, R( *func ) ( A1, A2, A3 )>
142 typedef A1 first_argument_type;
143 typedef A2 second_argument_type;
144 typedef A3 third_argument_type;
145 typedef R result_type;
146 static result_type call( first_argument_type a1, second_argument_type a2, third_argument_type a3 ){
147 return (func)( a1, a2, a3 );
151 template<typename A1, typename A2, typename A3, typename A4, typename R, R( *func ) ( A1, A2, A3, A4 )>
155 typedef A1 first_argument_type;
156 typedef A2 second_argument_type;
157 typedef A3 third_argument_type;
158 typedef A4 fourth_argument_type;
159 typedef R result_type;
160 static result_type call( first_argument_type a1, second_argument_type a2, third_argument_type a3, fourth_argument_type a4 ){
161 return (func)( a1, a2, a3, a4 );
165 template<typename Caller, typename FirstArgument = void*>
169 typedef FirstArgument first_argument_type;
170 typedef typename Caller::result_type result_type;
171 static result_type call( first_argument_type ){
172 return Caller::call();
176 template<typename Caller, typename FirstArgument = void*>
180 typedef FirstArgument first_argument_type;
181 typedef typename Caller::first_argument_type second_argument_type;
182 typedef typename Caller::result_type result_type;
183 static result_type call( first_argument_type, second_argument_type a2 ){
184 return Caller::call( a2 );
188 template<typename Caller, typename FirstArgument = void*>
192 typedef FirstArgument first_argument_type;
193 typedef typename Caller::first_argument_type second_argument_type;
194 typedef typename Caller::second_argument_type third_argument_type;
195 typedef typename Caller::result_type result_type;
196 static result_type call( first_argument_type, second_argument_type a2, third_argument_type a3 ){
197 return Caller::call( a2, a3 );
201 template<typename Caller, typename FirstArgument = void*>
205 typedef FirstArgument first_argument_type;
206 typedef typename Caller::first_argument_type second_argument_type;
207 typedef typename Caller::second_argument_type third_argument_type;
208 typedef typename Caller::third_argument_type fourth_argument_type;
209 typedef typename Caller::result_type result_type;
210 static result_type call( first_argument_type, second_argument_type a2, third_argument_type a3, fourth_argument_type a4 ){
211 return Caller::call( a2, a3, a4 );
215 template<typename Functor>
219 typedef typename Functor::result_type result_type;
220 inline result_type operator()( Functor functor ){
225 template<typename Functor>
228 typename Functor::first_argument_type a1;
230 typedef typename Functor::first_argument_type first_argument_type;
231 typedef typename Functor::result_type result_type;
232 Functor1Invoke( first_argument_type a1 ) : a1( a1 ){
234 inline result_type operator()( Functor functor ){
235 return functor( a1 );
239 template<typename Functor>
242 typename Functor::first_argument_type a1;
243 typename Functor::second_argument_type a2;
245 typedef typename Functor::first_argument_type first_argument_type;
246 typedef typename Functor::second_argument_type second_argument_type;
247 typedef typename Functor::result_type result_type;
248 Functor2Invoke( first_argument_type a1, second_argument_type a2 )
249 : a1( a1 ), a2( a2 ){
251 inline result_type operator()( Functor functor ){
252 return functor( a1, a2 );
256 template<typename Functor>
259 typename Functor::first_argument_type a1;
260 typename Functor::second_argument_type a2;
261 typename Functor::third_argument_type a3;
263 typedef typename Functor::first_argument_type first_argument_type;
264 typedef typename Functor::second_argument_type second_argument_type;
265 typedef typename Functor::third_argument_type third_argument_type;
266 typedef typename Functor::result_type result_type;
267 Functor3Invoke( first_argument_type a1, second_argument_type a2, third_argument_type a3 )
268 : a1( a1 ), a2( a2 ), a3( a3 ){
270 inline result_type operator()( Functor functor ){
271 return functor( a1, a2, a3 );
275 template<typename Other, typename True, typename False, typename Type>
281 template<typename Other, typename True, typename False>
282 class TypeEqual<Other, True, False, Other>