Associative arrays can't have a static array as key
Michiel
nomail at hotmail.com
Thu Feb 8 06:43:07 PST 2007
I have a template function like this:
void foo(T)(T bar) {
int[T] bla;
/* more code */
}
And I occasionally want to call it with a string literal.
foo("test");
But the compiler sais I can't, because "test" is of type char[4], and
apparently associative arrays can't take a static array as key.
This isn't documented. In fact, the documentation says that type[dim] can be
implicitly converted to type[].
But putting that aside for the moment, how can I convince D to automatically
make it a dynamic array, so I can use my function?
Thanks!
More information about the Digitalmars-d
mailing list