templates - Question about compile time code generation -
After
i
is something like a zero doSomething (int x) {.. .}} Zero fun () {#ifdef XXXX_1_YYYY doSomeThing (XXXX_1_YYYY); #endif // XXXX_1_YYYY #ifdef XXXX_2_YYYY doSomeThing (XXXX_2_YYYY); #endif // XXXX_2_YYYY #ifdef XXXX_3_YYYY doSomeThing (XXXX_3_YYYY); #endif // XXXX_3_YYYY #ifdef XXXX_4_YYYY doSomeThing (XXXX_4_YYYY); #endif // XXXX_4_YYYY .... until XXXX_20_YYYY}
Is there any way I can reduce this typing up to 20 using some macro extension technology or any other solution?
The macro definition can be something like this
#define XXXX_1_YYYY 10 #define XXXX_2_YYYY 20 #define XXXX_3_YYYY 30 #define XXXX_4_YYYY 40 ... #define XXXX_20_YYYY 200 < / Code>
Each #ifdef
is not mutually exclusive Code is in C ++
A trivial answer is probably, but if they are all mutually exclusive, using #elif will save you a lot of #endifs.
It is difficult to know how to avoid this without knowing about a good way that you are actually trying to do. Are all those functions in the same file, each of which is # around it?
Comments
Post a Comment