D needs emplacement new
Namespace via Digitalmars-d
digitalmars-d at puremagic.com
Sat Apr 25 12:38:38 PDT 2015
On Saturday, 25 April 2015 at 19:21:28 UTC, weaselcat wrote:
> On Saturday, 25 April 2015 at 19:16:21 UTC, Namespace wrote:
>>> hmm...
>>> http://dlang.org/phobos/std_conv.html#.emplace
>>
>>> constructs an object of non-class type T at that address.
>>
>> Non-Class. ;)
>
> There's a class overload 3 down
> T emplace(T, Args...)(void[] chunk, auto ref Args args) if
> (is(T == class));
Which accepts a void[] chunk:
----
Foo f = new Foo(...);
emplace!(Foo)((cast(void*) f)[0 .. __traits(classInstanceSize,
Foo)], ...);
----
That doesn't look like a "simple and friendly" manner for me. And
it is also still not intuitive, not nice and not safe.
More information about the Digitalmars-d
mailing list