alias this versus opDot
Ali Çehreli
acehreli at yahoo.com
Sun Nov 11 14:09:51 PST 2012
On 11/11/2012 12:38 PM, Namespace wrote:
> I have this code: http://dpaste.dzfl.pl/131ca7e9
> Why I get these error messages if I try to use a @property method with
> alias this? And why it works fine if I use opDot?
For what it's worth, this combination compiles:
/* returns immutable(T) but 'this' is inout */
@property
immutable(T) get() inout pure nothrow {
return this._val;
}
alias get this;
/* ... */
void foo(immutable A a)
{}
void main() {
Unique!(A) uni = new A();
foo(uni);
}
Ali
More information about the Digitalmars-d-learn
mailing list