std.typecons.Proxy + inheritance breaks cast'ing to inherited type

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 16 22:32:49 PDT 2015


On 03/16/2015 04:59 PM, Lukasz Wrzosek wrote:
> Bug reported as
> https://issues.dlang.org/show_bug.cgi?id=14298

Thanks...

I have carried the discussion over to the main newsgroup:

   http://forum.dlang.org/thread/me8e0a$1kp6$1@digitalmars.com

As I mention there, there is a workaround: Add a catch-all opCast to the 
class in question, which can simply forward to the all-powerful std.conv.to:

     T opCast(T)()
     {
         import std.conv;
         return this.to!T;
     }

Now it compiles and works as expected.

Ali



More information about the Digitalmars-d-learn mailing list