For the library, I would like the function to take another function and its arguments, and then save them for calling later. Arguments must allow any type mix, but functions should only return void. Something like that:
void myFunc1(int arg1, float arg2); void myFunc2(const char *arg1); class DelayedCaller { ... public: static DelayedCaller *setup(Function func, …); }; ... DelayedCaller* caller1 = DelayedCaller::setup(&myFunc1, 123, 45.6); DelayedCaller* caller2 = DelayedCaller::setup(&myFunc2, "A string"); caller1->call();
One approach is to force DelayedCaller :: setup () to accept the std :: function, and have my library users use std :: bind () before calling setup (). However, is there a way to implement setup () so that users do not need to bind themselves?
Edit : DelayedCaller is an existing class. setup () is a new static method that I would like to add.
source share