title: Having trouble with template classes having template member functions
body: <p>In my experimentation with templates I've come across a confusing predicament. I'm defining a templated struct <code>F</code> who default argument is <code>int</code>. It has a templated member function <code>g</code>. I'm defining it below the struct definition. I figured this was the correct way to go about it, however, I receive an error. And only one error:</p>
  
  <blockquote>
    <p>prog.cpp:9:62: error: default argument for template parameter for class enclosing 'void F&lt;  >::g()'</p>
  </blockquote>
  
  <pre><code>template &lt;typename = int&gt; struct F {
  
      template &lt;typename&gt; void g();
  
  };
  
  template &lt;typename T = int&gt; template &lt;typename&gt; void F&lt;T&gt;::g() {}
  
  int main() {
  
      F&lt;&gt;f;
  
  }
  </code></pre>
  
  <p>It's quite vague. I couldn't exactly understand what it means. So I tried changing some things around. I figured it was the default template arguments for the definition of <code>F</code>. So I changed:</p>
  
  <pre><code>template &lt;typename = int&gt; struct F {
  </code></pre>
  
  <p>to</p>
  
  <pre><code>template &lt;typename T = int&gt; struct F {
  </code></pre>
  
  <p>I also tried giving <code>g</code> template arguments:</p>
  
  <pre><code>template &lt;typename T = int&gt; template &lt;typename U&gt; void F&lt;T&gt;::g&lt;U&gt;() {}
  </code></pre>
  
  <p>But then I received the errors:</p>
  
  <blockquote>
    <p>prog.cpp:9:67: error: function template partial specialization 'g' is not allowed<br>
    prog.cpp:9:67: error: default argument for template parameter for class enclosing 'void F::g()'</p>
  </blockquote>
  
  <p>I even tried specifying that <code>g</code> was a template function:</p>
  
  <pre><code>template &lt;typename T = int&gt; template &lt;typename U&gt; void F&lt;T&gt;::template g&lt;U&gt;() {}
  </code></pre>
  
  <p>But it didn't help. What am I doing wrong?</p>