samedi 11 mars 2017

Can't set new value of existing std::unordered_map mapping

In one of my classes I have the following member:

std::unordered_map<std::string, float> m_SkillLevels;

And in one of the member functions of that class I am doing this:

// ...
else
{
    float val = float((NewValue - m_SkillValueMin) / (m_SkillValueMax - m_SkillValueMin));
    m_SkillLevels[Skill] = val;
}

In the debugger when these lines are being processed I can see that val is calculated to a proper value, say 175, and Skill contains the corrct map value. The current mapping for m_SkillLevels[Skill] is 0.

However, even after the assignment m_SkillLevels[Skill] = val the value in m_SkillLevels[Skill] is still 0, it hasn't changed.

It seems I am doing an obvious mistake, but I feel blind, can't spot the issue.
Any ideas?

Aucun commentaire:

Enregistrer un commentaire