I know it has probably been asked a million times here, but I couldn't find any example that I could use.
I want to create an unordered_map whose key is an object that I made (vector2), what's the best way of implementing a hash function to it? Can I have an example?
struct vector2
{
vector2();
vector2(const vector2 &v2);
vector2(float fx, float fy);
vector2 operator * (float num) const;
vector2 operator * (const vector2& v2) const;
vector2 operator / (float num) const;
vector2 operator / (const vector2& v2) const;
vector2 operator - (float num) const;
vector2 operator - (const vector2& v2) const;
vector2 operator + (float num) const;
vector2 operator + (const vector2& v2) const;
bool operator == (const vector2& v2) const;
bool operator != (const vector2& v2) const;
vector2& operator += (const vector2& v2);
vector2& operator -= (const vector2& v2);
vector2& operator *= (float f);
vector2& operator /= (float f);
float x,y;
};
boost::unordered_map<vector2, int> won't work.