Pointer to function

Dear ROOTers,
Is there any way to create pointer to function inside ROOT class and safely past this into Streamer. I Created function like this:

typedef void (MyCLass::*build_pair_t)(PairTrack *); build_pair_t fFunction;
On single machine everything is ok I get dictionary and so one, however in PROOF I get error:

Error in <TClass::New>: cannot create object of class MyClass Error in <TStreamerInfo::Build>: MyClass, unknown type: G__p2memfunc fFunction
I add this function to my LinkDef.h but it didn’t help, however it’s used into code so I can’t avoid streaming this pointer.


the direct serialisation of function pointers is not possible: this would be equivalent to the serialisation of code rather than data.
If this function is of interest for a certain object, why not adding it as a method of the class?


This function is method of the class, its do something like this:

do something(Pair *pair){ call_proper_function(pair) }
There are many “call_proper_function” - so I would like to avoid switch statement, on the other hand I don’t want to create a lot of daughter-classes for overwrite only one function

a general remark: this kind of procedures is not recommended as the double indirection has a huge cost in terms of performance.
Although very less than optimal, if really your design does not allow anything different, you could lazily initialise the pointer according to some parameter saved as a data member.