title: Easiest way to get the N-th argument of a variadic templated class?
body: <p>I wonder what is the easiest and more common way to get the N-th parameter of a variadic templated class <strong>at compile-time</strong> (The returned value has to be as a static const for the compiler in order to do some optimizations). Here is the form of my templated class :</p>
  
  <pre><code>template&lt;unsigned int... T&gt; MyClass
  {
      // Compile-time function to get the N-th value of the variadic template ?
  };
  </code></pre>
  
  <p>Thank you very much.</p>
  
  <p>EDIT : As MyClass will contain more than 200 functions, I can't specialize it. But I can specialize a struct or a function inside MyClass.</p>
  
  <p>EDIT : Final solution derived from the validated answer :</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template&lt;unsigned int... TN&gt; class MyClass
  {
      // Helper
      template&lt;unsigned int index, unsigned int... remPack&gt; struct getVal;
      template&lt;unsigned int index, unsigned int In, unsigned int... remPack&gt; struct getVal&lt;index, In,remPack...&gt;
      {
          static const unsigned int val = getVal&lt;index-1, remPack...&gt;::val;
      };
      template&lt;unsigned int In, unsigned int...remPack&gt; struct getVal&lt;1,In,remPack...&gt;
      {
          static const unsigned int val = In;
      };
  
      // Compile-time validation test
      public:
          template&lt;unsigned int T&gt; inline void f() {std::cout&lt;&lt;"Hello, my value is "&lt;&lt;T&lt;&lt;std::endl;}
          inline void ftest() {f&lt;getVal&lt;4,TN...&gt;::val&gt;();} // &lt;- If this compile, all is OK at compile-time
  };
  int main()
  {
      MyClass&lt;10, 11, 12, 13, 14&gt; x;
      x.ftest();
      return 0;
  }
  </code></pre>