title: Using .find() with struct as key in map in C++
body: <p>I do not have access to BOOST or STL; my struct and map looks similar to the following psuedo:</p>
  
  <pre><code> struct s_map_key{
      int a;
      int b;
      bool operator&lt;(const s_map_key&amp; smk) const 
      {
          if (a &lt; smk.a)       
          {            
              return true;
          } else if (a == smk.a)  
          { 
              if (b &lt; smk.b) 
              { 
                  return true;
              } 
              else if (b == smk.b)
              {
                  return true;
              }
          } 
              return false;
      }
  };
  
  int main(int argc, char* argv[])
  {
  
      std::multimap&lt;s_map_key, std::string&gt; myMap;
      for(int i = 0; i &lt;10; i++)
      {
      s_map_key smk;
      smk.a = i;
      smk.b = 2;
      myMap.insert(std::make_pair(smk, "test"));
      }
  
      s_map_key smk;
      smk.a = 3;
      std::multimap&lt;s_map_key, std::string&gt;::iterator x = myMap.find(smk);
      if(x != myMap.end())
      {
          std::cout &lt;&lt; x-&gt;first.a &lt;&lt;std::endl;
          std::cout &lt;&lt; x-&gt;first.b &lt;&lt;std::endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>What I am trying to do is search my multimap for all cases where A = 2, B = 2, or A &amp; B = 2. I am not exactly sure but, I think i need to create the predicates in my struct for "finding". Ideas?</p>