I need to store a templated function in a function pointer, how
can I do this?
e.g.,
void function(double) myfuncptr;
void myfunc(double d) { }
myfuncptr = myfunc;
Now I would like to use a template parameter instead of double.
In C++ one can do this by using boosts binding's and function
types.
For example, I want something like this
void function(F)(F) funcptr;
void Bind(T)(void function(T)(T) v)
{
funcptr = v; // F is sort of deduced automatically as being
T. Obviously problematic but effectively what I want to do.
}
This way I can bind to any function that takes a single type
parameter and returns a void.
void function(F) myfuncptr; // F is undefined
void myfunc(T)(T d) { } //
myfuncptr = myfunc;
To do this using boost I would simply bind the parameter so
myfuncptr would not depend on an arbitrary type.
I need a rather performant way to do this too.