Static function template

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 7 04:28:23 PDT 2015


On Thursday, 7 May 2015 at 10:19:44 UTC, Lemonfiend wrote:
> 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)'

Another thinks which is wierd is than on 2.066 it prints:

test.d(17): Error: need 'this' for 'foo' of type 'pure nothrow 
@nogc @safe void(int j)'

So it seems auto deduction for attributes does not work anymore 
:( (in this case I guess)


More information about the Digitalmars-d-learn mailing list