Map Binary archive problem May be a bug?

On my phone, so I try my best to describe my problem. std::map<int,int> myMap; for(int i = 0; i != 30; i++) myMap.insert( make_pair(i,i+1) ); ofstream ofs("test"); binary_oarchive oa(ofs); oa<<myMap; ofs.close(); ofs.clear(); myMap.clear(); Ifstream ifs("test"); binary_iarchive ia(ifs); ia>>myMap; This code will throw an exception "input stream error". But if reducing the size of map like this for(int i = 0;i != 20; i++) It will run successful. Cause I can't figure it out so I seek your help. Look forward to your reply.

Try making the following change: ... ofstream ofs("test", "b"); // open stream for binary output binary_oarchive oa(ofs); oa<<myMap; ofs.close(); ofs.clear(); myMap.clear(); ... Robert Ramey -- View this message in context: http://boost.2283326.n4.nabble.com/Map-Binary-archive-problem-May-be-a-bug-t... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
Joshua Nocturne
-
Robert Ramey