Static typing loop

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Dec 25 18:36:36 PST 2007


"bearophile" <bearophileHUGS at lycos.com> wrote in message 
news:fkscv5$2js8$1 at digitalmars.com...

> class Foo1(T, int n=10) {
>    Foo1!(T[], 20) f;
> }

Add a specialization for array types.  Or, better yet, specialize using a 
static if.

template isArrayType(T) { const isArrayType = false; }
template isArrayType(T : T[]) { const isArrayType = true; }

class Foo1(T, int n = 10)
{
    static if(isArrayType!(T))
    {
        // dependent data members declared as T
    }
    else
    {
        // dependent data members declared as T[]
    }
}

Your code looks odd, I'm not entirely sure what you're trying to do; I'm 
assuming it's that it's a very reduced example. 




More information about the Digitalmars-d-learn mailing list