I have the following code inside a C ++ class:
class Features
{
#define Feature_Size_A 12345
#define Feature_Size_B 45678
#define Feature_Size_C 78901
const int Feature_Sum = 0
#ifdef Feature_Size_A
+ Feature_Size_A
#endif
#ifdef Feature_Size_B
+ Feature_Size_B
#endif
#ifdef Feature_Size_C
+ Feature_Size_C
#endif
#ifdef Feature_Size_D
+ Feature_Size_D
#endif
;
#ifdef Feature_Size_A
static float Feature_A[Feature_Size_A];
#endif
#ifdef Feature_Size_B
static float Feature_B[Feature_Size_B];
#endif
#ifdef Feature_Size_C
static float Feature_C[Feature_Size_C];
#endif
#ifdef Feature_Size_D
static float Feature_D[Feature_Size_D];
#endif
};
I used to comment on functions like line 4 to compile and run various tests. But now I would like to have a class as a template, so I can create several versions with various functions turned on or off in the same program.
I am thinking of something like this:
template <bool Feature_A, bool Feature_B, bool Feature_C, bool Feature_D>
class Features
{
...
};
Features<true, true, true, false> f;
I tried with boost :: mpl: vector, but I'm struggling a lot.
BTW: This is not a complete code. The source code has 25 functions.
I am grateful for any idea not related to macros :-)
source
share