Boost logo

Boost Users :

Subject: Re: [Boost-users] [Serialization] Zero-sized arrays
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-08-04 01:28:39


We just added support for overloaded new operator for most compilers. That
might be an option. The wrapper binary_option might be what you want. The
of course there is the save/load construct data.

Robert Ramey

Matthias Troyer wrote:
> 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