On Friday, 11 October 2013 at 04:13:55 UTC, Agustin wrote:
I have a function that needs to check if the template provided inherit a class.

For example:

public void function(T, A...)(auto ref A values)
{
  // static assert(IsBaseOf(L, T));
}

Check if T inherit class "L". Same result that std::is_base_of<L, T>::value using C++. Any clean way to do it, without a dirty hack.

import std.traits;

bool ChildInheritsFromParent( parent, child )( ) {
        
        foreach ( k, t; BaseClassesTuple!child ) {
                if( typeid(t) == typeid(parent) )
                        return true;
        }
        return false;
}

Reply via email to