title: C++ std::map and std::pair<int, int> as Key
body: <p>I've the following C++ code:</p>
  
  <pre><code>struct MyStruct
  {
      int a[2];
      int b[2];
  };
  
  std::map&lt;std::pair&lt;int, int&gt; , MyStruct*&gt; MyMap;
  </code></pre>
  
  <p>Now I run this loop on MyMap:</p>
  
  <pre><code>for(std::map&lt;std::pair&lt;int, int&gt; , MyStruct*&gt;::iterator itr = MyMap.begin(); itr != MyMap.end(); ++itr)
  {
      std::pair&lt;int, int&gt; p (itr-&gt;first().second, itr-&gt;first().first);
      auto i = MyMap.find(p);
      if(i != MyMap.end())
      {
          //do something
      }
  }
  </code></pre>
  
  <p>What I'm actually trying to do is forming a pair by swapping the elements of another pair , so for example I have a key pair(12,16) in MyMap and also another key pair(16,12); these two key exists in MyMap and I know for sure. But when I apply the above technique MyMap don't return the value corresponding to the swapped key, what I'm guessing that MyMap.find(p) is matching the pointer of Key; but is there a way so that I can force MyMap.find(p) to match the corresponding value in Key (pair) instead of matching the pointers in Key (pair) ? Or is there anything I'm doing wrong here ?</p>