AA specialization not works

Stewart Gordon smjg_1998 at yahoo.com
Mon Sep 24 18:08:25 PDT 2007


"JdavidLS" <jdavidls at gmail.com> wrote in message 
news:fd9frq$2rtg$1 at digitalmars.com...
<snip>
> template _ArraySpec(A: A[C], const uint C) // Error: variable C foward 
> referenced

Yes, DMD has lots of bugs like that.

<snip>
> // Specialization for dinamic array:
> template _ArraySpec(A: A[])
> {
>  alias A.length length;
>  alias typeof(A[0]) Type;
>  alias uint Key;
> }
<snip>
>  //  error: does not match any template declaration:
>  alias _ArraySpec!(static_array) _staticArray;

Your template takes as parameter a type, not a variable.

But if I change it to

    alias _ArraySpec!(typeof(static_array)) _staticArray;

then it still fails, because A.length becomes uint.length, and there's no 
such thing.

I'm not sure if there's an easy way to do what you're trying to do.  You 
might need to depart from template specialisations and use static ifs 
instead.  It's a shame we don't seem to have ITTI (implicit template 
template instantiation).

<snip>
>    //  for static array:
>    static if(is(T A: A[K], const uint K)) //  Error: found',' when 
> expecting ')'
<snip>

Which version of (DM)D are you using?  You seem to be using D 2.x-specific 
syntax, which won't work in a D 1.x compiler.

Stewart.

-- 
My e-mail address is valid but not my primary mailbox.  Please keep replies 
on the 'group where everybody may benefit. 




More information about the Digitalmars-d mailing list