other array types than char in templates?

Reiner Pope some at address.com
Tue May 29 13:58:07 PDT 2007


dennis luehring wrote:
> what is the reason for allowing this
> 
> template test(char[] bla)
> {
> ...
> }
> 
> 
> but not
> 
> template test(int[] bla)
> {
> ...
> }
> 
> or other bultin(own) types?
> 
> ciao dennis

I agree that it doesn't make sense, but you can do this hack:

template test(T...)
{
     static assert(is(typeof(T[0]) == int[]));
     const int[] bla = T[0];
}


    -- Reiner



More information about the Digitalmars-d mailing list