array depth template

Jarrett Billingsley jarrett.billingsley at gmail.com
Thu Jun 11 21:01:38 PDT 2009


On Fri, Jun 12, 2009 at 12:04 AM, Saaa<empty at needmail.com> wrote:
>>
>> template BaseType(T: T[]) { const BaseType = BaseType!(T); }
>> template BaseType(T) {const BaseType = T; }
>
> ..
> else static if( std2.traits.isNumeric!( BaseType!(T) ) )
> {
> ..
>
> ddata\ddata.d(192): template instance isNumeric!(int) does not match any
> template declaration
> ddata\ddata.d(192): Error: expression isNumeric!(int) is not constant or
> does not evaluate to a bool
>
> What am I doing wrong?

Your template.  Types are not values, you cannot declare a constant
that is a type.  You have to use alias instead:

template BaseType(T: T[]) { alias BaseType!(T) BaseType; }
template BaseType(T) { alias T BaseType; }


More information about the Digitalmars-d-learn mailing list