Re: Memoizing a templated function

2012-04-16 Thread bearophile
ixid: Memoizing a templated version of a function doesn't seem to work, A template isn't a function, it's just a recipe to define a function given one or more compile-time values or types. So memoize works if you instantiate in some way the template: import std.functional; int test(int n)

Re: Memoizing a templated function

2012-04-16 Thread Andrej Mitrovic
On 4/17/12, ixid wrote: > Memoizing a templated version of a function doesn't seem to work, > how would I do it properly? Instantiate the template first. Either: n = memoize!(test2!int)(n); or: alias test2!int itest; n = memoize!itest(n); Actually I'm a little surprised this doesn't work: mem