On 01.09.2016 19:21, Meta wrote:
...
I just thought of this, but cannot test if it works. If it does, maybe
it would be a suitable solution?
void f(T)(T t) if(isSomething!T) {}
void f(T)(T t) if(isSomethingElse!T) {}
//Taken if no other "overload" of f will intantiate with the given T
void f(T)(T t) if(!__traits(compiles, alias _ = .f!T)) {}
It shouldn't work, but DMD currently seems to allow it. (If you fix the
syntax error.) I would expect it to break later.
The following causes an ICE (DMD segfaults).
import std.stdio;
int f(T)(T t) if(!__traits(compiles,.f!T)) {
return 0;
}
int f(T)(T t) if(!__traits(compiles,.f!T)) {
return 1;
}
void main(){
writeln(f(2));
}