I want to generate an array of function pointers using a variadic macro. Here's an example.
Before preprocessing:
#define MY_MACRO(mClassName, ...) ???
struct test {
void a() { }
void b() { }
void c() { }
};
MY_MACRO(test, a, b, c);
After preprocessing:
struct test {
void a() { }
void b() { }
void c() { }
};
void(test::*)() getMemFnPtr(int mIdx) {
static void(test::*)() fnPtrs[]{
&test::a,
&test::b,
&test::c
};
return fnPtrs[mIdx];
}
Is this possible?
Basically, I need to have something before the array expansion, something after the array expansion, and add a prefix to every expanded variadic macro argument.