title: Template argument deduction in partial specialization
body: <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  template &lt;typename T&gt; class A{
  public:
      void test() { cout &lt;&lt; "normal" &lt;&lt; endl;}
  
  };
  
  //template &lt;typename T&gt; class A&lt;T&amp;&gt;{
  //public:
  //    void test() { cout &lt;&lt; "&amp;" &lt;&lt; endl;}
  
  //};
  
  template &lt;typename T&gt; class A&lt;T&amp;&amp;&gt;{
  public:
      void test() { cout &lt;&lt; "&amp;&amp;" &lt;&lt; endl;}
  
  };
  
  int main(){
      A&lt;int&amp;&gt; a;
      a.test();
  }
  </code></pre>
  
  <p>The output is <code>normal</code> suggesting the ordinary (non-specialised) template was chosen. This may be seem obvious straight away since <code>int &amp;</code> is supplied as a template argument and the only available specialisation is one that takes an rvalue reference. But why is it that the second template specialisation cannot be selected by choosing <code>T = int&amp;</code> in which case reference collapsing causes <code>T&amp;&amp;</code> to become <code>int&amp;</code>? </p>