Forward Declaration of Template Function
<p>I have a template class with a friend template function. I currently have the following code and it is working:</p>

<pre><code>template&lt;class T&gt;
class Vector
{
  public:
    template&lt;class U, class W&gt;
    friend Vector&lt;U&gt; operator*(const W lhs, const Vector&lt;U&gt;&amp; rhs);
}

template&lt;class U, class W&gt;
Vector&lt;U&gt; operator*(const W lhs, const Vector&lt;U&gt;&amp; rhs)
{
  // Multiplication
}
</code></pre>

<p>I would prefer for my solution to have forward declaration of the friend function so that I can have the security benefits and one-to-one correspondence that it provides compared to my current method.  I tried the following but keep running into errors.</p>

<pre><code>template&lt;class T&gt;
class Vector;

template&lt;class T, class W&gt;
Vector&lt;T&gt; operator*(const W lhs, const Vector&lt;T&gt;&amp; rhs);

template&lt;class T&gt;
class Vector
{
  public:
    friend Vector&lt;T&gt; (::operator*&lt;&gt;)(const W lhs, const Vector&lt;T&gt;&amp; rhs);
}

template&lt;class T, class W&gt;
Vector&lt;T&gt; operator*(const W lhs, const Vector&lt;T&gt;&amp; rhs)
{
  // Multiplication
}
</code></pre>
