Function signature testing with is expression.
Alexandru Ermicioi
alexandru.ermicioi at gmail.com
Sun Dec 17 14:44:15 UTC 2017
Hi,
Have someone tried to test a function against a signature using
is expression?
Suppose:
--------
struct F {
static void foo(T)(T i, int o) {}
}
enum bool check(T) = is(F.foo!T == void function(Z, int), Z);
enum correct = check!int;
--------
Upon running it will return false, though, by logic is expression
could deduce that F.foo is conformat to function signature in
check test.
It is interesting that it will not work with global functions as
well:
--------
void foo(int i, double d) {};
enum bool check = is(typeof(foo) == void function(int, double));
--------
It will be as well evaluated to false.
So, the question is, is it I'm doing something wrong, that it
doesn't work, or is it not implemented?
If not implemented, what simple and short alternatives are
available?
Thanks.
More information about the Digitalmars-d-learn
mailing list