foreach of classes

Lucien via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 9 03:10:19 PDT 2016


Hello.

When I do:

---------------------
class MyClass{..}
class YourClass{..}
class OurClass{..}

YourClass yc = new YourClass();

foreach (auto id; [ typeid(MyClass), typeid(YourClass), 
typeid(OurClass) ])
{
   if (typeid(yc) == id)
   {
     writeln("It works !");
   }
}
---------------------
The compiler says: basic type expected, not auto
Why can't I have one time the type id of MyClass, then of 
YourClass and of OurClass ?
Is there an alternative ?


More information about the Digitalmars-d-learn mailing list