Jonathan Wakely wrote:

I believe Andrew's right and the strcpy case is valid, but you do have
a point. I think this should be rejected:

struct A { int i; };
struct B { A get() { return A(); } };

int main ()
{
    B b;
    b.get().i = 0;
    // int& error = b.get().i;
}

What about something like the following?

struct proxy { T& t;
   proxy(T& t_) : t(t_) {}
   proxy& operator=(const T& r) { foo(t, r); return *this; }
};

struct B { proxy get() { return proxy(bar); } };

int main ()
{
   B b;
   b.get() = 0;
}


jonathan.

Reply via email to