title: Error compile "no match for operator=="
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/10062532/no-matching-function-error-using-template-template-parameters-in-a-function">no matching function error using template template parameters in a function</a>  </p>
  </blockquote>
  
  
  
  <p>Good mornig I don't understand because I obtain compile error by implementing as global function the operator== (in class myList::iterator)
  If I realize the operator== as member function the code compile.</p>
  
  <p>The error is</p>
  
  <pre><code>error: no match for operator== in it == it1
  note: candidate is:
  note: tempalte&lt;class T&gt; bool operator==(const typename myList&lt;T&gt;::iterator&amp;,const typename myList&lt;T&gt;::iterator&amp;)
  </code></pre>
  
  <p>The code is:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;iterator&gt;
  #include &lt;typeinfo&gt;
  
  template &lt;class T&gt;
  class myList;
  
  template &lt;class T&gt;
  bool operator==(const typename myList&lt;T&gt;::iterator&amp; lhs,const typename myList&lt;T&gt;::iterator&amp; rhs);
  template &lt;class T&gt;
  bool operator!=(const typename myList&lt;T&gt;::iterator&amp; lhs,const typename myList&lt;T&gt;::iterator&amp; rhs);
  
  template &lt;class T&gt;
  class myList
  {
  private:
    class myInfo;
  public:
    //CTR DEFAULT
    myList():_pInfo(NULL)
    {}
    myList(T value):_pInfo(new myInfo(value))
    {}
    //  class iterator;
    //  friend class iterator;
    class iterator{
    public:
      //creo gli iteratori
      iterator():_pMyInfoIt(NULL)
      {}
      iterator(myInfo* p):_pMyInfoIt(p)
      {}
      iterator(const iterator&amp; it):_pMyInfoIt(it._pMyInfoIt)
      {}
      iterator&amp; operator=(const iterator&amp; it)
      {
        _pMyInfoIt = it._pMyInfoIt;
        return *this;
      }
      //creo funzioni che lavorano sugli iteratori
      /*
      bool operator==(const iterator&amp; rhs)
      {
        return _pMyInfoIt == rhs._pMyInfoIt;
  
      }
      */
      friend bool operator== &lt;T&gt;(const typename myList::iterator&amp; lhs,const typename myList::iterator&amp; rhs);
      friend bool operator!= &lt;T&gt;(const typename myList&lt;T&gt;::iterator&amp; lhs,const typename myList&lt;T&gt;::iterator&amp; rhs);
    private:
      myInfo* _pMyInfoIt;
    };
  
    myList::iterator begin()
    {
      std::cout &lt;&lt; __PRETTY_FUNCTION__ &lt;&lt; std::endl;
      return iterator(_pInfo);
    }
  
  private:
    class myInfo
    {
    public:
      myInfo(const T&amp; data):_data(data),_pMyInfo(NULL)
      {}
    private:
      T _data;
      myInfo* _pMyInfo;
    };
    myInfo* _pInfo;
  };
  
  
  template &lt;class T&gt;
  bool operator==(const typename myList&lt;T&gt;::iterator&amp; lhs,const typename myList&lt;T&gt;::iterator&amp; rhs)
  {
    std::cout &lt;&lt; __PRETTY_FUNCTION__ &lt;&lt; std::endl;
    return lhs._pMyInfoIt == rhs._pMyInfoIt;
  }
  
  template &lt;class T&gt;
  bool operator!=(const typename myList&lt;T&gt;::iterator&amp; lhs,const typename myList&lt;T&gt;::iterator&amp; rhs)
  {
    return !(lhs == rhs);
  }
  
  int main(int argc,char** argv){
    myList&lt;int&gt; test;
    myList&lt;int&gt;::iterator it = test.begin();
    myList&lt;int&gt;::iterator it1 = test.begin();
    std::cout &lt;&lt; typeid(it1).name() &lt;&lt; std::endl;
    if(it == it1)
      std::cout &lt;&lt; "EQUAL" &lt;&lt; std::endl;
    return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>thanks in advance</p>