check if _argument[0] is a descendant of a specific class.

realhet real_het at hotmail.com
Sat Jun 8 22:14:45 UTC 2019


On Saturday, 8 June 2019 at 21:25:41 UTC, Adam D. Ruppe wrote:
> On Saturday, 8 June 2019 at 21:24:53 UTC, Adam D. Ruppe wrote:
>> _arguments is a compile time construct, it is a run time thing.
>
> err i meant is *NOT* a compile time construct

Thank You for the fast help!

At first I was happy to find the variadic example and didn't even 
realized, that was the runtime version.

Now it works correctly with the base class check, and also it is 
now static and fast:

     static foreach(a; args){
       static if(is(typeof(a)==string)){
         //...
       }else
       static if(is(typeof(a) : Cell)){
         if(a !is null){
           //...
         }
       }else
       static if(is(typeof(a)==TextStyle)){
         //...
       }else{
         static assert(0, "Unsupported type: "~typeof(a).stringof);
       }
     }



More information about the Digitalmars-d-learn mailing list