I have a map and a vector.
I need to loop through the map and see if my vector has a matching record.
I'm using this:
Code:
std::map<std::string, int> mpDetailRecords;
std::vector<nsSVector::csRecord>::iterator startSDV = schooldistinctvector.begin();
std::string mapval;
while (startSDV != schooldistinctvector.end())
{
//add trim
mapval = ((startSDV)->corp + (startSDV)->grade);
trim(mapval);
mpDetailRecords[mapval.c_str()]++;
++startSDV;
}
//------------------------------------------
this is the part with the problem
std::map<std::string, int>::const_iterator itDetailRecords;
for (itDetailRecords=mpDetailRecords.begin(); itDetailRecords != mpDetailRecords.end(); ++itDetailRecords)
{
rval = findDesiredValue(schoolsummaryvector, itDetailRecords->first) ;
if (rval == 0)
{
std::cout << itDetailRecords->first << " not found or found with 0 count."<<std::endl;
}
else if (rval != itDetailRecords->second)
{
std::cout << itDetailRecords->first << ":" << rval << " not equal "<< itDetailRecords->second <<std::endl;
}
}
For whatever reason, it doesn't like "itDetailRecords->first "
I've tried
(itDetailRecords)->first
(*itDetailRecords)->first
itDetailRecords.first
*itDetailRecords.first
and none of these are working. I have sample code that says it should work...but I can't get it to work in my application.
Thanks.