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)'
Can be fixed by using of different names for static and
non-static function.
Not sure why doesn't work w/o this change (compiler bug?)
struct S
{
int i;
auto foo2(T)(int j) {
i=j;
}
static S foo(T)(int j) {
S s;
s.foo2!T(j);
return s;
}
}
void main()
{
auto s = S.foo!bool(1);
}