title: compact switch statement that uses repeatedly same templated function
body: <p>I have the following C++ code with a fairly big switch statement (I am using a C++11 compiler):</p>
  
  <pre><code>void function(std::size_t i, other_args)
  {
     switch(i)
     {
        case 0:
           templatedfunction&lt;0&gt;(other_args);
           break;
        case 1:
           templatedfunction&lt;1&gt;(other_args);
           break;
        case 2:
           templatedfunction&lt;2&gt;(other_args);
           break;
        ...............
        //lots of other cases here
        ...............
        case 100:
           templatedfunction&lt;100&gt;(other_args);
           break;
  
     }  
  
  }
  </code></pre>
  
  <p>where <code>templatedfunction</code> is defined as</p>
  
  <pre><code>template&lt;std::size_t T&gt;
  void templatedfunction(other_args){
     //some code here
  }
  </code></pre>
  
  <p>This is a lot of lines of code for describing a simple concept (i.e., call <code>templatedfunction</code> with the same value as variable <code>i</code> passed in its templated parameter). Is there a way in C++ to write this code more compactly? There should be a way to implement this long switch statement more compactly....Using <code>templatedfunction&lt;i&gt;(other_args)</code> will not compile since <code>i</code> is a variable and not a compile time constant. Thanks.</p>