> foreach (I i; array) { > if (B b = cast(B) i) { ... } > } Thanks all 3 of you for the quick and identical answers. :) It had not occurred to me to use a cast for this, but indeed the language ref says the same: "In order to determine if an object o is an instance of a class B use a cast" It does a bit inelegant to me.. Or are casts simply extremely cheap?