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

realhet real_het at hotmail.com
Sat Jun 8 21:16:14 UTC 2019


Hi, I'm googling since an hour but this is too much for me:

class A{}
class B:A{}

void foo(...){
   if(_arguments[0]==typeid(A)){
     //obviously not works for B
   }
   if(_arguments[0] ???? is_a_descendant_of A){
     //how to make it work for both A and B?
   }
}

----------------------------------

Also I tried to write a funct to compare classes by TypeInfo, but 
the TypeInfo.next field is not works in the way as I thought. It 
gives null, so the following code doesn't work.

auto isClass(C)(TypeInfo i){
   if(i==typeid(C)) return true;
   auto n = i.next;
   return n is null ? false : n.isClass!C;
}

I just wanna check if a compile_time _argument[0] is a descendant 
of a class or not.

I also tried (is : ) but without luck.

Thank you.



More information about the Digitalmars-d-learn mailing list