title: Why do I need to use typedef typename in g++ but not VS?
body: <p>It had been a while since GCC caught me with this one, but it just happened today. But I've never understood why GCC requires typedef typename within templates, while VS and I guess ICC don't. Is the typedef typename thing a "bug" or an overstrict standard, or something that is left up to the compiler writers?</p>
  
  <p>For those who don't know what I mean here is a sample:</p>
  
  <pre><code>template&lt;typename KEY, typename VALUE&gt;
  bool find(const std::map&lt;KEY,VALUE&gt;&amp; container, const KEY&amp; key)
  {
      std::map&lt;KEY,VALUE&gt;::const_iterator iter = container.find(key);
      return iter!=container.end();
  }
  </code></pre>
  
  <p>The above code compiles in VS (and probably in ICC), but fails in GCC because it wants it like this:</p>
  
  <pre><code>template&lt;typename KEY, typename VALUE&gt;
  bool find(const std::map&lt;KEY,VALUE&gt;&amp; container, const KEY&amp; key)
  {
      typedef typename std::map&lt;KEY,VALUE&gt;::const_iterator iterator; //typedef typename
      iterator iter = container.find(key);
      return iter!=container.end();
  }
  </code></pre>
  
  <p>Note: This is not an actual function I'm using, but just something silly that demonstrates the problem.</p>