(this MyType) automatic deduction?

andre via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 8 03:36:32 PDT 2014


Hi,

could you check whether it is correct, that second line in main
failes with a compiler error?
I think the compiler should be able to deduce the type without
explicitly passing it to the method call.

Kind regards
André

template ClassTemplate()
{
   static auto deserialize(this MyType)()
   {
     return new MyType();
   }
}

class A
{
   mixin ClassTemplate;
}

void main()
{
   A a = A.deserialize!A(); // Working
   A b = A.deserialize(); // Not working
}

source\app.d(17): Error: template 
app.A.ClassTemplate!().deserialize cannot dedu
ce function from argument types !()(), candidates are:
source\app.d(3):        app.A.ClassTemplate!().deserialize(this 
MyType)()


More information about the Digitalmars-d-learn mailing list