Boost logo

Boost Users :

Subject: Re: [Boost-users] [Serialization] Zero-sized arrays
From: Roland Kaminski (kaminski_at_[hidden])
Date: 2009-08-03 17:34:52


The code is full of such "dangerous" optimizations but most of them can be
somehow handled. It is optimized to be as cache-friendly as possible that is
why I would like to not remove this one.
A hook during deserialization would be exactly what I need. I could also
imagine other worarounds but all of them are very ugly.

Regards,
Roland

On Monday 03 August 2009 23:12:50 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 mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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