title: Find the end of stream for cin & ifstream?
body: <p>I'm running myself through a C++ text book that I have as a refresher to C++ programming. One of the practice problems (without going into too much detail) wants me to define a function that can be passed ifstream or cin (e.g. istream) as an argument. From there, I have to read through the stream. Trouble is, I can't figure out a way to have this <em>one</em> function use cin and ifstream to effectively find the end of the stream. Namely,</p>
  
  <pre><code>while(input_stream.peek() != EOF)
  </code></pre>
  
  <p>isn't going to work for cin. I could rework the function to look for a certain phrase (like "#End of Stream#" or something), but I think this is a bad idea if the file stream I pass has this exact phrase.</p>
  
  <p>I have thought to use function overloading, but so far the book has mentioned when it wants me to do this. I'm probably putting too much effort into this one practice problem, but I enjoy the creative process and am curious if there's such a way to do this without overloading.</p>