This D2 program compiles and works correctly: import std.c.stdio: printf; auto add(T1, T2)(T1 x, T2 y) { if (!is(T1 == T2)) printf("Different types\n"); return x + y; } void main() {}
But do you know why D2 needs that is() there? Can't it be removed, like this? (doesn't work): import std.c.stdio: printf; auto add(T1, T2)(T1 x, T2 y) { if (T1 != T2) printf("Different types\n"); return x + y; } void main() {} The difference for the programmer is not big, but the second is a little shorter/cleaner. Bye and thank you, bearophile