Method-call based on template argument

2012-05-09 Thread nrgyzer
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

Re: Method-call based on template argument

2012-05-09 Thread sclytrack
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

Re: Method-call based on template argument

2012-05-09 Thread nrgyzer
Hm... yes - works. I simply rewrote my method-header and it just works, too... but thanks :)