xxxxxxxxxx
import std.stdio;
struct MyType(T) {
static if (is (T == float)) {
alias ResultType = double;
} else static if (is (T == double)) {
alias ResultType = real;
} else {
alias ResultType = void;
static assert(false, T.stringof ~ " is not supported");
}
ResultType doWork() {
writefln("The return type for %s is %s.",
T.stringof, ResultType.stringof);
ResultType result;
// ...
return result;
}
}
void main() {
auto f = MyType!float();
f.doWork();
auto d = MyType!double();
d.doWork();
auto g = MyType!string();
g.doWork();
}