|
Boost : |
From: Russell Hind (rh_gmane_at_[hidden])
Date: 2004-10-26 05:42:04
There seems to be a problem on win32 where if you use a stream opened in
text mode for a binary archive, you get errors. The following code
asserts because 'd' appears to have a random value on the way back in.
If you open both streams in binary mode then the code runs fine. XML
archives don't have the same problem.
I realise you shouldn't use a binary archive with a text stream, but is
there anyway to catch this at compile or run time? Otherwise you just
end up with a corrupted archive?
Thanks
Russell
double d = -6.7;
{
ofstream ofs("C:\\test.dat");
archive::binary_oarchive oa(ofs);
oa & d;
}
d = 0.0;
{
ifstream ifs("C:\\test.dat");
archive::binary_iarchive ia(ifs);
ia & d;
}
assert(std::abs(d + 6.7) < 0.0001);
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk