Traits

luminousone rd.hunt at gmail.com
Fri Oct 11 02:49:51 PDT 2013


On Friday, 11 October 2013 at 09:37:33 UTC, Jacob Carlborg wrote:
> On 2013-10-11 07:49, luminousone wrote:
>
>> import std.traits;
>>
>> bool ChildInheritsFromParent( parent, child )( ) {
>>
>>     foreach ( k, t; BaseClassesTuple!child ) {
>>         if( typeid(t) == typeid(parent) )
>>             return true;
>>     }
>>     return false;
>> }
>
> That will perform a runtime check and not a compile time check.

Is is just the typeid call that makes it unable to be ran at 
compile time or is their something else wrong in their?,

Would a string compare with type.classInfo.name fix that, or is 
their not a tool yet in place for that?


More information about the Digitalmars-d-learn mailing list