I'd like to write a sort-of wrapper function for my class... And i really dont know how to do that!
See, i want a, say, run(), function, to accept a function as an argument, thats the easy part.
The usage would be something like
void f() { }
void run(int (*func)) {
//whatever code
func();
//whatever code
}
run(f);
That should just run the f() function, right?
But what if f() had required arguments? Say it was declared as f(int i, int j), i would go along rewriting the run() function to separately accept those ints, and pass them to the f() function.
But I'd like to be able to pass Any function to run(), no matter how many arguments, or what type they are. Meaning, in the end, i'd like to get usage similar to what i would expect the hypothetical
void f() {int i, int j}
void v() {char* a, int size, int position}
void run(int (*func)) {
//whatever code
func();
//whatever code
}
run(f(1, 2));
run(v(array, 1, 2));
to do. I know it looks dumb, but i think i'm getting my point across.
How would i do that?
Please remember that this is arduino-c++, so it might lack some stuff, but i do believe there are libraries that could make up for that...