mtaching types with static if

Nicholas Wilson iamthewilsonator at hotmail.com
Sun Oct 1 07:03:42 UTC 2017


struct ArrayAccesssor(alias ptr, alias len) {}

char * p;
size_t len;

ArrayAccesssor!(p,len) aa;

template helper(Fields...)
{
     static if (Fields.length == 0)
         enum helper = "";

     else static if (is(typeof(Fields[0]) : 
ArrayAccesssor!(ptr,len),ptr, len)) //13
     {
         pragma(msg, "ArrayAccesssor");
         enum helper = helper!(Fields[1 .. $]);
     }
     else
     {
         pragma(msg, "else");
         enum helper = helper!(Fields[1 .. $]);
     }
}

enum f = helper!(aa,len);

What is the correct line 13 to make the instansiation of 
`helper!(aa,len)` print

ArrayAccesssor
else

?

Thanks
Nic


More information about the Digitalmars-d-learn mailing list