D needs emplacement new

Namespace via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 26 11:21:10 PDT 2015


Since I'm unable to rebuild phobos on my Windows 8.1 PC, would 
someone else be interested, to apply a PR? The code (including 
comment) would be this:

----
/**
Given an existing object $(D obj), reinitialize the object of $(D 
class)
type $(D T) at that address. The constructor is passed the 
arguments
$(D Args), if any.

Returns: The reinitialized object
  */
T emplace(T, Args...)(ref T obj, auto ref Args args)
     if (is(T == class))
{
     enforce!ConvException(obj !is null, "emplace: Object is null 
and cannot be reinitialized");

     enum classSize = __traits(classInstanceSize, T);
     void[] buf = (cast(void*) obj)[0 .. classSize];
     return emplace!T(buf, args);
}
----

Unfortunately, I do not have much time to deal with the 
phobos-rebuilding problem, but I still want to improve phobos.


More information about the Digitalmars-d mailing list