dmd
dmd copied to clipboard
Cannot use `__rvalue` expression on a struct(non-copyable) property(non-copyable)
import core.memory : pureMalloc, pureFree;
struct S {
@("mallocd") ubyte[] p;
this() @disable;
this(this) @disable;
this(ubyte[] p) pure @nogc @trusted nothrow {
this.p = p;
}
this(S rhs) pure @nogc @trusted nothrow {
p = rhs.p;
rhs.p = null;
}
~this() pure @nogc @trusted nothrow {
if (p) {
pureFree(p.ptr);
p = null;
}
}
}
struct Container {
S s;
this() @disable;
this(this) @disable;
this(S s) pure @nogc @trusted nothrow {
this.s = __rvalue(s);
}
this(Container rhs) pure @nogc @trusted nothrow {
this.s = __rvalue(rhs.s);
}
}
Above code results in compilation error:
Error: struct `example.S` is not copyable because it has a disabled postblit
this.s = __rvalue(rhs.s);