title: What is the purpose of "typename" in C++
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1600936/officially-what-is-typename-for">Officially, what is typename for?</a>  </p>
  </blockquote>
  
  
  
  <p>When I use</p>
  
  <pre><code>template &lt;typename TMap&gt;
  typename TMap::referent_type * func(TMap &amp; map, typename TMap::key_type key) 
  { ... }
  </code></pre>
  
  <p>what is the purpose of the two "typename"'s on the second line?</p>
  
  <p>It seems to trigger a compile-time warning (VS2008: <a href="http://msdn.microsoft.com/en-us/library/tsx7wabs(VS.80).aspx" rel="nofollow noreferrer">C4346</a>) but it's only a "do you claim this to be a type"?</p>
  
  <p>i.e. the actual check if <code>TMap::referent_type</code> is actually type is made when the template gets instantiated, but there still seems to be a requirement by the C++ standard, but the code being parsed correctly regarless.</p>
  
  <p>Are there any examples where the typename is actually required to resolve an ambiguity? Or is there more to that?</p>