On Monday, 8 June 2020 at 04:13:08 UTC, Mike Parker wrote:
[snip]
The problem isn't the mixin. It's the template. Templates take
the scope of their declaration, not their instantiation. So the
mixin is getting the template's scope.
Anyway, this appears to work:
`double z = foo!"std.math.fabs"(x);`
Thanks, that makes sense.
However, I get the same error with the code below. Am I doing
something wrong?
double foo(alias f)(double x) {
return f(x);
}
template foo(string f)
{
mixin("alias foo = .foo!(" ~ f ~ ");");
}
void main() {
static import std.math;
double x = 2.0;
double y = foo!(std.math.fabs)(x);
double z = foo!"std.math.fabs"(x);
}