title: Why is the std::map.find() not working in following case?
body: <p>The <code>snmp.h</code> header file contains the definition of <code>AsnObjectIdentifier</code> struct and unfortunately there is no equality operator overload for this struct. I want <code>AsnObjectIdentifier</code> to be the key of an <code>std::map</code> but the problem is that <code>find()</code> is not able to find the key in the map. I have defined a custom comparator <code>AsnObjectIdentifierComparator</code> which serves as third template argument to the std::map declaration. Minimum reproducible code for the scenario is as follows:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;map&gt;
  using namespace std;
  
  typedef unsigned int UINT;
  
  typedef struct {
    UINT   idLength;
    UINT * ids;
  } AsnObjectIdentifier;
  
  struct AsnObjectIdentifierComparator {
  
    bool operator()(const AsnObjectIdentifier&amp; left, const AsnObjectIdentifier&amp; right) const {
      UINT* leftOidArr = left.ids, * rightOidArr = right.ids;
      UINT smallerOidLen = (left.idLength &lt; right.idLength ? left.idLength : right.idLength);
  
      for (UINT i = 0; i &lt; smallerOidLen; i++) {
        if (leftOidArr[i] &lt; rightOidArr[i]) {
          return true;
        }
      }
  
      if (smallerOidLen == left.idLength) {
        return true;
      }
      return false;
    }
  
  };
  
  
  typedef std::map&lt;AsnObjectIdentifier, std::string, AsnObjectIdentifierComparator&gt; MibMap;
  
  
  int main(void){
  
    MibMap map;
  
    UINT expectedOID1ids[] = { 1, 3, 6, 1, 1, 1, 2, 1 };
    AsnObjectIdentifier expectedOID1 = { 8, expectedOID1ids };
  
    map.insert( std::pair&lt;AsnObjectIdentifier, std::string&gt;(expectedOID1, "present") );
  
    cout &lt;&lt; map.size() &lt;&lt; endl;
  
    if(map.find(expectedOID1) == map.end()) {
  
        cout &lt;&lt; "Not found"  &lt;&lt; endl;   
  
    }
  
  }
  </code></pre>
  
  <p>It makes sense that <code>AsnObjectIdentifierComparator</code> defines the order how the keys are placed in the map but of no use if we are not able to find the key at first place. There are no more template arguments in case of <code>std::map</code> and it does not have something like <code>keyequal</code> argument as in <code>unordered_map</code>. Moreover I don't have control over the definition of <code>AsnObjectIdentifier</code> as it is already defined in other header file. How can I work out of this scenario?</p>