How can I know the equal_range didn't find any match cases?
like:
multimap<string,string> mapdic;
pair<multimap<string,string>::iterator,multimap<string,string>::iterator> ret;
// insert some string pairs
ret=mapdic.equal_range(thisUpperCaseName);
if (???)//how to test equal_range find nothing?
{
}else{
}
Anyone can help?
Thanks
:)
say your equal_range returns result of type pair
If your result.first == result.second
then it means there is nothing.
If there is even a single element then result.first != result.second
if(ret.first == ret.second)
{
// empty range
}
else
{
//at least an element.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With