title: how to return std file streams
body: <p>I am working on a "filesystem" for my application to handle file operations like listing, creating, removing files and directories, and get file data. I want to use std::fstream for that because its safer and easier to format than the C FILE Handler. But i cannot return a stream object from the function (it doesn't have a copy c'tor) and when I am trying to return the reference I am getting a warning (i not warning doesn't mean that much but I am trying to fix every possible warning in my app and I did all of it until now): "warning: returning a reference to temporary". What can I do? If someone encountered this situation and found a better way to handle it, please tell.</p>
  
  <p>EDIT:</p>
  
  <pre><code>std::ofstream &amp;Filesystem::createFile(const String &amp;str) {
     std::ofstream file(str);
     return file;
  }
  </code></pre>
  
  <p>this is what I am trying to achieve. But due to the warning i am looking for another way.</p>
  
  <p>Thanks in advance,<br>
  Gasim Gasimzada</p>