emplace, immutable members and undefined behaviour

Tobias Pankrath via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Nov 15 03:12:01 PST 2015


On Sunday, 15 November 2015 at 10:59:43 UTC, Tobias Pankrath 
wrote:
>
> Point* p = (allocate memory from somewhere);
> emplace!Point(p, 1, 2);
>
> immutable(Point)* immutableP = cast(immutable(Point)*) p;

You could also use the emplace version that takes untyped memory: 
http://dlang.org/phobos/std_conv.html#.emplace The last one.


More information about the Digitalmars-d-learn mailing list