Argentum Online - Servidor
position.h
1 #ifndef POSITION_H
2 #define POSITION_H
3 
4 #include <functional>
5 
6 #include "../../include/nlohmann/json.hpp"
7 
8 typedef struct position {
9  int x;
10  int y;
11 } position_t;
12 
13 inline void to_json(nlohmann::json& j, const position_t& p) {
14  j["x"] = p.x;
15  j["y"] = p.y;
16 }
17 
18 inline void from_json(const nlohmann::json& j, position_t& p) {
19  j["x"].get_to(p.x);
20  j["y"].get_to(p.y);
21 }
22 
24  public:
25  std::size_t operator()(const position_t& position) const noexcept {
26  std::hash<int> hasher;
27  return hasher(position.x) ^ hasher(position.y);
28  }
29 };
30 
32  public:
33  bool operator()(const position_t& position1,
34  const position_t& position2) const noexcept {
35  return position1.x == position2.x && position1.y == position2.y;
36  }
37 };
38 
39 #endif // POSITION_H
PositionHasher
Definition: position.h:23
PositionComparator
Definition: position.h:31
position
Definition: position.h:8