title: sizeof in variadic template c++
body: <p>I need to know how many items in parameter pack of a variadic templete.</p>
  
  <p>my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  
  
  template &lt;int... Entries&gt;
  struct StaticArray
  {
  
    int size  = sizeof... (Entries);// line A
    //int array[size] = {Entries...};// line B
  
  };
  
  
  int main()
  {
     StaticArray&lt;1,2,3,4&gt; sa;
     cout &lt;&lt; sa.size &lt;&lt; endl; 
  
     return 0;
  }
  </code></pre>
  
  <p>I got compilation error on line A.<br>
  if change this line to </p>
  
  <pre><code>static const unsigned short int size = sizeof...(Arguments)
  </code></pre>
  
  <p>It can be compiled. my first question is why I need "static const unsigned short" to get compiled. 
  as you can see, I need a size to put in on my array. my final goal is able to print this array out in main function.</p>
  
  <p>please help. thanks..
  my ideal comes from this website but i dont know how to make it works 
  <a href="http://thenewcpp.wordpress.com/2011/11/23/variadic-templates-part-1-2/" rel="nofollow">http://thenewcpp.wordpress.com/2011/11/23/variadic-templates-part-1-2/</a></p>