title: C++ unordered_set of pointers allows modifying elements
body: <p>My apologies if this has been answered. I did search specifically for this issue, and could not find the answer.</p>
  
  <p>unordered_set contains pointers to a user-defined type, one of whose memebers is a variable count.</p>
  
  <p>Now, when I try to insert a new object -- specifically a pointer to the object, I check if it's already present. If it is, I just increment the count for that object.</p>
  
  <p><strong>Question:</strong> How does C++ allow me to modify the object, which is the key of my unordered_set? </p>
  
  <pre><code>auto iter =  mySet.find(w);
  if(iter == mySet.end()) {
       mySet.insert(w);
  } 
  else { /* found the element. Increment the count. */
      (*iter) -&gt; count += 1;
  }
  </code></pre>
  
  <p>The above code works just fine and as expected. After the first time, any subsequent attempt to insert the object results in the count getting incremented.</p>
  
  <p>The documentation says that any iterator for the unordered_set is constant "even if not preceded by const_". Could someone kindly explain what I am missing. </p>
  
  <p><strong>Additional Info:</strong> I do have the relevant hash and comparison functors defined, which are passed to the unordered_set as template args.</p>
  
  <p>Best,</p>