I believe there are several ways to solve the task.
If you know that all functions have the same signature, you can use function pointer (or member function pointer) and array of potential arguments. Then you iterate over array of potential arguments and pass them to the function pointer. For instance:
void exec(void (*fun)(const std::string&), const std::vector<std::string>& args)
{
for (auto& v: args) { fun(v); }
}
You can achieve the same result (indeed, even better result due to function pointer optimization) by using template function (or functor), which accepts function and arguments list. This way you can adopt arbitrary functions to the same piece of code; moreover, you can adopt functions that accept more than one argument by using std::bind. For instance:
template <typename Fun, typename ArgsContainer>
void exec(Fun fun, const ArgsContainer& args)
{
for (auto& v: args) { fun(v); }
}
Actually, this is already done by for_each algorithm:
for_each(args.begin(), args.end(), &func);
Last but not least, you can use macros. Sometimes using macro+include to iterate over something is acceptable technique. For instance:
void exec(void (*fun)(const std::string&))
{
#define RUN(arg) fun((arg))
#include "run_cases.h"
#undef RUN
}
where run_cases.h looks like:
RUN("test1");
RUN(2.0f);
RUN(anything_that_is_acceptable_as_any_function_overload);
And no, you cannot pass just the name of the struct assuming compiler will substitute it with it's members. You have to explicitly type them in; actually, you don't want every struct member to be used, implicit ones are a good candidate for exclusion.