On Sat, 12 Nov 2011 16:17:29 +0100, Adam D. Ruppe <[email protected]> wrote:

The way I'd do it is:

S s;

auto heap = new S;

*heap = s;


that should work.

auto ps = std.conv.emplace(new S, s);

Avoids the hacky array aliasing.

// slightly more efficient
auto ps2 = emplace(cast(S*)(new ubyte[](S.sizeof)).ptr, s);

You will need to define a copy constructor for immutable fields.

Reply via email to