[Issue 6777] alias this disables casting for classes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 7 09:13:28 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=6777

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com

--- Comment #12 from Walter Bright <bugzilla at digitalmars.com> ---
The problem comes from the idea that having an alias this means that operations
not supported by the class get forwarded to the alias this. Since opCast() can
override what explicit casts do for a class reference, the alias this needs to
be respected (even if it doesn't provide an opCast(), it still can be cast).

The current behavior seems an inevitable consequence of that.

Using alias this in a class may not be a good practice.

--


More information about the Digitalmars-d-bugs mailing list