title: hash_map is saving each key/val pair even when keys are equal
body: <p>Hey guys, I am using a hash_map to relate strings to one another, with this code:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;hash_map&gt;
  
  using namespace std;
  using namespace stdext;
  
  struct StrCompare : public stdext::hash_compare&lt;string&gt; {
   unsigned int operator()(const string str) const {
    unsigned int hash = 0;
    unsigned int len = str.length();
  
    for (unsigned int i = 0; i &lt; len; i++)
     hash = 31 * hash + str[i];
  
    return hash;
   }
  
   bool operator()(const string str1, const string str2) const {
    return str1 == str2;
   }
  };
  
  int main() {
   hash_map&lt;string, string, StrCompare&gt; m;
  
   m["asdf"] = "fe";
   m["asdf"] = "asdf";
  
   for (hash_map&lt;string, string, StrCompare&gt;::iterator i = m.begin(); i != m.end(); ++i)
    cout &lt;&lt; i-&gt;first &lt;&lt; " " &lt;&lt; i-&gt;second &lt;&lt; endl;
  
   system("PAUSE");
  }
  </code></pre>
  
  <p>The problem is that the output is:</p>
  
  <pre><code>asdf asdf
  asdf fe
  Press any key to continue . . .
  </code></pre>
  
  <p>Why is this happening? I have tried printing the hashes each time, but the hash is the same.</p>