Proper way to handle "alias this" deprecation for classes

Chris Piker chris at hoopjump.com
Sun May 7 21:12:22 UTC 2023


On Sunday, 7 May 2023 at 21:04:05 UTC, Inkrementator wrote:
> On Sunday, 7 May 2023 at 18:19:04 UTC, Ali Çehreli wrote:
>> alias this is for implicit type conversions, which can be 
>> achieved explicitly as well.
>
> Open question to everybody: What you're opinion on using opCast 
> for this? Since it's a type conversion, it seems fitting to me.
>
> And another suggestion: Wrap the class in a struct that has 
> visibility on the class members via the "package" access 
> specifier and continue using "alias this".

Hi Inkrementator

In this case, ResponseContainer is already a wrapper structure, 
so on the surface, putting a wrapper on a wrapper feels like 
over-engineering.

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?






More information about the Digitalmars-d-learn mailing list