I am trying to specialize std :: unordered_map for class X with user hash and user equality. The problem is that both the equality functions and the hashes do not depend only on the object (s) of class X, but also on the data in another (fixed) object of another class Y. Here is an example of a toy (only with a hash function) of what i want to do:
#include <unordered_map>
using namespace std;
struct Y {
bool b;
struct X {
size_t i;
};
size_t hash(const X &x) {
return x.i + b;
}
unordered_map<X, int, hash> mymap;
};
The problem is that the hash function in the specialized template is a method, and the compiler complains ("calling a non-static member function without an object argument"). I want y.mymap to use y.hash (). Any way to do this?
Note that in real code, Y is also a template, if that matters.
Thank!
EDIT: , b , X. X, , X , X ( X, ). , , , , .