Improve placement new changelog entry (#20954)

This commit is contained in:
Quirin F. Schroll 2025-03-06 08:58:46 +01:00 committed by GitHub
parent ee6449ded0
commit cc6f184a66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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