std::string as a key in std::map using a compare operator
I'm trying to use a std::string as a key in a std::map however, i'm unable to find() correctly. My code is somewhat complicated and large so this is a small program that demonstrates the problem I'm having. If someone could tell me why this doesn't work, i'd be very grateful. Thanks. #include <stdio.h> #include <string> #include <map> struct comparer { public: bool operator()(const std::string x, const std::string y) { return x.compare(y)==0; } }; int main(int argc, char *argv[]) { std::map<std::string, int, comparer> numbers; numbers.insert(std::pair<std::string,int>("One",1)); numbers.insert