It's not a problem with the hashing function, it's a problem with the equality of the char*
's. You're relying upon pointer comparison, and you can see from the debugger watch variables, the pointers of the various "temp" literals have different locations, and are thus not equal.
You need to define an equality functor that actually does the string compare, and use that with the unordered_map
.
Or, instead of using char*
as your key, use std::string
, and avoid this issue altogether.