|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-02-27 14:11:47
----- Original Message -----
From: "Yitzhak Sapir" <ysapir_at_[hidden]>
> > 3) ar << * static_cast<const bus_stop *>(this);
> >
>
> Implementing serialization with << and >> is nice, and it allows you to
> write code like this:
>
> socketstream << some_object;
> cout << some_object;
>
> which looks very generic. In fact, you may not even need to know which
> type of stream you're serializing too. However, This is also
> problematic. << and >> were not meant for serialization of restorable
> non-fielded data as far as I can see. That is, cout << 23 << 34; would
> print 2334. Sent to a file and read back to an int, you'd read "2334".
There are much worse problems with operator>>() than that one, IMO. How do
you unserialize an object with no default constructor?
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk