title: Forward declaration of C++ template
body: <p>I want to add some friend declarations to a class. For example, I want to add some functions of <code>operator==</code> ,<code>operator &lt;</code>. So what I have to do is use the forward declarations:</p>
  
  <pre><code>template &lt;typename &gt;
  class MyBlob;
  
  template &lt;typename T&gt;
  bool operator==(const MyBlob&lt;T&gt; &amp;, const MyBlob&lt;T&gt;&amp;);
  
  template &lt;typename T&gt;
  bool operator!=(const MyBlob&lt;T&gt; &amp;, const MyBlob&lt;T&gt;&amp;);
  
  
  template &lt;typename T&gt;
  bool operator&lt;(const MyBlob&lt;T&gt; &amp;, const MyBlob&lt;T&gt;&amp;);
  
  
  template &lt;typename T&gt;
  class MyBlob
  {
  
      friend bool operator== &lt;T&gt;(const MyBlob&lt;T&gt; &amp;lhs,const MyBlob&lt;T&gt; &amp;rhs);
      friend bool operator!= &lt;T&gt;(const MyBlob&lt;T&gt; &amp;lhs,const MyBlob&lt;T&gt; &amp;rhs);
      friend bool operator&lt; &lt;T&gt;(const MyBlob&lt;T&gt; &amp;lhs,const MyBlob&lt;T&gt; &amp;rhs);
        //other things
  
  };
  </code></pre>
  
  <p>This is annoying that I have to use <code>template &lt;typename T&gt;</code> for three times. And this really reduce the readability.</p>
  
  <p>So, is there any method to make the  forward declaration more simple? Or can I have some method to declare these things in one place just like the ordinary function?<br>
  If this can't be done, Is using <code>typedef</code> to simplify the <code>template &lt;typename T&gt;</code> a good idea?</p>