Under what circumstances can operator[] for std::map return 0?

Viewed 85

I'm working with LLVM, and I'm having issues with the following piece of code that I did not write:

static std::map<std::string, Value*> NamedValues;
... //Lots of other code
Value *V = NamedValues["Demo string"];
return V ? V : ErrorV("V is not in NamedValues map.");

From what I understand of std::map, it should never return a null pointer (Unless it's out of memory?), so I have a hard time understanding how V being 0 would indicate that V is not in the map. As is, my program is always getting an error here, but I can't figure out why. Any help on what is going on here?

2 Answers
Related