inner templates?

BCS ao at pathlink.com
Fri May 25 09:57:46 PDT 2007


Reply to dennis,

> hi
> 
> i've try to write an template wich calculates e
> 
> ok here it is - but wait i need a helper template to reduce the
> interface to my needs (just to adjust the precision) - is there any
> way getting rid of these helper template (maybe an inner-template or
> something)?
> 
> 
> ciao dennis
> 

Is this of use?

import std.stdio;
private template e_help(double p, double s, double f, int n)
{
static if( s > p )
const e_help = e_help!(p, s/n,f+s/n,n+1);
else
const e_help = f;
}

public const double e = e_help!(1e-14, 1, 1, 1);

void main()
{
writefln("e: ", e);
}





More information about the Digitalmars-d mailing list