title: Turning #ifdef's into a template metaprogram in C++
body: <p>I have the following code inside a C++ class:</p>
  
  <pre><code>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
  };
  </code></pre>
  
  <p>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.</p>
  
  <p>I'm thinking of something like this:</p>
  
  <pre><code>template &lt;bool Feature_A, bool Feature_B, bool Feature_C, bool Feature_D&gt;
  class Features
  {
      ...
  };
  
  Features&lt;true, true, true, false&gt; f;
  </code></pre>
  
  <p>I tried with boost::mpl:vector's but I'm struggling harshly.</p>
  
  <p>BTW: This is not the complete code. The original code has 25 features.</p>
  
  <p>I'm thankful for every idea not involving macros :-)</p>