title: How to make the C++ precompiler do a "loop"
body: <p>I want to simplify the following code:</p>
  
  <pre><code>switch (index)
      {
      case 1:
          output = function1();
          break;
      case 2:
          output = function2();
          break;
      case 3:
          output = function3();
          break;
      ....
  </code></pre>
  
  <p>Where <code>index</code> is a compile time constant. </p>
  
  <p>If I would use a precompiler macro, I would need to use it <code>n</code> times, where <code>n</code> is the number of cases. How can I reduce the above mentioned code to O(1) lines of code?</p>