function overload with mixin template bug?

Patric Dexheimer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 17 06:13:06 PDT 2017


1)

struct T{
     void f1(){writeln("default f1");}
     void f1(int x){writeln("overload f1");}
}
//main
T().f1();
T().f1(1);
//compiles and output as expected.


2)

mixin template add_function(){
     void f1(){writeln("default f1");}
}
struct T{
     mixin add_function;
     void f1(int x){writeln("overload f1");}
}
//main
T().f1();
T().f1(1);
//Error: function f355.T.f1 (int x) is not callable using 
argument types ()
/* What? i´m missing something here? */


3)

mixin template add_function(){
     void f1(){writeln("default f1");}
}
struct T{
     mixin add_function;
}
//main
T().f1();
//compiles and output as expected.


Function overloads coming from mixin templates are not being 
detected ?




More information about the Digitalmars-d-learn mailing list