Using implicit template properties, one can define const arrays of a template type. For example
template cstr(T)
{
alias const(T)[] cstr;
}
Such a construct could be used to refer to a constant array of char, wchar, or dchar in a template instantiation of string functions.
However, the compiler does not implicitly understand how to instantiate templates based on this. It will compile if you use the type it is aliased to directly. For example:
void foo1(T)(cstr!(T) arg)
{
}
void foo2(T)(const(T)[] arg)
{
}
void main()
{
static assert(typeid(cstr!(char)) is typeid(const(char)[])); // OK
foo1("hello"); // cannot deduce arguments
foo2("hello"); // OK
}
both foo1 and foo2 should compile the same as there arguments are the same. I'm not sure if this is possible however, because you need to reverse the template to figure out the correct template to instantiate so it can match the arguments.
Comment #1 by schveiguy — 2008-11-14T14:00:29Z
This would be solved by the more general bug 1807, which is why this should be the duplicate bug, even though I reported it earlier.
*** This bug has been marked as a duplicate of 1807 ***