title: C++: nested class of a template class
body: <p>Consider the following code:</p>
  
  <pre><code>template &lt; typename T &gt;
  struct A
  {
      struct B { };
  };
  
  template &lt; typename T &gt;
  void f( typename A&lt;T&gt;::B ) { }
  
  int main()
  {
      A&lt;int&gt;::B x;
      f( x );         // fails for gcc-4.1.2
      f&lt;int&gt;( x );    // passes
      return 0;
  }
  </code></pre>
  
  <p>So here gcc-4.1.2 requires the template argument of <code>f</code> to be explicitly specified. Is this meet the standard? Does the newer versions of GCC have this issue fixed? How can I avoid explicitly specifying <code>int</code> while calling <code>f</code>?</p>
  
  <p><strong>Update:</strong>
  Here is a workaround.</p>
  
  <pre><code>#include &lt;boost/static_assert.hpp&gt;
  #include &lt;boost/type_traits/is_same.hpp&gt;
  
  template &lt; typename T &gt;
  struct A
  {
      typedef T argument;
      struct B { typedef A outer; };
  };
  
  template &lt; typename T &gt;
  void f( typename A&lt;T&gt;::B ) { }
  
  template &lt; typename Nested &gt;
  void g( Nested )
  {   
      typedef typename Nested::outer::argument TT;
      BOOST_STATIC_ASSERT( (boost::is_same&lt; typename A&lt;TT&gt;::B, Nested &gt;::value) );
  }
  
  struct NN 
  {
      typedef NN outer;
      typedef NN argument;
  };
  
  int main()
  {
      A&lt;int&gt;::B x;
      NN y;
      g( x );  // Passes
      g( y );  // Fails as it should, note that this will pass if we remove the type check
      f( x );  // Fails as before
  
      return 0;
  }
  </code></pre>
  
  <p>However, I still can't see why call <code>f( x );</code> is invalid. Can you refer to some point in the standard which says such call should be invalid? Can you bring an example where such call is ambiguous?</p>