I'm trying to find string tp inside an unordered_map but it's giving me problems.
unordered_map < string, int > pastPoints;
int t = 0;
void doStuff(int x, int y) {
pair < int, int > tp_ = {x, y};
string tp = int_string(tp_);
if (find(pastPoints.begin(), pastPoints.end(), tp) != pastPoints.end()) {
ans = max(ans, t - pastPoints[tp]);
}
pastPoints[tp] = t;
}
It's giving me this error:
error: no match for ‘operator==’ (operand types are ‘std::pair<conststd::basic_string<char>, int>’ and ‘const std::basic_string<char>’)
{ return *__it == _M_value; }
Am I using unordered_map::find wrong? I'm finding the key which is a string.