On 09/04/2010 10:41 AM, Steven Schveighoffer wrote:
Andrei Alexandrescu Wrote:
On 9/3/10 16:03 CDT, bearophile wrote:
JMRyan:
Is this a bug in the compiler (v.2.047)? Am I missing something in
thinking it shouldn't be?
I think it's not a bug. It's not a common need, but a method may way want to
swap this with another. In Phobos this is done on a struct, see:
http://www.dsource.org/projects/phobos/browser/trunk/phobos/std/stdio.d#L324
Bye,
bearophile
For classes this must be an rvalue.
Andrei
Should this work?
class C
{
int x;
void opAssign(int n) {x = n;}
void foo(int n) {this = n;}
}
I agree this should not be rebindable. But it has to be an lvalue.
-Steve
The example should work, but doesn't need this to be an lvalue.
Andrei