I am using an object as a key in an unordered_map, so I need to define a hash function. My question is, where should the hash function be implemented. Should I put it with the class implementation or should I implement it close to where I need it.
UPDATE:
If it makes a difference, all of this is based in a framework
If you anticipate you’ll need to reuse it in many
unordered_maps, put it somewhere visible, like in the class.If you just need it for a one-off
unordered_map, put it close to where you use it. You can even use a lambda.