Boost logo

Boost Users :

From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2006-01-23 09:13:48


Adrian Grigore wrote:
>
> I encountered a mysterious stream exception when trying to deserialize
> an std::map<std::string,long> container. The exception seems to occur
> depending on the data stored in the container. Unfortunately none of
> the hints regarding stream exceptions from the manual seem to help.
> ...
>
> void ResArchive::SaveToFile()
> {
> std::ofstream ofs (INDEX_FILE_NAME);
> boost::archive::binary_oarchive OArchive(ofs);
> OArchive <<ArchiveEntries;
> }
>
> void ResArchive::LoadFromFile()
> {
> std::ifstream ifs(INDEX_FILE_NAME);
> boost::archive::binary_iarchive IArchive(ifs);
> IArchive >>ArchiveEntries; //STREAM EXCEPTION!!!
> }

Open your streams with 'binary' mode.

Jeff Flinn


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net