lundi 27 juillet 2020

How to store and call a variable argument function and a vector of values

In Python, it is possible to store a function pointer with different number of arguments and store the arguments in a list and then unpack the list and call that function like:

def Func(x1, x2):
   return x1+x2
ArgList = [1.2, 3.22]
MyClass.Store(Func)
MyClass.FuncPtr(*ArgList)

Is it possible in c++ to do similar thing? For example, store the function with variable number of inputs and the values in a std::vector and call function pointer by that vector? I don’t want to define argument list as vector.

Aucun commentaire:

Enregistrer un commentaire