Placement new and @trusted
IchorDev
zxinsworld at gmail.com
Wed Sep 10 14:31:27 UTC 2025
On Wednesday, 10 September 2025 at 13:13:34 UTC, Richard (Rikki)
Andrew Cattermole wrote:
> Placement new is @system, but you wanted to use it in an @safe
> function iff the constructor to be called is @safe as well.
Pretty much.
> The reason placement new is @system is because of double-init.
> It can't be a safe operation.
What?! Like, it assigns to the memory twice? What's the point of
this feature, then? I thought this could essentially replace
`emplace` for constructing types into uninitialised memory, but
instead it's just a booby-trap that stops people from making
their code `@safe`?
More information about the Digitalmars-d-learn
mailing list