I need to write/read a file that contains a std::map. The file must be read at the program start up (if it exists). Im using boost's fstream, but im getting this:
"terminate called after throwing an instance of 'boost::archive::archive_exception'
what(): input stream error"
Well, i really dont know what is happening.. these are my lines:
map<int64_t, int64_t> foo;
filesystem::path myFile = GetWorkingDirectory() / "myfile.dat";
[...............] // some code
filesystem::ifstream ifs(myFile);
archive::text_archive ta(ifs);
if (filesystem::exists(myFile)
{
ta >> foo; // foo is empty until now, it's fed by myFile
ifs.close();
}
What im doing wrong? Any idea? Thanks.
P.S. Note that some lines after, i need to do the reverse action: write into myfile.dat the std::map foo.
EDIT: all works if i use std::ifstream, saving the file in the same dir where im running the Application. But using boost and his path, something goes wrong.