If you cannot find std::function
in std::tr1::function
or via std::function
or via a compiler upgrade...
Write your own std::function
-like type eraser, or use boost
, or use 'the fastest possible delegates' (that should google to a complete implememtation), or pass both a this
pointer and a method pointer as template
-type-deduced arguments to a function, or pass a template
-type-deduced copy of the function object to the function.
Note that the last two options require the function's body to be exposed (such as in a header file).
Or convert the function object into a void*
style C callback.
I would go with C++11, and failing that boost
, and failing that fast delegates, failing that write a type eraser myself, failing that stick body in header and template+pass a copy (unless function is simple, in which case do this first), and failing that pvoid C style.