mirror of
https://github.com/dlang/dmd.git
synced 2025-04-25 20:50:41 +03:00
add Placement New
This commit is contained in:
parent
cdf4f5b072
commit
73158d8a78
24 changed files with 407 additions and 46 deletions
20
changelog/dmd.placementNew.dd
Normal file
20
changelog/dmd.placementNew.dd
Normal 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);
|
||||
}
|
||||
---
|
Loading…
Add table
Add a link
Reference in a new issue