IFTI Bug
Derek Parnell
derek at nomail.afraid.org
Sun Jul 9 22:37:51 PDT 2006
On Mon, 10 Jul 2006 00:14:36 -0500, Kramer wrote:
> What would I need to do so IFTI would be invoked?
// ------------------
import std.stdio;
void main()
{
writefln(factorial(2));
}
template factorial(T)
{
T factorial(T n)
{
if (n <= 1)
return cast(T)1;
else
return cast(T)( n * factorial(n-1));
}
}
// ------------------
The example you gave at first was using a template to generate a
compile-time literal. To turn that into a template that generates a
function instead, you need to define the function inside the template. If
you give it the same name as the template, IFTI becomes easier to use too.
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
10/07/2006 3:33:48 PM
More information about the Digitalmars-d-bugs
mailing list