In a multimap when two iterator holds values with same key mapped to differnt Value . How can we find which of them comes before the other in map
<p>Below is my code where i am inserting some values in map where two iterator it2 holds key and value "1-1","yes" and iterator it4 holds"1-1","no" . As i have inserted "1-1","yes" before "1-1","no" . The appearance of value "1-1","yes" in map is before "1-1","no". But when i try and compare which iterator comes before and which later then mycomp(it2->first,it4->first); or mycomp(it4->first,it2->first); both cases bool value returned is false. I know that map compares by Key and here key are same so probably it is returning false in both cases . But is there a way to determine whether a key related to which iterator is stored first and which last any how . I have to actually delete all values between a upper bound and lower bound . So i need to know in which is a forward direction for me While iterating for erasing the elements .</p>

<pre><code>std::multimap&lt;string, string&gt; m;
std::multimap&lt;string, string&gt;::iterator it2;
std::multimap&lt;string, string&gt;::iterator it4;
std::multimap&lt;string, string&gt;::key_compare mycomp;
std::multimap&lt;string, string&gt; common;
mycomp = m.key_comp();

cout &lt;&lt;"Making Map m "&lt;&lt;endl;

m.insert(pair&lt; string, string&gt;("1-1"," yes" ));
m.insert(pair&lt; string, string&gt;("1-1"," no" ));

it2=m.lower_bound("1-0");
it4=it2++;

cout &lt;&lt; "it2 values are : " &lt;&lt; it2-&gt; first &lt;&lt; " and " &lt;&lt; it2-&gt;second &lt;&lt;endl;
cout &lt;&lt; "it4 values are : " &lt;&lt; it4-&gt; first &lt;&lt; " and " &lt;&lt; it4-&gt;second&lt;&lt; endl;
bool j =false;
j=mycomp(it2-&gt;first,it4-&gt;first);
if(j==true)
cout &lt;&lt; " value of j returned is true" ;
if(j==false)
cout &lt;&lt; " value of j returned is false" ;
</code></pre>
