|
Boost : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2005-08-26 22:26:37
Neal Becker wrote:
> Looking again at mersenne_twister, one of the objections that has been
> raised to adding serialization support, is that there is already
> iostream
> I/O support. It is in principle possible to leverage iostream to do
> serialization.
>
> Unfortunately, that approach is hardly efficient and rather ugly IMHO.
>
> But, what about the other way around? If we have generic archive
> support, can we use it to eliminate the need for iostream? I think
> so.
>
> In fact, consider this code (assuming serialization suport added to
> mersenne_twister):
> typedef boost::mt19937 rng_t;
>
> int main() {
> rng_t rng1;
>
> std::ostringstream os;
> boost::archive::text_oarchive oa(os, boost::archive::no_header);
> oa << const_cast<const rng_t&>(rng1);
>
> std::string st (os.str());
>
> std::cout << rng1 << '\n';
> std::cout << st << '\n';
> }
>
> As it is, the 2 outputs are almost identical. There is only one
> difference: the text_oarchive (,no_header) output prints 2 leading
> '0' characters.
>
> Is there some way to suppress this preamble?
>
> If so, then we have a more elegant solution. All we need to do is
> put in
> the serialization support and remove the iostream support, since
> serialization is just a generalization of i/o.
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk