我有一个std :: map,我使用迭代器来查找某个键,值对。找到它后,我无法从迭代器中获取键值对的位置。通过做另一个发现我可以得到它,但我想为此工作。迭代器操作问题
//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
}
}
注:编辑为size_t关键的位置,值对
你是什么意思“来自迭代器的size_t值”? size_t是C中的一个类型,它不是迭代器的值。请详细说明 – 2010-03-04 04:53:48
迭代器的“size_t”值是什么意思? – Naveen 2010-03-04 04:54:25
什么'size_t'值?您的地图使用'std :: string'作为键,'myclass *'作为值。我没有在任何地方看到任何'size_t' ... – 2010-03-04 04:54:42