title: default template class argument confuses g++?
body: <p>Yesterday I ran into a g++ (3.4.6) compiler problem for code that I have been compiling without a problem using the Intel (9.0) compiler. Here's a code snippet that shows what happened:</p>
  
  <pre><code>template&lt;typename A, typename B&gt;
  class Foo { };
  
  struct Bar {
     void method ( Foo&lt;int,int&gt; const&amp; stuff = Foo&lt;int,int&gt;() );
  };
  </code></pre>
  
  <p>The g++ compiler error is:</p>
  
  <pre><code>foo.cpp:5: error: expected `,' or `...' before '&gt;' token
  foo.cpp:5: error: wrong number of template arguments (1, should be 2)
  foo.cpp:2: error: provided for `template&lt;class A, class B&gt; struct Foo'
  foo.cpp:5: error: default argument missing for parameter 2 of `void Bar::method(const Foo&lt;int, int&gt;&amp;, int)'
  </code></pre>
  
  <p>Apparently, the default argument is not accepted when written this way, and the compiler assumes that instead of the second template argument a new function argument is specified, for which it then expects a default value because the <code>stuff</code> argument has one. I can help the compiler by creating a typedef, and then everything compiles fine: </p>
  
  <pre><code>template&lt;typename A, typename B&gt;
  class Foo { };
  
  struct Bar {
     typedef Foo&lt;int,int&gt; FooType;
     void method ( FooType const&amp; stuff = FooType() );
  };
  </code></pre>
  
  <p>So I can solve my problem, but I don't understand what is going on. Do I miss a C++ (template?) language feature here and am I doing something wrong, or is the g++ compiler wrong in not accepting the first piece of code? </p>
  
  <p>Note BTW that this also compiles ...</p>
  
  <pre><code>template&lt;typename A, typename B&gt;
  class Foo { };
  
  void method ( Foo&lt;int,int&gt; const&amp; stuff = Foo&lt;int,int&gt;() );
  </code></pre>