In following function code, ofs.close() results in failure
to write last end tag of XML archive, apparently because stream is closed
before destructor is executed, so when do we execute ofs.close() ? ofs.flush
does not help either or shell we skip executing any flush or close and just
return from function ?
template<class T>
void Serialize(const char * filename)
{
std::ofstream ofs(filename);
assert(ofs.good());
boost::archive::xml_oarchive oa(ofs);
oa << BOOST_SERIALIZATION_NVP(T);
ofs.close();
}