On Thursday, 30 January 2020 at 15:14:43 UTC, ShadoLight wrote:
Is there a technical reason for this limitation? Why are the
'classical' invocation style not allowed for eponymous
templates as well?
It seems somewhat arbitrary - note that inner/outer functions
does not have this limitation - the fllowing is legal and
compiles (and does not lead to infinite recursion):
I guess the intention is to e.g. allow UFCS on the return values
of templated functions without ambiguities, e.g.:
void main()
{
import std.algorithm, std.stdio;
int[] values = [ 1, 2, 3, 4 ];
values.filter!(i => i % 2 == 0)
.map!(i => i / 2) // Does not refer to any hidden
member of template filter
.each!writeln;
}
From my POV is
void foo(T)() { ... }
just a shorthand notation for
template foo(T)
{
void foo() {}
}
allthough it could probably use some improvements to the
documentation.