title: Using std::copy - error C2679: can't find correct binary '=' operator
body: <p>I am trying to use a solution from this question:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/1567082/how-do-i-iterate-over-cin-line-by-line-in-c/1567703#1567703">How do I iterate over cin line by line in C++?</a></li>
  </ul>
  
  <p><strong>The error message</strong></p>
  
  <blockquote>
    <p>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility(2144): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const Line' (or there is no acceptable conversion)</p>
  </blockquote>
  
  <p>(and a bunch of template trace data after this)</p>
  
  <p>I am using Visual C++ 2010 Express.</p>
  
  <p><strong>The code</strong></p>
  
  <pre><code>#include&lt;string&gt;
  #include&lt;iostream&gt;
  #include&lt;fstream&gt;
  #include&lt;vector&gt;
  #include&lt;iterator&gt;
  
  class Line
  {
    std::string data;
  
  public:
    friend std::istream&amp; operator&gt;&gt;(std::istream&amp; inputStream, Line&amp; line)
    {
      std::getline(inputStream, line.data);
      return inputStream;
    }
  
    operator std::string()
    {
      return data;
    }
  };
  
  int main(int argc, char* argv[])
  {
    std::fstream file("filename.txt", std::fstream::in | std::fstream::out);
    std::vector&lt;std::string&gt; lines;
  
    // error is in one of these lines
    std::copy(
      std::istream_iterator&lt;Line&gt;(file),
      std::istream_iterator&lt;Line&gt;(),
      std::back_inserter(lines));
  }
  </code></pre>