Preciso fechar manualmente um ifstream?

Preciso ligar manualmente paraclose() quando eu uso umstd::ifstream?

Por exemplo, no código:

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");
}

Preciso ligar parafile.close() manualmente? Não deveriaifstream fazer uso de RAII para fechar arquivos?

questionAnswers(5)

yourAnswerToTheQuestion