title: Compiling error with std::min_element
body: <p>I have been struggling with C2440 compiling error when I use std::min_element:</p>
  
  <pre><code>struct compare_x_coordinate 
  {
    bool operator() (Geocoordinatefloat i,Geocoordinatefloat j) { return i.x_&lt;j.x_; }
  } mycompare;
  
  vector&lt;Geocoordinatefloat&gt;::iterator it_min;
  vector&lt;Geocoordinatefloat&gt; ptArray;
  ptArray.push_back(...)
  ptArray.push_back(...)
  ...
  
  it_min = std::min_element(ptArray.begin(),ptArray.end(),mycompare); // Line 475 Compiling error C2440
  
  std::min_element(ptArray.begin(),ptArray.end(),mycompare);           // Right
  </code></pre>
  
  <p>The compiling error with VC2010 is:</p>
  
  <pre><code>Error   19  error C2440: '=' : cannot convert from 'const geometric::Geocoordinate&lt;T&gt; ' to 'geometric::Geocoordinate&lt;T&gt; *'  c:\research\projectivecorrection\code\iris\geometriccorrection\src\correspondingpoints\cp_hybrid.cpp    475
  </code></pre>
  
  <p>It is true that Geocoordinatefloat is a complicated class, and if I redefine class Geocoordinatefloat in a very simple way：</p>
  
  <pre><code>class Geocoordinatefloat
  {
  public:
    int x;
    int y;
    float Func()
    {
        return 1;
    };
    virtual void Fun2()
    {
        cout&lt;&lt;"hello"&lt;&lt;endl;
    };
  
  };
  </code></pre>
  
  <p>It will work. But for my program, it is impossible to change the definition of the class Geocoordinatefloat. I was wondering what element in Geocoordinatefloat makes the compiling error. Sorry, I cannot give the definition of Geocoordinatefloat as it is a very big class. Thanks for any suggestion.</p>
  
  <p>EDIT:
  With the request, I make a simple program to repeat the error:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vld.h&gt; 
  #include &lt;map&gt;
  #include &lt;set&gt;
  #include &lt;iostream&gt;
  #include &lt;algorithm&gt;
  #include &lt;vector&gt;
  
  
  using namespace std;
  
  
  
  template &lt;typename T&gt;
  class  Geocoordinate 
  {
  public:
      Geocoordinate() {};
      ~Geocoordinate() {};
       T x_;
       T y_;
   };
  
  typedef Geocoordinate&lt;float&gt; Geocoordinatefloat;
  typedef vector&lt;Geocoordinatefloat&gt; PointArray;
  
  
  struct compare_x_coordinate 
  {
      bool operator() (const Geocoordinatefloat &amp;i,const Geocoordinatefloat &amp;j) { return i.x_&lt;j.x_; }
  } mycompare;
  
  void find_left_right_eignpoints(const PointArray &amp;ptArray, 
          Geocoordinatefloat &amp;left)
  {
          vector&lt;float&gt; x_cord;
          PointArray::iterator it_min;
          std::min_element(ptArray.begin(),ptArray.end(),mycompare); 
  
          /******************************************************************************************
          // Error    1   error C2440: '=' : cannot convert from 'const Geocoordinate&lt;T&gt; 
          // ' to 'Geocoordinate&lt;T&gt; *'    c:\main.cpp 41
          */
          it_min = std::min_element(ptArray.begin(),ptArray.end(),mycompare);  // error code is here
  
          int index_min = it_min-ptArray.begin();
          left    = ptArray[index_min];
  
  }
  
  
  
  int  main(int argc, char* argv[])
  {
  
  
      return 0;
  
  }
  </code></pre>