title: About the return type of an unbound template friend function of a template class
body: <p>Suppose I have a template class which has a template friend function hoping to implement the function of a value multiplying an array(myArray):</p>
  
  <pre><code>template&lt;typename T, int size&gt;
  class myArray{
    T *_array;
  public:
    ...
    template&lt;typename Val, typename Array&gt; 
    friend myArray&lt;T,size&gt; operator*(const Val &amp;lhs, const Array &amp;rhs){
      myArray&lt;T,size&gt; mat_t;
      for(int i = 0;i &lt; size; i++)
        mat_t._array[i] = lhs * rhs._array[i];
      return mat_t;
  }
    ...
  };
  </code></pre>
  
  <p>It works on VS2013. Then I move the definition of the unbound template friend function outside:</p>
  
  <pre><code>template&lt;typename Val, typename Array&gt;
  myArray&lt;T,size&gt; operator*(const Val &amp;lhs, const Array &amp;rhs){
    myArray&lt;T,size&gt; mat_t;
    for(int i = 0;i &lt; size; i++)
      mat_t._array[i] = lhs * rhs._array[i];
    return mat_t;
  }
  </code></pre>
  
  <p>It is incorrect! I suppose the problem is with the return type of the friend function. But I can't not figure it out.
  So how to define a friend template function like this outside the class declaration?</p>