[Issue 16093] Trivial case of passing a template function to another template function doesn't compile
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun May 29 11:08:36 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16093
--- Comment #2 from Max Samukha <maxsamukha at gmail.com> ---
(In reply to b2.temp from comment #1)
> It's because f is local. When f is static (i.e like a free function) it works
>
void main() {
int x = 1;
void f() {
x += 1;
}
bar!f(); // ok
}
'f' above is local, and the compiled program works as expected. Can't see why
making it a template should affect the semantics. Also, if the following didn't
compile, the whole "pass functions by alias" business would go down the drain:
void bar(alias f)() {
f(1);
}
void main() {
int y = 1;
alias f = (x) { y += x; }; // local, equivalent to "void f(A)(A x) { y +=
x; }"
bar!f(); // ok
}
--
More information about the Digitalmars-d-bugs
mailing list