isInstanceOf from std.traits seems to not work with class the way I need to. I'd like to make a template function accepts only class of a specified class type

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
{
  // ...
}

Reply via email to