On 2012-09-05 09:18, Andrei Alexandrescu wrote:
Deserialization is a low-level operation, and it shouldn't invoke a
constructor because the object has been constructed at serialization time.
I suggest you allocate a chunk of raw memory, deserialize into it, then
cast it to the object type.
I gave this a try but I have two questions:
1. Is that safe to do with immutable fields?
2. If I'm allocating a chunk of raw memory then I would need to recreate
the vtable, classinfo and other stuff. Would it be safe to just create a
new instance with the "_d_newclass"? This is the function used by the
runtime when "new" is used. This will allocate the necessary memory,
handle all the extra stuff but it won't call the constructor.
--
/Jacob Carlborg