i have a std::map and i am using iterator to find a certain key,value pair. After finding it i am unable to get the position of the key,value pair from the iterator. By doing another find i can get it, but i want a work around for this.
//mycode is this
std::map<std::string,myclass*> mymap;
size_t myfind(const std::string &s)
{
std::map<std:string,myclass*>::iterator i=mymap.find(s);
if((i==mymap.end())||((*i).second==0))
{
std::cout<<"some error\n";
}
else
{
//here i need to return the size_t value of the iterator i
}
}
NOTE: edited size_t as the position of key,value pair