title: Why can't I declare a type of friend function by template parameter but can with alias
body: <p>Consider the code:</p>
  
  <pre><code>template &lt;class T&gt;
  class Bar {
      int foobar;
      using X = T();
      friend X foo;
  };
  
  void foo() {
      Bar&lt;void&gt; bar;
      bar.foobar = 1;
      static_cast&lt;void&gt;(bar);
  }
  
  int main() {}
  </code></pre>
  
  <p>Compiles fine in both <a href="https://wandbox.org/permlink/qDdOcircf2OSQnTf" rel="nofollow noreferrer">gcc</a> and <a href="https://wandbox.org/permlink/mVOoSNN8cHxrDYFc" rel="nofollow noreferrer">clang</a>. But seemingly equivalent code:</p>
  
  <pre><code>template &lt;class T&gt;
  class Bar {
      int foobar;
      friend T foo;
  };
  
  void foo() {
      Bar&lt;void()&gt; bar;
      bar.foobar = 1;
      static_cast&lt;void&gt;(bar);
  }
  
  int main() {}
  </code></pre>
  
  <p>causes error in both <a href="https://wandbox.org/permlink/WI1EAhztaQFFlbIo" rel="nofollow noreferrer">gcc</a> and <a href="https://wandbox.org/permlink/SKpKfTMc5zRKqOSg" rel="nofollow noreferrer">clang</a>. How come the template parameter doesn't work here equivalently to alias?</p>