Mixin Problems with D2.0

Simen Kjaeraas simen.kjaras at gmail.com
Thu Mar 6 04:47:17 PST 2008


On Thu, 06 Mar 2008 13:32:57 +0100, Brian White <bcwhite at pobox.com> wrote:

>> The problem is that "Foo" and "bar", as D strings, are  
>> invariant(char)[], not char[].
>>  The solution is to change the template to
>>
>>> template GenStruct(const char[] Name, const char[] M1)
>
> Got it.  Why not declare them "invariant char[]", or does it simply make  
> no difference?
>
> -- Brian

Both char[] and invariant(char)[] are implicitly castable to  
const(char)[]. Had you for some reason done something like this:

template GenStruct(const char[] Name, const char[] M1)
{
   //stuffs
}

char[] myString1 = "Foo";
char[] myString2 = "bar";

GenStruct!(myString1, myString2); // error here, char[] not implicitly  
castable to invariant(char)[]

-- Simen


More information about the Digitalmars-d-learn mailing list