title: C++ array size inferring from integer template
body: <p>I came across the template version <code>_snwprintf_s</code></p>
  
  <p>from <a href="https://msdn.microsoft.com/en-us/library/f30dzcf6.aspx" rel="nofollow noreferrer">MSDN</a>:</p>
  
  <pre><code>template &lt;size_t size&gt;
  int _snwprintf_s(
     wchar_t (&amp;buffer)[size],
     size_t count,
     const wchar_t *format [,
     argument] ... 
  ); // C++ only
  </code></pre>
  
  <p>I understand how to use it, and I'm familiar with c++ templates and the possibility to use templates with an integer.</p>
  
  <p>What is the type of <code>wchar_t (&amp;buffer)[size]</code>? Is it a reference to a wchar_t, if so then what the [size] mean? what is this called?</p>
  
  <p>I'm guessing the compiler infers the size somehow but this is the first time I've come across such syntax and would appreciate an explanation as I haven't found anything on it by myself (probably since I don't know what to search for).</p>
  
  <p>Also, If you can explain how this works behind the scene, that'd be great.</p>
  
  <p>EDIT:</p>
  
  <p>I'm more interested at how this works compiler-wise, less about the type that is passed, which is as mentioned explained <a href="https://stackoverflow.com/questions/5724171/passing-an-array-by-reference">here</a></p>
  
  <p>Thanks </p>