次のように unordered_set を定義しようとしています。
unordered_set<Point> m_Points;
コンパイルすると、次のエラーが発生します。
C++ 標準は、この型のハッシュを提供していません。
クラスPoint
:
class Point{
private:
int x, y;
public:
Point(int a_x, int a_y)
: x(a_x), y(a_y)
{}
~Point(){}
int getX()const { return x; }
int getY()const { return y; }
bool operator == (const Point& rhs) const{
return x == rhs.x && y == rhs.y;
}
bool operator != (const Point& rhs) const{
return !(*this == rhs);
}
};
- Pointのハッシュ関数を定義する方法/場所は?
- 2D ポイントの適切なハッシュ関数は何でしょうか?