add Placement New

This commit is contained in:
Walter Bright 2024-11-09 22:07:37 -08:00 committed by Manu Evans
parent cdf4f5b072
commit 73158d8a78
24 changed files with 407 additions and 46 deletions

View file

@ -0,0 +1,20 @@
# Added Placement New Expression
Placement new explicitly provides the storage for NewExpression to initialize
with the newly created value, rather than using the GC.
---
struct S
{
float d;
int i;
char c;
}
void main()
{
S s;
S* p = new (s) S(); // place new object into s
assert(p.i == 0 && p.c == 0xFF);
}
---