the following code raises alot of errors, 'cause compiler doesn't parse postfix attributes on `new` and `delete` declarations:
class Foo {
@nogc this () {}
new (size_t size) @trusted nothrow @nogc {
import core.stdc.stdlib : malloc;
auto res = malloc(size);
if (res is null) {
import core.exception : onOutOfMemoryError;
onOutOfMemoryError();
}
return res;
}
delete (void* p) nothrow @nogc {
import core.stdc.stdlib : free;
free(p);
}
}
void main () {
auto f = new Foo();
delete f;
}
Comment #1 by dkorpel — 2021-09-08T12:36:38Z
class allocators were deprecated in 2.080.1, made an error in 2.087.1, and now removed.