mirror of
https://github.com/dlang/dmd.git
synced 2025-04-25 20:50:41 +03:00
Improve placement new changelog entry (#20954)
This commit is contained in:
parent
ee6449ded0
commit
cc6f184a66
1 changed files with 5 additions and 5 deletions
|
@ -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');
|
||||
}
|
||||
---
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue