Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unordered_map>
- struct Point {
- int x;
- int y;
- bool operator==(const Point& other) {
- return x == other.x && y == other.y;
- }
- };
- namespace std {
- template<>
- struct hash<Point> {
- inline size_t operator()(const Point& point) const {
- return point.x * 1024 + point.y;
- }
- };
- }
- int main() {
- std::unordered_map<Point, int> points_map;
- points_map.emplace(Point{1, 2}, 3);
- std::cout << points_map.size();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement