How to call destroy() in @nogc?

cc cc at nevernet.com
Tue May 24 06:50:58 UTC 2022


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.  I noticed something similar when trying to 
call malloc in a pure function...

std.internal.memory:
```d
extern (C) @nogc nothrow pure private
{
     pragma(mangle, "malloc") void* fakePureMalloc(size_t) @safe;
     pragma(mangle, "calloc") void* fakePureCalloc(size_t nmemb, 
size_t size) @safe;
     pragma(mangle, "realloc") void* fakePureRealloc(return scope 
void* ptr, size_t size) @system;
}
```


More information about the Digitalmars-d-learn mailing list