detect implicitly convertible typeid's?

Steven Schveighoffer schveiguy at yahoo.com
Mon Sep 25 13:20:03 UTC 2017


On 9/23/17 11:52 AM, bitwise wrote:
> Is it possible to tell if two objects represented by TypeInfo's are 
> convertible to each other?
> 
> Basically, is there a built in way to do this?
> 
> int x;
> long y;
> assert(typeid(x).isImplicitlyConvertibleTo(typeid(y));

I would say no. There isn't any function/data to detect that.

Keep in mind that TypeInfo is generated by the compiler, and only 
contains what the developers of the runtime have wanted it to contain. 
It's not a full-fledged reflection system.

However, you COULD build something in RTInfo that could place that 
inside the TypeInfo. That is what RTInfo was added for.

-Steve


More information about the Digitalmars-d-learn mailing list