2 /* Do not edit! -- generated file */
4 #ifndef _SIGC_FUNCTORS_PTR_FUN_H_
5 #define _SIGC_FUNCTORS_PTR_FUN_H_
6 #include <sigc++/type_traits.h>
7 #include <sigc++/functors/functor_trait.h>
11 /** @defgroup ptr_fun ptr_fun()
12 * ptr_fun() is used to convert a pointer to a function to a functor.
13 * If the function pointer is to an overloaded type, you must specify
14 * the types using template arguments starting with the first argument.
15 * It is not necessary to supply the return type.
20 * sigc::slot<void, int> sl = sigc::ptr_fun(&foo);
23 * Use ptr_fun#() if there is an ambiguity as to the number of arguments.
27 * void foo(int) {} // choose this one
29 * void foo(int, int) {}
30 * sigc::slot<void, long> sl = sigc::ptr_fun1<int>(&foo);
33 * ptr_fun() can also be used to convert a pointer to a static member
34 * function to a functor, like so:
40 * static void bar(int) {}
42 * sigc::slot<void, int> sl = sigc::ptr_fun(&foo::bar);
45 * @ingroup sigcfunctors
48 /** pointer_functor0 wraps existing non-member functions with 0 argument(s).
49 * Use the convenience function ptr_fun() to create an instance of pointer_functor0.
51 * The following template arguments are used:
52 * - @e T_return The return type of operator()().
56 template <class T_return>
57 class pointer_functor0 : public functor_base
59 typedef T_return (*function_type)();
61 function_type func_ptr_;
63 typedef T_return result_type;
65 /// Constructs an invalid functor.
68 /** Constructs a pointer_functor0 object that wraps an existing function.
69 * @param _A_func Pointer to function that will be invoked from operator()().
71 explicit pointer_functor0(function_type _A_func): func_ptr_(_A_func) {}
73 /** Execute the wrapped function.
74 * @return The return value of the function invocation.
76 T_return operator()() const
77 { return func_ptr_(); }
80 /** pointer_functor1 wraps existing non-member functions with 1 argument(s).
81 * Use the convenience function ptr_fun() to create an instance of pointer_functor1.
83 * The following template arguments are used:
84 * - @e T_arg1 Argument type used in the definition of operator()().
85 * - @e T_return The return type of operator()().
89 template <class T_arg1, class T_return>
90 class pointer_functor1 : public functor_base
92 typedef T_return (*function_type)(T_arg1);
94 function_type func_ptr_;
96 typedef T_return result_type;
98 /// Constructs an invalid functor.
101 /** Constructs a pointer_functor1 object that wraps an existing function.
102 * @param _A_func Pointer to function that will be invoked from operator()().
104 explicit pointer_functor1(function_type _A_func): func_ptr_(_A_func) {}
106 /** Execute the wrapped function.
107 * @param _A_a1 Argument to be passed on to the function.
108 * @return The return value of the function invocation.
110 T_return operator()(type_trait_take_t<T_arg1> _A_a1) const
111 { return func_ptr_(_A_a1); }
114 /** pointer_functor2 wraps existing non-member functions with 2 argument(s).
115 * Use the convenience function ptr_fun() to create an instance of pointer_functor2.
117 * The following template arguments are used:
118 * - @e T_arg1 Argument type used in the definition of operator()().
119 * - @e T_arg2 Argument type used in the definition of operator()().
120 * - @e T_return The return type of operator()().
124 template <class T_arg1, class T_arg2, class T_return>
125 class pointer_functor2 : public functor_base
127 typedef T_return (*function_type)(T_arg1, T_arg2);
129 function_type func_ptr_;
131 typedef T_return result_type;
133 /// Constructs an invalid functor.
134 pointer_functor2() {}
136 /** Constructs a pointer_functor2 object that wraps an existing function.
137 * @param _A_func Pointer to function that will be invoked from operator()().
139 explicit pointer_functor2(function_type _A_func): func_ptr_(_A_func) {}
141 /** Execute the wrapped function.
142 * @param _A_a1 Argument to be passed on to the function.
143 * @param _A_a2 Argument to be passed on to the function.
144 * @return The return value of the function invocation.
146 T_return operator()(type_trait_take_t<T_arg1> _A_a1, type_trait_take_t<T_arg2> _A_a2) const
147 { return func_ptr_(_A_a1, _A_a2); }
150 /** pointer_functor3 wraps existing non-member functions with 3 argument(s).
151 * Use the convenience function ptr_fun() to create an instance of pointer_functor3.
153 * The following template arguments are used:
154 * - @e T_arg1 Argument type used in the definition of operator()().
155 * - @e T_arg2 Argument type used in the definition of operator()().
156 * - @e T_arg3 Argument type used in the definition of operator()().
157 * - @e T_return The return type of operator()().
161 template <class T_arg1, class T_arg2, class T_arg3, class T_return>
162 class pointer_functor3 : public functor_base
164 typedef T_return (*function_type)(T_arg1, T_arg2, T_arg3);
166 function_type func_ptr_;
168 typedef T_return result_type;
170 /// Constructs an invalid functor.
171 pointer_functor3() {}
173 /** Constructs a pointer_functor3 object that wraps an existing function.
174 * @param _A_func Pointer to function that will be invoked from operator()().
176 explicit pointer_functor3(function_type _A_func): func_ptr_(_A_func) {}
178 /** Execute the wrapped function.
179 * @param _A_a1 Argument to be passed on to the function.
180 * @param _A_a2 Argument to be passed on to the function.
181 * @param _A_a3 Argument to be passed on to the function.
182 * @return The return value of the function invocation.
184 T_return operator()(type_trait_take_t<T_arg1> _A_a1, type_trait_take_t<T_arg2> _A_a2, type_trait_take_t<T_arg3> _A_a3) const
185 { return func_ptr_(_A_a1, _A_a2, _A_a3); }
188 /** pointer_functor4 wraps existing non-member functions with 4 argument(s).
189 * Use the convenience function ptr_fun() to create an instance of pointer_functor4.
191 * The following template arguments are used:
192 * - @e T_arg1 Argument type used in the definition of operator()().
193 * - @e T_arg2 Argument type used in the definition of operator()().
194 * - @e T_arg3 Argument type used in the definition of operator()().
195 * - @e T_arg4 Argument type used in the definition of operator()().
196 * - @e T_return The return type of operator()().
200 template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_return>
201 class pointer_functor4 : public functor_base
203 typedef T_return (*function_type)(T_arg1, T_arg2, T_arg3, T_arg4);
205 function_type func_ptr_;
207 typedef T_return result_type;
209 /// Constructs an invalid functor.
210 pointer_functor4() {}
212 /** Constructs a pointer_functor4 object that wraps an existing function.
213 * @param _A_func Pointer to function that will be invoked from operator()().
215 explicit pointer_functor4(function_type _A_func): func_ptr_(_A_func) {}
217 /** Execute the wrapped function.
218 * @param _A_a1 Argument to be passed on to the function.
219 * @param _A_a2 Argument to be passed on to the function.
220 * @param _A_a3 Argument to be passed on to the function.
221 * @param _A_a4 Argument to be passed on to the function.
222 * @return The return value of the function invocation.
224 T_return operator()(type_trait_take_t<T_arg1> _A_a1, type_trait_take_t<T_arg2> _A_a2, type_trait_take_t<T_arg3> _A_a3, type_trait_take_t<T_arg4> _A_a4) const
225 { return func_ptr_(_A_a1, _A_a2, _A_a3, _A_a4); }
228 /** pointer_functor5 wraps existing non-member functions with 5 argument(s).
229 * Use the convenience function ptr_fun() to create an instance of pointer_functor5.
231 * The following template arguments are used:
232 * - @e T_arg1 Argument type used in the definition of operator()().
233 * - @e T_arg2 Argument type used in the definition of operator()().
234 * - @e T_arg3 Argument type used in the definition of operator()().
235 * - @e T_arg4 Argument type used in the definition of operator()().
236 * - @e T_arg5 Argument type used in the definition of operator()().
237 * - @e T_return The return type of operator()().
241 template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_return>
242 class pointer_functor5 : public functor_base
244 typedef T_return (*function_type)(T_arg1, T_arg2, T_arg3, T_arg4, T_arg5);
246 function_type func_ptr_;
248 typedef T_return result_type;
250 /// Constructs an invalid functor.
251 pointer_functor5() {}
253 /** Constructs a pointer_functor5 object that wraps an existing function.
254 * @param _A_func Pointer to function that will be invoked from operator()().
256 explicit pointer_functor5(function_type _A_func): func_ptr_(_A_func) {}
258 /** Execute the wrapped function.
259 * @param _A_a1 Argument to be passed on to the function.
260 * @param _A_a2 Argument to be passed on to the function.
261 * @param _A_a3 Argument to be passed on to the function.
262 * @param _A_a4 Argument to be passed on to the function.
263 * @param _A_a5 Argument to be passed on to the function.
264 * @return The return value of the function invocation.
266 T_return operator()(type_trait_take_t<T_arg1> _A_a1, type_trait_take_t<T_arg2> _A_a2, type_trait_take_t<T_arg3> _A_a3, type_trait_take_t<T_arg4> _A_a4, type_trait_take_t<T_arg5> _A_a5) const
267 { return func_ptr_(_A_a1, _A_a2, _A_a3, _A_a4, _A_a5); }
270 /** pointer_functor6 wraps existing non-member functions with 6 argument(s).
271 * Use the convenience function ptr_fun() to create an instance of pointer_functor6.
273 * The following template arguments are used:
274 * - @e T_arg1 Argument type used in the definition of operator()().
275 * - @e T_arg2 Argument type used in the definition of operator()().
276 * - @e T_arg3 Argument type used in the definition of operator()().
277 * - @e T_arg4 Argument type used in the definition of operator()().
278 * - @e T_arg5 Argument type used in the definition of operator()().
279 * - @e T_arg6 Argument type used in the definition of operator()().
280 * - @e T_return The return type of operator()().
284 template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6, class T_return>
285 class pointer_functor6 : public functor_base
287 typedef T_return (*function_type)(T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6);
289 function_type func_ptr_;
291 typedef T_return result_type;
293 /// Constructs an invalid functor.
294 pointer_functor6() {}
296 /** Constructs a pointer_functor6 object that wraps an existing function.
297 * @param _A_func Pointer to function that will be invoked from operator()().
299 explicit pointer_functor6(function_type _A_func): func_ptr_(_A_func) {}
301 /** Execute the wrapped function.
302 * @param _A_a1 Argument to be passed on to the function.
303 * @param _A_a2 Argument to be passed on to the function.
304 * @param _A_a3 Argument to be passed on to the function.
305 * @param _A_a4 Argument to be passed on to the function.
306 * @param _A_a5 Argument to be passed on to the function.
307 * @param _A_a6 Argument to be passed on to the function.
308 * @return The return value of the function invocation.
310 T_return operator()(type_trait_take_t<T_arg1> _A_a1, type_trait_take_t<T_arg2> _A_a2, type_trait_take_t<T_arg3> _A_a3, type_trait_take_t<T_arg4> _A_a4, type_trait_take_t<T_arg5> _A_a5, type_trait_take_t<T_arg6> _A_a6) const
311 { return func_ptr_(_A_a1, _A_a2, _A_a3, _A_a4, _A_a5, _A_a6); }
314 /** pointer_functor7 wraps existing non-member functions with 7 argument(s).
315 * Use the convenience function ptr_fun() to create an instance of pointer_functor7.
317 * The following template arguments are used:
318 * - @e T_arg1 Argument type used in the definition of operator()().
319 * - @e T_arg2 Argument type used in the definition of operator()().
320 * - @e T_arg3 Argument type used in the definition of operator()().
321 * - @e T_arg4 Argument type used in the definition of operator()().
322 * - @e T_arg5 Argument type used in the definition of operator()().
323 * - @e T_arg6 Argument type used in the definition of operator()().
324 * - @e T_arg7 Argument type used in the definition of operator()().
325 * - @e T_return The return type of operator()().
329 template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6, class T_arg7, class T_return>
330 class pointer_functor7 : public functor_base
332 typedef T_return (*function_type)(T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7);
334 function_type func_ptr_;
336 typedef T_return result_type;
338 /// Constructs an invalid functor.
339 pointer_functor7() {}
341 /** Constructs a pointer_functor7 object that wraps an existing function.
342 * @param _A_func Pointer to function that will be invoked from operator()().
344 explicit pointer_functor7(function_type _A_func): func_ptr_(_A_func) {}
346 /** Execute the wrapped function.
347 * @param _A_a1 Argument to be passed on to the function.
348 * @param _A_a2 Argument to be passed on to the function.
349 * @param _A_a3 Argument to be passed on to the function.
350 * @param _A_a4 Argument to be passed on to the function.
351 * @param _A_a5 Argument to be passed on to the function.
352 * @param _A_a6 Argument to be passed on to the function.
353 * @param _A_a7 Argument to be passed on to the function.
354 * @return The return value of the function invocation.
356 T_return operator()(type_trait_take_t<T_arg1> _A_a1, type_trait_take_t<T_arg2> _A_a2, type_trait_take_t<T_arg3> _A_a3, type_trait_take_t<T_arg4> _A_a4, type_trait_take_t<T_arg5> _A_a5, type_trait_take_t<T_arg6> _A_a6, type_trait_take_t<T_arg7> _A_a7) const
357 { return func_ptr_(_A_a1, _A_a2, _A_a3, _A_a4, _A_a5, _A_a6, _A_a7); }
362 /** Creates a functor of type sigc::pointer_functor0 which wraps an existing non-member function.
363 * @param _A_func Pointer to function that should be wrapped.
364 * @return Functor that executes @e _A_func on invokation.
368 template <class T_return>
369 inline pointer_functor0<T_return>
370 ptr_fun0(T_return (*_A_func)())
371 { return pointer_functor0<T_return>(_A_func); }
373 /** Creates a functor of type sigc::pointer_functor1 which wraps an existing non-member function.
374 * @param _A_func Pointer to function that should be wrapped.
375 * @return Functor that executes @e _A_func on invokation.
379 template <class T_arg1, class T_return>
380 inline pointer_functor1<T_arg1, T_return>
381 ptr_fun1(T_return (*_A_func)(T_arg1))
382 { return pointer_functor1<T_arg1, T_return>(_A_func); }
384 /** Creates a functor of type sigc::pointer_functor2 which wraps an existing non-member function.
385 * @param _A_func Pointer to function that should be wrapped.
386 * @return Functor that executes @e _A_func on invokation.
390 template <class T_arg1, class T_arg2, class T_return>
391 inline pointer_functor2<T_arg1, T_arg2, T_return>
392 ptr_fun2(T_return (*_A_func)(T_arg1, T_arg2))
393 { return pointer_functor2<T_arg1, T_arg2, T_return>(_A_func); }
395 /** Creates a functor of type sigc::pointer_functor3 which wraps an existing non-member function.
396 * @param _A_func Pointer to function that should be wrapped.
397 * @return Functor that executes @e _A_func on invokation.
401 template <class T_arg1, class T_arg2, class T_arg3, class T_return>
402 inline pointer_functor3<T_arg1, T_arg2, T_arg3, T_return>
403 ptr_fun3(T_return (*_A_func)(T_arg1, T_arg2, T_arg3))
404 { return pointer_functor3<T_arg1, T_arg2, T_arg3, T_return>(_A_func); }
406 /** Creates a functor of type sigc::pointer_functor4 which wraps an existing non-member function.
407 * @param _A_func Pointer to function that should be wrapped.
408 * @return Functor that executes @e _A_func on invokation.
412 template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_return>
413 inline pointer_functor4<T_arg1, T_arg2, T_arg3, T_arg4, T_return>
414 ptr_fun4(T_return (*_A_func)(T_arg1, T_arg2, T_arg3, T_arg4))
415 { return pointer_functor4<T_arg1, T_arg2, T_arg3, T_arg4, T_return>(_A_func); }
417 /** Creates a functor of type sigc::pointer_functor5 which wraps an existing non-member function.
418 * @param _A_func Pointer to function that should be wrapped.
419 * @return Functor that executes @e _A_func on invokation.
423 template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_return>
424 inline pointer_functor5<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_return>
425 ptr_fun5(T_return (*_A_func)(T_arg1, T_arg2, T_arg3, T_arg4, T_arg5))
426 { return pointer_functor5<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_return>(_A_func); }
428 /** Creates a functor of type sigc::pointer_functor6 which wraps an existing non-member function.
429 * @param _A_func Pointer to function that should be wrapped.
430 * @return Functor that executes @e _A_func on invokation.
434 template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6, class T_return>
435 inline pointer_functor6<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_return>
436 ptr_fun6(T_return (*_A_func)(T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6))
437 { return pointer_functor6<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_return>(_A_func); }
439 /** Creates a functor of type sigc::pointer_functor7 which wraps an existing non-member function.
440 * @param _A_func Pointer to function that should be wrapped.
441 * @return Functor that executes @e _A_func on invokation.
445 template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6, class T_arg7, class T_return>
446 inline pointer_functor7<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7, T_return>
447 ptr_fun7(T_return (*_A_func)(T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7))
448 { return pointer_functor7<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7, T_return>(_A_func); }
451 // unnumbered ptr_fun
452 /** Creates a functor of type sigc::pointer_functor0 which wraps an existing non-member function.
453 * @param _A_func Pointer to function that should be wrapped.
454 * @return Functor that executes @e _A_func on invokation.
458 template <class T_return>
459 inline pointer_functor0<T_return>
460 ptr_fun(T_return (*_A_func)())
461 { return pointer_functor0<T_return>(_A_func); }
463 /** Creates a functor of type sigc::pointer_functor1 which wraps an existing non-member function.
464 * @param _A_func Pointer to function that should be wrapped.
465 * @return Functor that executes @e _A_func on invokation.
469 template <class T_arg1, class T_return>
470 inline pointer_functor1<T_arg1, T_return>
471 ptr_fun(T_return (*_A_func)(T_arg1))
472 { return pointer_functor1<T_arg1, T_return>(_A_func); }
474 /** Creates a functor of type sigc::pointer_functor2 which wraps an existing non-member function.
475 * @param _A_func Pointer to function that should be wrapped.
476 * @return Functor that executes @e _A_func on invokation.
480 template <class T_arg1, class T_arg2, class T_return>
481 inline pointer_functor2<T_arg1, T_arg2, T_return>
482 ptr_fun(T_return (*_A_func)(T_arg1, T_arg2))
483 { return pointer_functor2<T_arg1, T_arg2, T_return>(_A_func); }
485 /** Creates a functor of type sigc::pointer_functor3 which wraps an existing non-member function.
486 * @param _A_func Pointer to function that should be wrapped.
487 * @return Functor that executes @e _A_func on invokation.
491 template <class T_arg1, class T_arg2, class T_arg3, class T_return>
492 inline pointer_functor3<T_arg1, T_arg2, T_arg3, T_return>
493 ptr_fun(T_return (*_A_func)(T_arg1, T_arg2, T_arg3))
494 { return pointer_functor3<T_arg1, T_arg2, T_arg3, T_return>(_A_func); }
496 /** Creates a functor of type sigc::pointer_functor4 which wraps an existing non-member function.
497 * @param _A_func Pointer to function that should be wrapped.
498 * @return Functor that executes @e _A_func on invokation.
502 template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_return>
503 inline pointer_functor4<T_arg1, T_arg2, T_arg3, T_arg4, T_return>
504 ptr_fun(T_return (*_A_func)(T_arg1, T_arg2, T_arg3, T_arg4))
505 { return pointer_functor4<T_arg1, T_arg2, T_arg3, T_arg4, T_return>(_A_func); }
507 /** Creates a functor of type sigc::pointer_functor5 which wraps an existing non-member function.
508 * @param _A_func Pointer to function that should be wrapped.
509 * @return Functor that executes @e _A_func on invokation.
513 template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_return>
514 inline pointer_functor5<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_return>
515 ptr_fun(T_return (*_A_func)(T_arg1, T_arg2, T_arg3, T_arg4, T_arg5))
516 { return pointer_functor5<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_return>(_A_func); }
518 /** Creates a functor of type sigc::pointer_functor6 which wraps an existing non-member function.
519 * @param _A_func Pointer to function that should be wrapped.
520 * @return Functor that executes @e _A_func on invokation.
524 template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6, class T_return>
525 inline pointer_functor6<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_return>
526 ptr_fun(T_return (*_A_func)(T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6))
527 { return pointer_functor6<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_return>(_A_func); }
529 /** Creates a functor of type sigc::pointer_functor7 which wraps an existing non-member function.
530 * @param _A_func Pointer to function that should be wrapped.
531 * @return Functor that executes @e _A_func on invokation.
535 template <class T_arg1, class T_arg2, class T_arg3, class T_arg4, class T_arg5, class T_arg6, class T_arg7, class T_return>
536 inline pointer_functor7<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7, T_return>
537 ptr_fun(T_return (*_A_func)(T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7))
538 { return pointer_functor7<T_arg1, T_arg2, T_arg3, T_arg4, T_arg5, T_arg6, T_arg7, T_return>(_A_func); }
541 } /* namespace sigc */
542 #endif /* _SIGC_FUNCTORS_PTR_FUN_H_ */