Hi! How I can return from function a reference to int? Here is a
simple code, to demonstrate my problem:

struct Foo {
public:
        @property int foo() const
        {
                return x_;
        }
        
        @property ref int foo(int value)
        {
                x_ = value;
                return x_;
        }
        
private:
        int x_;
}


void main()
{
        auto f = Foo;
        f.foo += 5;
}


When I try to build this code, I get the error at line "f.foo +=
5" with message: "Error: f.foo() is not an lvalue". I thought the
ref qualifier causes the compiler to return a reference in that
case.

Reply via email to