Static function template

Lemonfiend via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 7 03:19:42 PDT 2015


Is it not possible to have a static function template with the 
same name as the non-static version?

struct S
{
     int i;

     auto foo(T)(int j) {
         i=j;
     }

     static auto foo(T)(int j) {
         S s;
         s.foo!T(j);
         return s;
     }
}

void main()
{
     auto s = S.foo!bool(1);
}

Error: need 'this' for 'foo' of type '(int j)'


More information about the Digitalmars-d-learn mailing list