title: How to define different criteria for FIND and ORDER in std::set
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;set&gt;
  #include &lt;string&gt;
  using namespace std;
  
  struct Client {
     string client_id;
     int    salary;   
  
     // allow client to sorted by salary
     bool operator&lt;(const Client&amp; rhs) const {
        return salary &lt; rhs.salary;
     }
  
     // expect to search on client_id but this doesn't work
     bool operator==(const Client&amp; rhs) const {
        return client_id == rhs.client_id;
     }
  };    
  
  int main()
  {
     set&lt;Client&gt; clients;
  
     clients.emplace(Client{"a001", 10});
     clients.emplace(Client{"a002", 20});
  
     if (clients.find(Client{"a0001", 10}) != clients.end()) // Found
       cout &lt;&lt; "Found\n";
     else
       cout &lt;&lt; "Not Found\n";
  
     if (clients.find(Client{"a0002"}) != clients.end()) // Not Found
       cout &lt;&lt; "Found\n";
     else
       cout &lt;&lt; "Not Found\n";     
     return 0;
  }
  </code></pre>
  
  <p>The output result of <code>set::find</code> does match <a href="http://www.cplusplus.com/reference/set/set/find/" rel="nofollow">this document</a>.
  The <code>set::find</code> is based on the the container's comparison object which is in turn based on the <code>salary</code> rather than <code>client_id</code>.</p>
  
  <p>Question> In this case, I need to order <code>Clients</code> based on their <code>salary</code> but when in search I would like to search based on <code>client_id</code>. Is there a way to work around this? I would like to use STL functions rather than write a loop myself.</p>