title: C++ getline pass file or cin
body: <p>I searched internet and read manuals for hours but I can't figure out this one:</p>
  
  <p>My program gets one optional argument, which is file name. Consider this conditions</p>
  
  <pre><code>std::ifstream file;
  
  if (argc &gt; 1) {
      file.open(argv[1]);
  }
  
  if (file.is_open()) {
      processInput(file);
      file.close();
  } else {
      processInput(std::cin);
  }
  </code></pre>
  
  <p>in function <code>processInput</code> I'm trying to read all lines from input and do something with them like this:</p>
  
  <pre><code>void processInput(std::basic_istream&lt;char&gt; inputStream) {
      std::string line;
      while (std::getline(inputStream, line)) {
          processLine(line);
      }
  }
  </code></pre>
  
  <p>but I'm getting an error in basic_istream, so I don't have any clue what type should I pass to this function. I tried only blind shots.</p>