I have a code which looks as follows
template <typename KeyType, typename ValueType>
KeyType IDSystem<KeyType,ValueType>::registerParameter(const ValueType& value)
{
KeyType key = __IDCounter++;
_Map[key] = value; //crashes here
return key;
}
where _Map is
std::map<KeyType, ValueType> _Map;
The program used to crash where indicated, and then I replaced that line with
_Map.at(key) = value; //out_of_range thrown here
And now the program throws an std::out_of_range exception at that same line...
KeyType is int64_t from the standard library, and ValueType is a pointer to some class (like MyClass*).
The surprising part is that I used std::map just like that before... and no problem occured.
Am I using std::map incorrectly? Please advise.