I'm trying to do the following:
module myModule;
int calculate(T)(int a, int b) if(T == add) {
return a + b;
}
int calculate(T)(int a, int b) if(T == subtract) {
return a - b;
}
But when I try to run the following code, I get template myModule.calculate
does not match any function
On 05/09/2012 12:33 PM, nrgyzer wrote:
void main() {
int a = 10;
int b = 20;
std.stdio.writeln(calculate!(add)(a, b));
std.stdio.writeln(calculate!(subtract)(a, b));
}
Below works
---
import std.stdio;
int calculate(string T)(int a, int b) if(T == add)
{
return
Hm... yes - works. I simply rewrote my method-header and it just works, too...
but thanks :)