0

I have an Agent's class and there I have some unordered_map variables

  unordered_map<Node, Node> came_from;  // <Parent, Child>
  unordered_map<Node, unsigned int> g_score;
  unordered_map<Node, unsigned int> f_score;
  unordered_map<Node, unsigned int> closed_set;

The Node it's just a simple structure and it looks something like that

typedef struct Node {
  uint x, y, f_score, g_score;

  bool operator==(const Node &n) const { return (x == n.x && y == n.y); }

  bool operator!=(const Node &n) const { return (x != n.x || y != n.y); }

  friend ostream &operator<<(ostream &out, const Node &n) {
    out << '[' << n.x << ", " << n.y << ']';
    return (out);
  }
} Node;

And when I starting the build, I have such error

Error   C2280   "std::hash<_Kty>::hash(void)": attempting to reference a deleted function
        with
        [
            _Kty=Node
        ]   Coopirative_Pathfinding C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.23.28019\include\unordered_map(117,1)  

When I'am pass the pointer to the Node its working

  unordered_map<Node*, Node> came_from;  // <Parent, Child>
  unordered_map<Node*, unsigned int> g_score;
  unordered_map<Node*, unsigned int> f_score;
  unordered_map<Node*, unsigned int> closed_set;

What am I doing wrong?

JuiceFV
  • 171
  • 11
  • TL;DR of the dupe: `std::unordered_map` is a hash based container and you either need to specialize `std::hash` for your type or provide your own hasher for the third template parameter. – NathanOliver Nov 13 '19 at 22:10
  • @NathanOliver- Reinstate Monica Yeah you right. Thank you a lot! – JuiceFV Nov 13 '19 at 22:30

0 Answers0