static if check for array and AA

Bruno Medeiros brunodomedeirosATgmail at
Fri Jun 23 17:16:48 PDT 2006

Sean Kelly wrote:
> Oskar Linde wrote:
>> In article <e7djp7$42g$1 at>, Kirk McDonald says...
>>> It turns out the above template fails because "is(typeof(T.init[0]))" 
>>> fails, as it doesn't describe a valid type. (You can't subscript an 
>>> int!)
>> Yes. I've been reporting this a couple of time, but never gotten any 
>> (official)
>> response on whether this is the intended behavior. Static arrays are 
>> the only type for which typeof(T.init)
>> != T.
> This is also somewhat close to implementation-specific behavior.  I'd 
> prefer to have a more formal means of detecting static arrays.
> Sean

I'm not sure that is implementation-specific behavior. I suspect that 
that is related to the fact that static arrays are the only type that 
cannot be assigned to a value of the same type (sar1 = sar2).
So in order for something like this:
   T sar = T.init ;
to work for all types, then T.init had to an element of the static array.
I think that all of this (arrays not being proper value types) is pretty 
inconsistent, although most of us are so used to C and C++ that we don't 
even notice or are bothered by it

Bruno Medeiros - CS/E student

More information about the Digitalmars-d mailing list