Proper way to handle "alias this" deprecation for classes
Ali Çehreli
acehreli at yahoo.com
Sun May 7 21:23:02 UTC 2023
On 5/7/23 13:44, Chris Piker wrote:
> to fix the problem I
> just delete the alias this line from dpq2, see what unit tests and app
> code it breaks, then fix each of those.
Yes but I neglected the lvalue/rvalue issue. In some cases the code
won't compile if the return type of the newly written explicit function
is not 'ref'. For example, the 'ref' below is essential for the
following use case:
class C {
int* result;
// HERE
ref asIntPtr() {
return result;
}
}
auto main() {
auto c = new C();
int i;
c.asIntPtr = &i;
assert(c.result == &i);
}
> "Programming in D" for a bright young programming
> student I know in appreciation.
Very kind of you! :)
Ali
More information about the Digitalmars-d-learn
mailing list