Class info on interfaces

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 26 12:01:49 PDT 2015


On 08/26/2015 11:59 AM, Adam D. Ruppe wrote:
> On Wednesday, 26 August 2015 at 18:53:19 UTC, Jacob Carlborg wrote:
>> Is that intentional? Perhaps because of COM and C++ interfaces?
>
> Yes, exactly. COM and C++ things won't necessarily have a D TypeInfo
> available and since interfaces can be them, it can't be sure.
>
> What I do there is to just cast the interface to Object. Then you should
> check for null to cover those cases, then you can typeid or classinfo it.

To complete, the documentation says ".classinfo applied to an interface 
gives the information for the interface, not the class it might be an 
instance of."

   http://dlang.org/property.html#classinfo

Ali



More information about the Digitalmars-d-learn mailing list