close()使用时需要手动调用std::ifstream吗?
例如,在代码中:
std::string readContentsOfFile(std::string fileName) {
  std::ifstream file(fileName.c_str());
  if (file.good()) {
      std::stringstream buffer;
      buffer << file.rdbuf();
      file.close();
      return buffer.str();
  }
  throw std::runtime_exception("file not found");
}
我需要file.close()手动调用吗?不应该ifstream使用RAII来关闭文件吗?