for(x = 0; x < MAX_SKILL; x++)
{
if(ch->pcdata->learned[x] == 3)
return whatever;
}
for(SkillsMap::iterator skill_iter = ch->pcdata->learned.begin(); skill_iter != ch->pcdata->learned.end(); ++skill_iter)
{
if(skill_iter->second <= 0)
continue;
return skill_iter->second;
}
// basic method to keep the map from 'creating' empty values
// whilst allowing you to return what its 'second' is.
// Darien
template<typename Map>
typename Map::mapped_type
map_value( const Map & m, typename Map::key_type v )
{
typename Map::const_iterator it = m.find( v );
if ( it == m.end() )
return typename Map::mapped_type();
return it->second;
}
Darien told me that checking a std::map for a certain value, like so: if( numbers[x] == 0 ) would cause the map to throw a default value into the map at key[x]. I didn't believe him because it sounded silly, but the above function when added as a test command to my codebase returned a Count #2 value of 900, instead of the expected 5.
Is this normal expected behavior for a std::map or is this a compiler bug that needs to be reported to GNU?