[serialization] Loading objects of classes with customized operator new

Hi Robert Under release.html#todo you say that it is currently not possible to use serialization with types that define their own new/delete operators. In serialialization.html#constructors you describe a technique how types that do not possess a default constructor can be serialized. Given the design of load_object_ptr and load_construct_data it seems that this is easily possible, namely by overloading load_object_ptr. I'm therefore wondering whether the remark under release.html#todo is outdated or whether I'm missing something. Regards, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.

Are you by any chance using draft #20 with boost_1-31? Currently, I don't have load_object_ptr anymore in the code. It fell a way when I made adjustments to accommodate ADL. My original intention was that load_object_ptr be overloadible for just this reason. I can't remember why it was on a TODO list. In any case, it seems to me that there is (or was) an obstacle to using a class specific new. The current system uses a global new operator or a stack_allocator to allocate the requisite amount of memory then uses placement new to initialize it. This turned out to be more convenient in particular situations - specifically serialization of the STL library. So, any class specific new would probably not be invoked. I'm not sure how to handle this in general - I suspect there is no general solution. I suppose you could use something like the following: class x { y *m_y; template<class Archive> load(Archive& ar){ m_y = new y; ar >> m_y; } }; but of course this would evade the free object tracking for serialized pointers I really haven't thought about this much. Robert Ramey "Andreas Huber" <ahd6974-spamgroupstrap@yahoo.com> wrote in message news:clmgq8$urs$1@sea.gmane.org...
Hi Robert
Under release.html#todo you say that it is currently not possible to use serialization with types that define their own new/delete operators. In serialialization.html#constructors you describe a technique how types that do not possess a default constructor can be serialized. Given the design of load_object_ptr and load_construct_data it seems that this is easily possible, namely by overloading load_object_ptr. I'm therefore wondering whether the remark under release.html#todo is outdated or whether I'm missing something.
Regards,
-- Andreas Huber
When replying by private email, please remove the words spam and trap from the address shown in the header.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Robert Ramey wrote:
Are you by any chance using draft #20 with boost_1-31?
No, I've downloaded the RC_1_32_0 branch. I haven't yet tried to use the code, I was just reading the documentation.
Currently, I don't have load_object_ptr anymore in the code. It fell a way when I made adjustments to accommodate ADL.
Hmmm, the same would apply to load_construct_data, which still is in the code or am I missing something?
I suppose you could use something like the following:
class x { y *m_y; template<class Archive> load(Archive& ar){ m_y = new y; ar >> m_y; } };
but of course this would evade the free object tracking for serialized pointers
Yes, I could do something like this. However, as you said, it's a rather inconvenient because I'd have to implement tracking myself. The situation I'm thinking of using serialization in consists of a handful of objects that can freely point to other objects. Regards, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
participants (2)
-
Andreas Huber
-
Robert Ramey