Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-03-01 09:41:54


From: "Asger Alstrup Nielsen" <alstrup_at_[hidden]>
> 1) When saving, the number of elements is written to the stream, and
> then all elements of the vector is written to the stream using
> 'describe' on each.
>
> 2) When loading, the number of elements is read from the stream, and
> then each element is read using 'describe'.

Thanks for the explanation. :-)

> Similar for other containers.
>
> Please read the documentation for XTL to understand more about how this
> works:
>
> http://xtl.sourceforge.net/

From what I see(5.2), XTL distinguishes reads from writes using overloads on
obj_input<Format> and obj_output<Format>, which means that all supported
streams must derive from obj_input<> or obj_output<>.

MFC makes a runtime decision using stream.isStoring() (or whatever.)

Both approaches work, but I wanted to be able to support _anything_ as a
reader/writer, including std::istream/ostream _and_ std::FILE*. This is not
strictly necessary, of course, it just makes me feel better. :-)

Plus, I kind of like const correct code. I.e. in

void f(X const & x);

I'd like to be able to write x to a stream (but not read it.)


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