Why simple code using Rebindable doesn't compile ?

chmike via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 30 03:09:19 PDT 2016


This code compile, but array appending doesn't work

----
alias Rebindable!(immutable(InfoImpl)) Info;

class InfoImpl
{
     void foo() {}
     static immutable(InfoImpl) info()
     {
         __gshared immutable InfoImpl x = new immutable InfoImpl;
         return x;
     }
}


void main()
{
     Info t = Info.info;
     Info[] a;
     //a ~= Info.info; <--  KO Compiler Error
     a ~= rebindable(Info.info); // Ok
}
-----

Why can't info() return a Rebindable!(immutable(InfoImpl)) ?


More information about the Digitalmars-d-learn mailing list