title: C++ std::map compare method
body: <p>I ran into error with the following code</p>
  
  <pre><code>struct MapKey {
      std::string x;
      std::string y;
  }
  
  std::map&lt;MapKey, int&gt; m;
  
  if (m.find(key) != m.end()) {
      ......
  }
  </code></pre>
  
  <p>I receive an error says,</p>
  
  <pre><code>no match for "operator&lt;" in '__x &lt; __y'
  </code></pre>
  
  <p>I believe the problem is that MapKey needs to have a compare method, I am wondering how can I implement one for Mapkey. For example,</p>
  
  <pre><code>struct MapKey {
      bool operator&lt;(const MapKey &amp;key) const {
          ... what shall I put here? ...
      }
      std::string x;
      std::string y;
  }
  </code></pre>
  
  <p>Thanks.</p>