fstream is a proper
How do you close a STD if ifstream?
Using a nested scope just to close the file is completely artificial - if you mean to close it, call close() on it. Although, you might be able to argue that restricting the object's lifetime to the necessary scope means that you won't accidentally access a closed ifstream.
How do I close an ifstream file?
std::ifstream::close
The file association of a stream is kept by its internal stream buffer: Internally, the function calls rdbuf()->close() , and sets failbit in case of failure. Note that any open file is automatically closed when the ifstream object is destroyed.