title: How can I read lines in vector<T> like ifstream
body: <p>In the following code it works correctly:</p>
  <pre><code>int main(int argc, char *argv[]) {
      uint64_t bucket_size = (kMemoryAvailable / sizeof(double) - sizeof(std::vector &lt; double &gt; )) * 0.7;
  
      std::ifstream input_file(input_file_path);
      size_t number_of_buckets = 0;
      while (input_file) {
          WriteBucket(input_file, bucket_size, number_of_buckets);
          ++number_of_buckets;
      }
      std::cout &lt;&lt; &quot;number_of_buckets: &quot; &lt;&lt; number_of_buckets &lt;&lt; std::endl;
  
      std::vector &lt;std::ifstream&gt; intermediate_outputs;
      for (size_t i = 0; i &lt; number_of_buckets; ++i) {
          intermediate_outputs.push_back(std::ifstream(&quot;intermediate_output_&quot; + std::to_string(i)));
      }
  
      std::ofstream output_file(output_file_path);
  
      MergeFiles(intermediate_outputs, output_file);
      output_file.close();
  
      for (size_t i = 0; i &lt; number_of_buckets; ++i) {
          intermediate_outputs[i].close();
          remove((&quot;intermediate_output_&quot; + std::to_string(i)).c_str());
      }
  }
  </code></pre>
  <p>I want to execute this code for any type as this code, but the file is not read and entered into the loop</p>
  <pre><code>template&lt;typename T&gt;
  static void sorting(std::vector&lt;T&gt; &amp;input_file) {
      const uint64_t kMemoryAvailable = 100 * 1024 * 1024;
  
      uint64_t bucket_size = (kMemoryAvailable / sizeof(double) - sizeof(std::vector&lt;double&gt;)) * 0.7;
  
      size_t number_of_chunks = 0;
      string output_file_path;
  
      while (!input_file.empty()) {
          WriteBucket(input_file, bucket_size, number_of_chunks);
          ++number_of_chunks;
      }
      vector&lt;ifstream&gt; intermediate_outputs;
      for (size_t i = 0; i &lt; number_of_chunks; ++i) {
          intermediate_outputs.push_back(ifstream(&quot;intermediate_output_&quot; + to_string(i)));
      }
  
      ofstream output_file(output_file_path);
      MergeFiles(intermediate_outputs, output_file);
      output_file.close();
  
      for (size_t i = 0; i &lt; number_of_chunks; ++i) {
          intermediate_outputs[i].close();
          remove((&quot;intermediate_output_&quot; + to_string(i)).c_str());
      }
  
  }
  </code></pre>
  <p>In this code I would like to read the input_file from the first code in the WriteBucket method to produce several intermediate_outputs that I will write on later, but this does not work in T .</p>