dmd/changelog/dmd.placementNew.dd
2025-03-06 15:58:46 +08:00

20 lines
370 B
Text

Added Placement New Expression
Placement `new` explicitly provides the storage for `new` expression to initialize
with the newly created value, rather than using the GC.
---
struct S
{
float d;
int i;
char c;
}
void main() @system @nogc
{
S s;
S* p = new (s) S(3.14, 42, 'X'); // place new object into s
assert(p.i == 42 && p.c == 'X');
}
---