Binary data-structure serialization

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Jun 3 06:45:11 PDT 2010


On 06/03/2010 02:31 AM, Robert M. Münch wrote:
> On 2010-06-02 21:34:32 +0200, Andrei Alexandrescu said:
>
>> The signature for non-class types is:
>>
>> T* emplace(T, Args...)(void * address, Args args);
>>
>> The function creates an object of type T at location address and
>> initializes it with args. Returns a pointer to the just-created value.
>> I needed this function for TightArray.
>
> Hi, does this already work? This would make it possible to allocate T
> within a memory-mapped file. I would like to give it a try.

I didn't have much time to work on it lately, but I'll check it in soon.

> Not sure how to deal with re-allocation problem as pointers within the
> MMF need to be MMF relative and not absolut. IMO via operator
> overloading this should be possible to handle in the background.

Once created, a file mapping is at a constant address. If you remap a 
file (an unsafe operation), you can memcpy the data around. All D 
objects are assumed to be relocatable.


Andrei


More information about the Digitalmars-d mailing list