title: fail to insert new elements to set when I add customized comparator
body: <p>Here is my original code. I have two functions, add and print_out. "add" is used to update the times of a url by incrementing one every time when a user use that. And print_out just print all of urls that have bee used in order of times.</p>
  
  <hr>
  
  <pre><code># include&lt;iostream&gt;
  # include&lt;unordered_map&gt;
  # include&lt;set&gt;
  # include&lt;string&gt;
  # include&lt;utility&gt;
  
  using namespace std;
  
  struct compare { // simple comparison function
     public:
        bool operator()(const pair&lt;string, int&gt;&amp; x, const pair&lt;string, int&gt; &amp;y) const
        { return x.second &gt; y.second; } // returns x&gt;y
  };
  
  
  class Sol{
  
      set&lt; pair&lt;string, int&gt;, compare  &gt; db;
  // the unordered_map is used to store the iterator of a url in my set, db, so that I can pull the pair of this url later, and update it.
      unordered_map&lt; string, set&lt; pair&lt;string, int&gt; &gt;:: iterator &gt; table;
  
  
  public:
  
      Sol(){};
      void add( string url); 
      void print_out();
  };
  
  void Sol :: add( string url){
  
      //  when a url is used, the times of it increments by it. If this url is used for the first time, then just insert new pair { url, 1 } into my set.
  
      if( table.find( url ) != table.end() ){
  
          int times = (*table[url]).second +1;
          db.erase( table[url] );
          db.insert( { url, times} );
          table[url] = db.find( { url, times} );
      }
      else{   
          pair&lt;string, int&gt; p = { url, 1};
          db.insert( p );
  
      }
  
      return;
  
  }
  
  void Sol :: print_out(){
  
  // print out all of urls in order of times they have been used so far
  
      for( auto ite = db.begin() ; ite != db.end() ; ite++  )
          cout&lt;&lt; (*ite).first &lt;&lt; "  " &lt;&lt; (*ite).second&lt;&lt;"\n";
  
      return;
  }
  </code></pre>