Proper way to handle "alias this" deprecation for classes

Inkrementator invalid at email.com
Wed May 10 14:42:50 UTC 2023


On Sunday, 7 May 2023 at 21:12:22 UTC, Chris Piker wrote:
> On the other hand, your first suggestion of using opCast() does 
> seem like a reasonable choice to me.  Can you provide a short 
> code snippet using opCast to achieve the same result?

I've never used it, and particularly I know that I don't know 
whether making the the return type of opCast ref can lead to 
issues down the road and whether the template specialization is 
dangerous, as it will trigger for all types implicitly 
convertible to int* (whatever they are)

Another potential future pitfall I discovered is that code might 
break if you change your class into a struct.

Code example is in a gist since the system thinks I've added HTML 
entities to it and won't let me post it:

https://gist.github.com/run-dlang/9b7aec72710b1108fc8277789776962a


More information about the Digitalmars-d-learn mailing list