[phobos] phobos commit, revision 2123

Lars Tandle Kyllingstad lars at kyllingen.net
Fri Nov 5 06:11:01 PDT 2010


So it's not only weird, it's actually wrong, since A[0] does in fact
have a sensible meaning...

Anyway, this shows that the compiler does not interpret it as a static
array type inside the typeof():

        template Elem(T)
        {
                alias typeof(T[0]) Elem;
        }
        
        static assert (is(Elem!(int[]) == int));

-Lars



On Fri, 2010-11-05 at 06:01 -0700, Steve Schveighoffer wrote:
> A[0] is a static array of A's of size 0.  However, I'm not sure why it ever 
> passes, because typeof(X) where X is already a type should fail, I think?
> 
> -Steve
> 
> 
> 
> ----- Original Message ----
> > From: Lars Tandle Kyllingstad <lars at kyllingen.net>
> > 
> > I noticed something funny when fixing this.  In the template  constraint
> > for back(), is(typeof(A.init[0])), is used to check whether the  type A
> > supports indexing.  This makes sense.  In the constraint for  front(),
> > however, is(typeof(A[0])) is used.  Does anyone know why this  last case
> > works at all?  Outside of typeof(), A[0] is completely  meaningless
> > unless A is a tuple, so why allow this special  case?
> > 
> > -Lars
> 
> 
> 
>       
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos




More information about the phobos mailing list