decltype(fpair_hash)
is std::function<std::size_t(std::pair<int , int>)>
so you are just building set with empty hash function.
You need to provide your function to constructor of std::unordered_set
:
std::unordered_set<std::pair<int, int>, decltype(fpair_hash)> temp2(10, fpair_hash);
This should make it work, but using std::function
will have overhead of polymorphic call and you probably don't need it:
auto fpair_hash = [](const std::pair<int, int>& v) -> std::size_t
{
return std::hash<int>()(v.first) ^ std::hash<int>()(v.second);
};
Finally, your hash function is not really good - it maps all pairs (x, x)
to 0
. Perhaps using something like x * 17 + y * 13
instead of x ^ y
will reduce probability of collisions.