How to write overload operators for STL containers and alogrithm functions?
<p>For example, I want to write overload functions for <code>set_difference</code> which compares the type <code>std::set&lt;point&gt;</code></p>

<pre><code>class myIter : public std::iterator&lt;std::input_iterator_tag, int&gt; {
public:
    myIter(int n) : num(n){}
    myIter(const myIter &amp; n) : num(n.num){}
    int &amp; operator *(){return num;}
    myIter &amp; operator ++(){++num; return *this;}
    bool operator !=(const myIter &amp; n){return n.num != num;}
private:
    int num;
};

struct point
{
  point(int X, int Y):x(X), y(Y){}
  int x;
  int y;
}

int main()
{
   set &lt;point&gt; myset;
   myset.insert(point(1, 1);
   myset.insert(point(3, 2);
   myset.insert(point(5, 3);

  //find the missing elements in set for `point.x` using `set_difference`

   std::set&lt;int&gt; missing;

   std::set_difference(myIter(myset.begin()-&gt;x+1), myIter(myset.rbegin()-&gt;x),
   myset.begin(), myset.end(), std::insert_iterator&lt;std::set&lt;int&gt;&gt;(missing, missing.begin()));

}
</code></pre>

<p>After applying the <code>std::set_difference</code> on <code>point.x</code> variables the <code>set&lt;int&gt; missing</code> must be:</p>

<pre><code>missing[0] {2}
missing[1] {4}
</code></pre>

<p>How do i know how to write the overload operators for the operation?</p>
