Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-01-14 10:28:48


In a project of mine we plan to store some number of objects into an archive
and later load them. The problem is that the number of objects is not known
when you're writing an archive, so when reading, you don't know where to
stop.

I wonder if the following code will work:

   ifstream ifs(...);
   boost::binary_iarchive ia(ifs);

   while(ifs) {
       some_object obj;
       ia >> obj;
       objects.push_back(obj);
   }

The problem is that I don't know what archive will do on stream errors. For
the above to work, it should stop doing anything. But I can't find any
documentation about what happens -- I think it's better to discuss and
document that.

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk