Can a derived type be the same name as a nested type of its base?
<p>Is the following code legal?  MSVC 9 and g++ 4.4 disagree:</p>

<pre><code>struct base
{
  struct derived {};
};

struct derived : base {};

int main()
{
  typedef derived::derived type;
  return 0;
}
</code></pre>

<p>MSVC complains, confusing the nested name for the type's constructor:</p>

<pre><code>c:\dev&gt;cl test.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp
test.cpp(10) : error C2146: syntax error : missing ';' before identifier 'type'
test.cpp(10) : error C2761: '{ctor}' : member function redeclaration not allowed

test.cpp(10) : error C2065: 'type' : undeclared identifier
</code></pre>

<p>While g++ does not:</p>

<pre><code>$ g++ --version test.cpp
g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
</code></pre>

<p>For context, my code contains an iterator called <code>pointer</code>. To provide the iterator interface, it provides the nested type <code>pointer</code>, which is a synonym for itself.</p>
