[Issue 19517] Spurious compiler warning with const toHash and alias this classes
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 13 18:49:11 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=19517
--- Comment #2 from hsteoh at quickfur.ath.cx ---
Found this (partial) workaround:
------
class C { /* ... */ }
struct S
{
C c;
auto opDispatch(string field)() inout
{
return mixin("c."~field);
}
}
------
The key here is the `inout`.
This works as long as you don't expect to implicitly convert S to C. You can
access class fields as if they were fields in S.
For implicit conversion, though, I haven't come up with a good workaround yet.
--
More information about the Digitalmars-d-bugs
mailing list