First, I must apologize long silence about this issue. Yes, I do remember
one time we discussed about pointer to function issue. It foces user to
deal with messy code now. I thought I had a good idea, but turned out it
really wasn't so simple. And I forgot it for long time.
I want to make things clear that issue of pointer to function and
pointer to member are different. To be more precise, pointer to function
issue is common for both, and pointer to member has further and deeper issue.
Maybe I need to revisit this issue.
I could not think of a generic solution, so far. What really bothers me is
argument list. If you have fixed argument list for the functions you want to
use through pointer, things can be easier. For example, if your functions
(which you want to use through pointer) take only (float x) as an argument
solution can be easier. Is this the case? Or do you have variety of argument
lists different from function to function.
Masaharu Goto
--------------------------------------------------------------------
Hi Masa,
As you might remember we discussed this item already a long time ago
(when I needed it to get random numbers according to a user defined
function in which I needed to pass the pointer to that interpreted
user function to a pre-compiled member function).
The I suggested the idea of a ROOT/CINT facility of the sort of
// The user function in the interpreted code
float func(float x)
{
return (x*x-2*x+25);
}
// The main program
void test()
{
Random q;
float a=6;
float b=9;
int nbins=100;
// Provide a random number in <a,b> according to function func
// using nbins between a and b
q.User(a,b,nbins,GetPointer(func));
}
where I defined Random::User(float a,float b, int n, float (*f)(float))
so the trick is the GetPointer() facility that contains all the
platform/compiler
dependence, but from the user point of view the functionality is
platform independent.
That time you told me you got an idea how to do it.
Has anything come out of this ?
Maybe my idea is wrong, but something similar should
be possible I would say.
--Cheers,
_/_/ _/ _/ _/_/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/_/_/_/ _/ _/