I am trying to create a interface between user defined function and data. Let's say I need to create a function called MapFun()
, input of MapFun()
includes user defined function (UDF) handle and UDF inputs.
void userFun1(Data data, int in1, int in2){
// user defined function 1;
}
void userFun2(Data data, int in1, int in2, std::string s){
// user defined function 2;
}
// ...
// apply user function 1 on data
MapFun(@userFun1, data, 3, 4);
// apply user function 2 on data
MapFun(@userFun2, data, 1, 2, "algorithm");
User will write userFun
and apply it with MapFun()
. So, how to design MapFun()
? User function may have different inputs and the signature can't be predicted. In addition, MapFun()
won't evaluate userFun
immediately, instead, it stores all userFun
and do a lazy evaluation.
Any suggestions are greatly appreciated.