title: How to pass array to function template with reference
body: <p>I am learning c++ template concepts.  I do not understand the following.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;typeinfo&gt;
  
  using namespace std;
  
  template &lt;typename T&gt;
  T fun(T&amp; x)
  {
   cout &lt;&lt;" X is "&lt;&lt;x;
   cout &lt;&lt;"Type id is "&lt;&lt;typeid(x).name()&lt;&lt;endl;
  }
  
  
  int main ( int argc, char ** argv)
  {
     int a[100];
     fun (a);
  }
  </code></pre>
  
  <p>What i am trying?</p>
  
  <p>1)    T fun (T &amp; x)</p>
  
  <p>Here x is a reference, and hence will not decayed 'a' into pointer type,
   but while compiling , i am getting the following error. </p>
  
  <pre><code> error: no matching function for call to ‘fun(int [100])’
  </code></pre>
  
  <p>When I try non-reference, it works fine. As I understand it the array is decayed into pointer type. </p>