I have a quite big object to serialize to disk, like this:
std::cerr << "Failed to write to file \"" << EngineFile << "\"! Aborting ..." << std::endl;
std::cout << "\"" << EngineFile << "\" successfully wrote to disk." << std::endl;
First of all,
serialize should constantly verify whether its write operations succeed and throw should they fail.
In the code you've presented you should check
OutEngineStream.fail() (it covers more cases than
bad) before calling
close may also set this state). This however will still leave
serialize implemented incorrectly.