class A { } class B : A { } class C : A { }
import std.traits : isInstanceOf; int f(T)(in A[int] arr) if(isInstanceOf!(A, T)) // doesn't work for class from what I saw { foreach(c; arr) { if((cast(A)c) !is null) { } } // ... } int f(T)(in A[int] arr)if(cast(T) !is null) // run time this is ok but not at compile time
{ // ... }