I have multiple functions with different numbers of parameters, e.g.
double foo(double x, double y) { return x + y; }
double bar(double x, double y, double z) { return x + y + z; }
double zoo(double x, double y) { return x * y; }
I'd like to call the functions by their names using some catchall function in the following manner:
call_function("foo", x, y);
call_function("bar", x, y, z);
It can be assumed that both parameters and function return have the same type (e.g. double as in the above example). Unfortunately due to complex nature of the project I cannot change the functions I call and I need to deal with them as-is.
Is there any simple solution for this?
std::anyand amap<std::string, std::function>