https://issues.dlang.org/show_bug.cgi?id=12918

Thayne <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #4 from Thayne <[email protected]> ---
A workaround for this is to allocate a Foo then assign it to the struct.

struct Foo
{
    int i;
}

void main()
{
    auto f = Foo(5);
    auto g = new Foo;
    *g = f;
}

However, if the Foo struct has the default constructor disabled (@disable
this();) then this doesn't work, even if postblit isn't disabled. The only way
I can think of to get this to work in general would be something like this:

auto f= Foo(5);
auto g = cast(Foo*) (new ubyte[Foo.sizeof]).ptr;
*g = f;

which is pretty awkward.

--

Reply via email to