title: Same key, multiple entries for std::unordered_map?
body: <p>I have a map inserting multiple values with the same key of <code>C string</code> type.</p>
  
  <p>I would expect to have a single entry with the specified key.</p>
  
  <p>However the map seems to take it's address into consideration when uniquely identifying a key.</p>
  
  <pre><code>#include &lt;cassert&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;unordered_map&gt;
  
  typedef char const* const MyKey;
  
  /// @brief Hash function for StatementMap keys
  ///
  /// Delegates to std::hash&lt;std::string&gt;.
  struct MyMapHash {
  public:
      size_t operator()(MyKey&amp; key) const {
          return std::hash&lt;std::string&gt;{}(std::string(key));
      }
  };
  
  typedef std::unordered_map&lt;MyKey, int, MyMapHash&gt; MyMap;
  
  int main()
  {
      // Build std::strings to prevent optimizations on the addresses of
      // underlying C strings.
      std::string key1_s = "same";
      std::string key2_s = "same";
      MyKey key1 = key1_s.c_str();
      MyKey key2 = key2_s.c_str();
  
      // Make sure addresses are different.
      assert(key1 != key2);
  
      // Make sure hashes are identical.
      assert(MyMapHash{}(key1) == MyMapHash{}(key2));
  
      // Insert two values with the same key.
      MyMap map;
      map.insert({key1, 1});
      map.insert({key2, 2});
  
      // Make sure we find them in the map.
      auto it1 = map.find(key1);
      auto it2 = map.find(key2);
      assert(it1 != map.end());
      assert(it2 != map.end());
  
      // Get values.
      int value1 = it1-&gt;second;
      int value2 = it2-&gt;second;
  
      // The first one of any of these asserts fails. Why is there not only one
      // entry in the map?
      assert(value1 == value2);
      assert(map.size() == 1u);
  }
  </code></pre>
  
  <p>A print in the debugger shows that map contains two elements just after inserting them.</p>
  
  <pre><code>(gdb) p map
  $4 = std::unordered_map with 2 elements = {
    [0x7fffffffda20 "same"] = 2,
    [0x7fffffffda00 "same"] = 1
  }
  </code></pre>
  
  <p>Why does this happen if the hash function which delegates to <code>std::hash&lt;std::string&gt;</code> only takes it's value into account (this is asserted in the code)?</p>
  
  <p>Moreover, if this is the intended behaviour, how can I use a map with C string as key, but with a 1:1 key-value mapping?</p>