Find in a stl map doesn't work when a custom compare function is written which stops keys from sorting
<pre><code>class compare
{
    public:
    bool operator()(const int x,const int y) const
    {
        if(x-y == 0) 
            return false;
        else 
            return true; 
    }
};

int main()
{
    std::map&lt;char,int,compare&gt; mymap;

    //Add data into map
    mymap.insert ( std::pair&lt;char,int&gt;('f',100) );
    mymap.insert ( std::pair&lt;char,int&gt;('a',100) );
    mymap.insert ( std::pair&lt;char,int&gt;('k',100) );
    mymap.insert ( std::pair&lt;char,int&gt;('z',200) );

    //try to find a key in map
    std::map&lt;char,int,compare&gt;::iterator l_pos = mymap.begin();
    l_pos = mymap.find('z');

    if(l_pos != mymap.end())
    {
        printf("\nfound = %c\n",l_pos-&gt;first);
    }
    else
    {
        printf("Not found = %c\n",l_pos-&gt;first);
    }
}
</code></pre>

<p>Result:</p>

<pre><code>Not found =
</code></pre>

<p>But if I display the map I can see the contents. mymap contains: f => 100 a => 100 k => 100 z => 20</p>

<p>Find in a stl map doesn't work when a custom compare function is written which stops keys from sorting. The Find fails. Is there a way to fix this? Find doesn't return any data. I know stl maps are not for this purpose. But is there way to fix this? The Compare function stops sorting. The entries are stored in reverse order. When I use a for loop to iterate through the map I can see all the values. It is only the find command which is not working.</p>
