title: How can I use an unordered_set with a custom struct?
body: <p>I want to use an <code>unordered_set</code> with a custom <code>struct</code>. In my case, the custom <code>struct</code> represents a 2D point in an euclidean plane. I know that one should define a hash function and comparator operator and I have done so as you can see in my code below:</p>
  
  <pre><code>struct Point {
      int X;
      int Y;
  
      Point() : X(0), Y(0) {};
      Point(const int&amp; x, const int&amp; y) : X(x), Y(y) {};
      Point(const IPoint&amp; other){
          X = other.X;
          Y = other.Y;
      };
  
      Point&amp; operator=(const Point&amp; other) {
          X = other.X;
          Y = other.Y;
          return *this;
      };
  
      bool operator==(const Point&amp; other) {
          if (X == other.X &amp;&amp; Y == other.Y)
              return true;
          return false;
      };
  
      bool operator&lt;(const Point&amp; other) {
          if (X &lt; other.X )
              return true;
          else if (X == other.X &amp;&amp; Y == other.Y)
              return true;
  
          return false;
      };
  
      size_t operator()(const Point&amp; pointToHash) const {
          size_t hash = pointToHash.X + 10 * pointToHash.Y;
          return hash;
      };
  };
  </code></pre>
  
  <p>However, I'm getting the error below, if I define the set as follows:</p>
  
  <pre><code>unordered_set&lt;Point&gt; mySet;
  </code></pre>
  
  <blockquote>
    <p>Error C2280   'std::hash&lt;_Kty>::hash(const std::hash&lt;_Kty> &amp;)':
    attempting to reference a deleted function</p>
  </blockquote>
  
  <p>What am I missing?</p>