Merged in fix/boost-1_66-1_68_serialization (pull request #340)

Fix xml roundtrip serialization crash in boost 1.66-1.68
release/4.3a0
Chris Beall 2018-11-26 16:16:54 +00:00 committed by Frank Dellaert
commit 84febaf679
1 changed files with 7 additions and 2 deletions

View File

@ -84,8 +84,13 @@ bool deserializeFromFile(const std::string& filename, T& output) {
template<class T> template<class T>
std::string serializeXML(const T& input, const std::string& name="data") { std::string serializeXML(const T& input, const std::string& name="data") {
std::ostringstream out_archive_stream; std::ostringstream out_archive_stream;
// braces to flush out_archive as it goes out of scope before taking str()
// fixes crash with boost 1.66-1.68
// see https://github.com/boostorg/serialization/issues/82
{
boost::archive::xml_oarchive out_archive(out_archive_stream); boost::archive::xml_oarchive out_archive(out_archive_stream);
out_archive << boost::serialization::make_nvp(name.c_str(), input); out_archive << boost::serialization::make_nvp(name.c_str(), input);
}
return out_archive_stream.str(); return out_archive_stream.str();
} }