Boost logo

Boost Users :

Subject: Re: [Boost-users] [Serialization] Zero-sized arrays
From: Matthias Troyer (troyer_at_[hidden])
Date: 2009-08-03 17:12:50


On 3 Aug 2009, at 10:51, Roland Kaminski wrote:

> Hi,
> i am planning to use the boost serialization library to implement
> checkpointing for an ASP/Sat solver. Unfortunately, the solver
> implements one
> (very special) optimization that makes use of a zero-sized array at
> the end
> of a class.
> I have found no way to store something like this using the library.
> There is a
> small program in the attachment that contains data structures
> similar to the
> ones used in the solver code. This would need a mechanism to control
> the
> allocation of memory during deserialization. Do you see any
> possibility do
> serialize something like this?
>
> Regards and thanks,
> Roland
>

Uhhhh .... that is dangerous code. and this object is neither
Assignable nor Copyable. Do you really need to make use of that
optimization? In essence you need to control the memory allocation:

     Base *x = new(new unsigned char[sizeof(Derived) + 42 *
sizeof(int)]) Derived(42);

and have the serialization library do such a new operation instead of
the default one. Robert, is there a hook for that?

Matthias


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net