On Sunday, 31 January 2016 at 17:42:19 UTC, anonymous wrote:
I don't know if this works in all cases, but it passes that simple test:

----
@disable void foo(ref int x);
void foo(int x) {}

void main()
{
    foo(5); /* works */
    int y = 5;
    foo(y); /* error */
}
----

My fault, I should have better explained the situation I'm running into. I've boiled it down to this:

[code]
struct Foo
{
    @disable this(this);
    @disable void opAssign(ref Foo);
    void opAssign(Foo foo) {}
}

unittest
{
    void bar(Foo foo)
    {
        Foo foo1;
        foo1 = foo; // Fails to compile here
    }
    Foo makeFoo() {return Foo();}
    bar(Foo());
}
[/code]

[output]
Error: function Foo.opAssign is not callable because it is annotated with @disable
[/output]

Note that if I don't declare and assign foo1 on separate steps it yells at me for the post-blit constructor being disabled, which is reasonable. But it seems like the rvalue assignment operator should work...

Reply via email to