class inside of template puzzler
 
I've reached a bit of code that I'm failing to understand. The error
generated by g++ 4.* is below each attempt to get the code working.
The simple distilled down version is below:
#include <map>
template<class P1>
struct T
{
    struct T2
     {
         T2() {}
     };
     T()
     {
       std::map<std::string, T2> m;
       std::map<std::string, T2>::iterator itr1 = m.begin();
         //error: expected `;' before 'itr'
       std::map<std::string, T::T2>::iterator itr2 = m.begin();
         //type/value mismatch at argument 2 in template parameter list
for 'template<class _Key, class _Tp, class _Compare, class _Alloc>
class std::map'
         //  expected a type, got 'T<P1>::T2'
         //  template argument 4 is invalid
         //  expected initializer before 'itr2'
       std::map<std::string, T<P1>::T2 >::iterator itr3 = m.begin();
         //Same error as above
       std::map<std::string, T<int>::T2 >::iterator itr4 = m.begin();
         // Compiles, but not really useful
       typename std::map<std::string, T2>::iterator itr5 = m.begin();
         // Works as expected
     }
};
int main() {}
I understand that typename is meant to be used in cases where the
compiler thinks there is an ambiguity and it does not know if you are
referring to a type or a variable. However, I don't understand why it
is is needed in the case above.
Case in point, the declaration of "m" does not need "typename."
Thanks
-Jason
-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]