Code behaves incorrectly if it is compiled in std.functional
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jun 4 19:38:37 PDT 2015
here's dustmited source:
template unaryFun(alias fun, string parmName="a") {
static if (is(typeof(fun)))
auto unaryFun(ElementType) (auto ElementType __a) {
mixin("alias " ~ parmName ~ " = __a ;");
return mixin(fun);
} else static if (needOpCallAlias) {
unaryFun fun;
}
}
unittest {
cast(void)unaryFun!"a+1"(41); // silence warning
}
unittest {
struct Foo2 {
int fun (int n) pure nothrow @safe @nogc { return n; }
}
import std.traits;
pragma(msg, ParameterTypeTuple!(typeof(Foo2.fun)));
}
# dmd -c -o- -unittest test.d to see `(auto int)`
note that after removing any attribute from `Foo2.foo` will emit
correct `(int)`.
More information about the Digitalmars-d
mailing list