Help on hashing

Suppose in unordered_map i want to put pair<int,int> as data type as “key”.
but if I write
unordered_map<pair<int,int>,int> i get a error so how can we put an user defined data type as “key” for hashing?

Unordered map does not have a hash function for pair< int,int >.
You need to define your own hash function.
See c++ Why can’t I compile an unordered_map with a pair as key? and How to create an unordered_map of pairs in C++? - GFG

1 Like