C ++ unorderedmap vector index out of range

Currently, when I call the getFunction method, I get a nasty crash. My program compiles fine, but when I run and call this function, I get "Debug error with error!", "Expression: vector index out of range". Not sure how to deal with this, since I have not done much in C ++ for several years.

void* PluginMap::getFunction(char* pguid, char* fname){ if(plugin_map.size()>0 && plugin_map.find(pguid)!=plugin_map.end()) { //plugin_map is an unorderedmap that is defined elsewhere. MicroMap* mm = &plugin_map[pguid]; if((*mm).find(fname)!=(*mm).end()) { //MicroMap is an unorderedmap that goes in plugin_map, and contains void* return (*mm)[fname]; } } return 0; } 

Any help would be greatly appreciated.

0
source share
1 answer

Please avoid char * using std :: unordered_map use std :: string, and everything should be fine. char * is taken as a pointer type and can cause a problem if you have not defined std :: hash for it.

+1
source

All Articles