title: When a `key/value` is inserted into a `std::map`, does it make its own copy of the objects?
body: <p>This is inspired by an Item in Effective C# first edition, warning about overriding <code>GetHashCode()</code> naively.</p>
  
  <p>Sorry, I do not have supporting code. By the way, this is not a homework, I am just not that familiar with <code>C++/STL</code>, and could not find information regarding implementation.</p>
  
  <p>Suppose I create my own class named person which has 3 public mutable string fields:</p>
  
  <ul>
  <li>First Name,</li>
  <li>Middle Initial</li>
  <li>Last Name</li>
  </ul>
  
  <p>It also provides a less than operator to compare one person to another based on first name first, then middle name, and then the last name - that is all.</p>
  
  <p>I create a map from person to int (say age), and fill it up with some 20 key/value pairs. I also store pointers to my keys in an array. I then change the first name of an object that say the fifth pointer points to, and try to look up a corresponding age using this modified key (remember the object is mutable and wide open).</p>
  
  <p>Why did this happen?</p>
  
  <p>A) Because the key used by <code>std::map</code> has not changed (was copied), and I changed my own copy and now my key is not found. But how can this be? I have not provided my own copy constructor. Perhaps a default one was created by the compiler?</p>
  
  <p>B) The <code>std::map</code> collection is actually a Red-Black tree, and I happened to have a direct pointer to a key. When I have changed the key, I changed it directly in the node of a tree. Now it is likely that my node is not positioned correctly, and will not be found using a proper tree search algorithm. I should have deleted the node, then modified they key, and then re-inserted it again. If this is the case, then I suspect that <code>STL</code> collections in general are rather dangerous and cause noobs to make many mistakes.</p>
  
  <p>C) Something else?</p>
  
  <p>I would appreciate your insights.</p>