Since c++11, we can move assign one std::fstream
object to another, but I'm unable to find documentation that states, what happens if the fstream
object is already associated with a file (is_open()==true
).
So my question is whether in the following code, File1.txt
will properly be closed or if I have to close it manually. And if I have to do it manually, what happens if I don't?
std::fstream file("File1.txt");
file = std::fstream("File2.txt"); //will this implicitly call file.close()?