Templated Interfaces?

Ary Borenszweig ary at esperanto.org.ar
Tue Aug 26 18:18:47 PDT 2008


Jarrett Billingsley a écrit :
> "Jarrett Billingsley" <kb3ctd2 at yahoo.com> wrote in message 
> news:g911lg$ja5$1 at digitalmars.com...
>> "Ary Borenszweig" <ary at esperanto.org.ar> wrote in message 
>> news:g8vp2l$11nf$1 at digitalmars.com...
>>> Ouch. I first wrote
>>>
>>> I!(char)[3] array = new I!(char)[3];
>>>
>>> which compiles, and makes array a static array (you can't append to it). 
>>> Then, for simplicity, I changed the type to auto... it seems new makes a 
>>> dynamic array, but then it is implicitly converted to a static one, 
>>> right?
>> No.  When you write
>>
>> auto x = Y;
>>
>> it is identical to writing
>>
>> typeof(Y) x = Y;
>>
>> In this case, typeof(new I!(char)[3]) is I!(char)[].  A dynamic array.
>>
> 
> Unless you meant in the non-auto case?  In which case I'm kind of surprised 
> the compiler allows it since it normally does not allow you to reassign 
> static arrays. 

Exactly, I meant in the non-auto case. What's going on there?


More information about the Digitalmars-d-learn mailing list