On Tuesday, 24 May 2022 at 14:11:57 UTC, Steven Schveighoffer
wrote:
Note it has no idea what the real object type is at this point,
just that it is an Object (which does not have a @nogc
destructor).
It actually has nothing to do with Object. It doesn't have a
destructor at all, so there's
On 5/23/22 10:29 PM, cc wrote:
```d
import core.memory;
import core.stdc.stdlib : malloc, free;
import core.lifetime : emplace;
T NEW(T, Args...)(auto ref Args args) /*@nogc*/ if (is(T == class)) {
enum size = __traits(classInstanceSize, T);
void* mem = malloc(size);
On Tuesday, 24 May 2022 at 02:55:06 UTC, Tejas wrote:
On Tuesday, 24 May 2022 at 02:29:38 UTC, cc wrote:
```d
import core.memory;
import core.stdc.stdlib : malloc, free;
import core.lifetime : emplace;
[...]
FWIW your code will compile if you add `extern(C++)` to `Foo`
Interesting, thanks.
On Tuesday, 24 May 2022 at 02:29:38 UTC, cc wrote:
```d
import core.memory;
import core.stdc.stdlib : malloc, free;
import core.lifetime : emplace;
[...]
FWIW your code will compile if you add `extern(C++)` to `Foo`
```d
import core.memory;
import core.stdc.stdlib : malloc, free;
import core.lifetime : emplace;
T NEW(T, Args...)(auto ref Args args) /*@nogc*/ if (is(T ==
class)) {
enum size = __traits(classInstanceSize, T);
void* mem = malloc(size);
scope(failure) free(mem);