How can I use a C++ unordered_set for a custom class?
问题 How can I store objects of a class in an unordered_set ? My program needs to frequently check if an object exists in this unordered_set and if it does, then do some update on that object. I have looked up online on how to use unordered_set , but sadly most tutorials are about using it on int or string types. But how can I use it on a class? How can I define a hash function to make the node_id in the following example the key of the unordered_set ? #include <iostream> #include <unordered_set>