C++ std::unordered_map
<p>I am am using <code>std::unordered_map</code> and I would like to use it to store pointers to an object that I dynamically create with <code>new</code>.</p>

<p>I can create the objects fine and the insert method succeeds; however when I attempt to resolve a specific object from the map using the index it appears that all of the items in the list are mapped to the last item I point in the map.</p>

<pre><code>typedef std::unordered_map&lt;__int64, Session*&gt; HashDict;
HashDict dict;

void Sessions::Insert()
{
  Session* newSession = new Session;
  newSession-&gt;setId(sessionCounter++);
  dict.insert(HashDict::value_type(newSession-&gt;Id(), newSession));
}

void Sessions::Find(__int64 id)
{
  HashDict::iterator it = dict.find(id);

  if(it != dict.end())
  {
    Session* s = it-&gt;second;
    std::cout &lt;&lt; "Search for: " &lt;&lt; id &lt;&lt; std::setw(3) &lt;&lt; 
                 " found @ location: "  &lt;&lt; it-&gt;second &lt;&lt; std::setw(3) &lt;&lt; 
                 " with value: " &lt;&lt;  s-&gt;Id() &lt;&lt; std::endl;
  }
}

001D4F50    0
001D5038    1
001D50D0    2
001D5378    3
001D5410    4
001D54A8    5
001D5540    6
001D55D8    7
001D5670    8
001D4E50    9
Search for: 5 found @ location: 001D54A8 with value: 9
</code></pre>

<p>Notice that <code>5</code> points to the location at <code>5</code> (from the insert), however it says that the value is <code>9</code>.</p>

<p>What am I doing wrong?</p>
