D hackers requested. Dancing around postblit.
IgorStepanov via Digitalmars-d
digitalmars-d at puremagic.com
Wed Nov 5 12:24:44 PST 2014
FYI:
My second try:
void emplace(V1)(ref V1 dst, ref V1 src) @trusted if (is(V1 ==
struct))
{
static if (new_obj)
{
V1 tmp = cast(V1)src; //create copy and call postblit
static V1 init = V1.init;
//bitwise copy of object, which already postblitted
(cast(void*)&dst)[0 .. V1.sizeof] = (cast(void*)&tmp)[0
.. V1.sizeof];
//initialize tmp with V1.init.
(cast(void*)&tmp)[0 .. V1.sizeof] = (cast(void*)&init)[0
.. V1.sizeof];
}
}
This method do one extra dtor call for tmp, but it may be trivial
because tmp is V.init.
However it is not a complete solution of the task.
More information about the Digitalmars-d
mailing list