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
//#define Feature_Size_D 14725
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 out features, like line 4, to compile and run different tests. But now I'd like to have the class as a template, so I can instantiate several versions with different features turned on or off in the same program.
I'm 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's but I'm struggling harshly.
BTW: This is not the complete code. The original code has 25 features.
I'm thankful for every idea not involving macros :-)
Features
class? Should they be accessible with a specific name, or is an indexed access acceptable? Are they all float arrays?