RE:Re: Pointer-to-member operator and me

From: Valery Fine (fine@bnl.gov)
Date: Wed Aug 12 1998 - 17:05:51 MEST


On 12 Aug 98 at 20:47, Masaharu Goto wrote:

> 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));
> } 

  I would like to note the pointer alone is not sufficient to 
make call any function. One has to define the formal arguments list 
of that function within the q.User prototype too.  This means 
strictly say we need the family of the GetPointer methods (or special 
"infinite" (template ?) class) for each combination of the possibly 
arguments.

  I mean

   typedef ( *)(int) funcint1;
   typedef ( *)(int,int) funcint2;
   typedef ( *)(float) funcifloat1;

    etc etc etc

   funcint1   GetPointer(funct1);
   funcint2   GetPointer(funct2);
   funcfloat1 GetPointer(funfloat1);

      etc etc etc

  Therefore I would like to understand whether there is a good 
solution on C++ level, then ask CINT to implement this.
(I'd like to call your attention on some platfroms one can make a 
trick returning void * instead of real pointer-to-real-function and 
then cast it to what he/she wants, but this trick is not general 
one and does't work for some compiler/platform combinations ).
Anyway I would like to avoid any "trick" on the CINT level.

                    Valery

=================================================================
Dr. Valeri Faine (Fine)
    -------------------          Phone: +1 516 344 7806
Brookhaven National Laboratory   FAX  : +1 516 344 4206
Bldg. 510A /STAR                 mailto:fine@bnl.gov
Upton, New York, 11973-5000      http://nicewww.cern.ch/~fine
USA
                                 
Dr. Valery Fine                  Telex : 911621 dubna su
    -----------
LCTA/Joint Inst.for Nuclear Res. Phone : +7 09621 6 40 80
141980 Dubna, Moscow region      Fax   : +7 09621 6 51 45
Russia                           mailto:fine@main1.jinr.dubna.su                              



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:36 MET