title: how to compare structs
body: <p>I am having difficulties to set up the comparison correctly.
  Here is an example of my problem, where my code wrongly assumes {1,2}={2,1}: <a href="http://ideone.com/i7huL" rel="noreferrer">http://ideone.com/i7huL</a></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;map&gt;
  using namespace std;
  
  struct myStruct {
    int a;
    int b;
    bool operator&lt;(const myStruct&amp; rhs) const {
             return rhs.a &lt; this-&gt;a &amp;&amp; rhs.b &lt; this-&gt;b;
    }
  };
  
  
  int main() {
         std::map  &lt;myStruct, int&gt; mymap ;
         myStruct m1={1,2};
         myStruct m2={2,1};
         mymap.insert(make_pair(m1,3));
         std::map&lt;myStruct, int&gt;::iterator it1 = mymap.find(m1);
         std::map&lt;myStruct, int&gt;::iterator it2 = mymap.find(m2);
         cout &lt;&lt; it1-&gt;second &lt;&lt; it2-&gt;second;
         // here it1-&gt;second=it2-&gt;second=3, although I would have expected it2 to be equal to map.end().
  }
  </code></pre>
  
  <p>I could use || instead of &amp;&amp;, but I'm not sure this is the correct way either. I just want to have operator&lt; implemented in such a way that I am able to find objects in my map, without making any errors, as is the case in the code I linked to.</p>
  
  <p>Thanks.</p>