Associative arrays can't have a static array as key

Jarrett Billingsley kb3ctd2 at yahoo.com
Thu Feb 8 07:17:20 PST 2007


"Michiel" <nomail at hotmail.com> wrote in message 
news:eqfeid$8mt$1 at digitaldaemon.com...
>> foo("blah"[]);
>>
>> Notice the slice operator.  This converts the static array into a dynamic
>> one.  Kind of ugly, but.
>
> Hm.. Yes. That works. But I was hoping for a solution inside the function
> definition, so i could still use regular string literals.

import std.traits;

void foo(T)(T bar)
{
    static if(isStaticArray!(T))
        int[typeof(T[0])[]] bla;
    else
        int[T] bla;
    // ...
}

void main()
{
    foo("hi");
}


 :) 





More information about the Digitalmars-d mailing list