I have the following test case that serializes an int into std:vector
.
It crashes with the following assertion:
serialization_test: /usr/include/boost/iostreams/detail/optional.hpp:55: T& boost::iostreams::detail::optional<T>::operator*() [with T = boost::iostreams::detail::concept_adapter<boost::iostreams::back_insert_device<std::vector<char> > >]: Assertion `initialized_' failed.
Any ideas? I think this should work...
BOOST_AUTO_TEST_CASE(serialize_base_test)
{
int t = 42;
std::vector<char> buffer;
iostreams::back_insert_device<std::vector<char>> sink{buffer};
iostreams::stream<iostreams::back_insert_device<std::vector<char>>> os;
os.open(sink);
archive::binary_oarchive oa(os);
oa << t;
os.flush();
os.close();
}
edit: I simplified the test case.
Destructor for an archive should be called before the stream is closed because it restores any altered stream facets to their state before the archive was opened.