$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] binary archive with text file
From: gtsml owevwr (gtsml.owevwr_at_[hidden])
Date: 2009-01-09 08:42:54
Hi,
I just spend a entire day to realize this code was wrong:
std::ofstream ofs(filename.c_str());
boost::archive::binary_oarchive oa(ofs);
oa << (*this);
And this one was right:
std::ofstream ofs(filename.c_str(), std::ios::binary);
boost::archive::binary_oarchive oa(ofs);
oa << (*this);
The consequence of the first code is a "stream_error" throw which doesn't
say much about the problem.
Instead, an exception should be thrown earlier on if the file is not in
binary mode.
thanks alot to all the boost contributors,
Frank