mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
20 lines
370 B
Text
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');
|
|
}
|
|
---
|