title: Modify key of std::map
body: <p>Is there a way to modify the key of a <code>std::map</code> or ? <a href="https://stackoverflow.com/questions/5743545/what-is-the-fastest-way-to-change-a-key-of-an-element-inside-stdmap">This example</a> shows how to do so with rebalancing the tree. But what if I provide some guarantees that the key won't need to be rebalanced?</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;iostream&gt;
  #include &lt;map&gt;
  
  
  class Keymap
  {
  private:    
      int key; // this key will be used for the indexing
      int total;
  public:
      Keymap(int key): key(key), total(0)
      {}
      bool operator&lt;(const Keymap&amp; rhs) const{
          return key &lt; rhs.key;
      }
      void inc()
      {
          total++;
      }
  };
  std::map&lt;Keymap, int&gt; my_index;
  
  
  
  int main (){
      std::map&lt;Keymap, int&gt; my_index;
      Keymap k(2);
      my_index.insert(std::make_pair(k, 0));
  
      auto it = my_index.begin();
  
      it-&gt;first.inc(); // this won't rebalance the tree from my understanding
      return 0;
  }
  </code></pre>
  
  <p>The modification won't compile because of the constness of <code>it-&gt;first</code></p>
  
  <p>Is there any way to override this behavior?</p>