title: Using a class template in a function template with universal reference parameter
body: <p>According to msvc, gcc and clang, the following code is illegal:</p>
  
  <pre><code>template &lt;typename T&gt;
  void f(T&amp;&amp; e) {
      std::vector&lt;T&gt; v;
      // do something with v and e ...
  }
  int main() {
  
      int i;
      f(i);
  }
  </code></pre>
  
  <p>msvc yields </p>
  
  <blockquote>
    <p>xmemory0(591): error C2528: 'pointer': pointer to reference is
    illegal</p>
  </blockquote>
  
  <p>gcc and clang give similar sounding error messages. Note that the universal reference parameter <code>e</code> is not used. The compiler obviously fails to instantiate the vector <code>v</code>, complaining about it being used with a reference to <code>int</code>:</p>
  
  <blockquote>
    <p>note: see reference to class template instantiation
    <code>'std::vector&lt;T,std::allocator&lt;_Ty&gt;&gt;'</code> being compiled
            with</p>
  
  <pre><code>    [
          T=int &amp;,
          _Ty=int &amp;
      ]
  </code></pre>
  </blockquote>
  
  <p>But I can't see where the function template <code>f</code> is instantiated with a reference to <code>int</code>.</p>
  
  <p>Can somebody explain the compiler errors that we see here?</p>