On Wed, Jan 21, 2009 at 10:30 AM, Qian Xu <[email protected]> wrote: > Hi All, > > can D check, whether a class A an Interface B supports? > > like: > > if (supports(class_A, intf_B)) > { > cast(intf_B) (class_A).hello(); > }
At compile time, like Frits said, you can use is(class_A : intf_B).
At runtime, you can use cast(intf_B)someInstance. That returns 'null'
if someInstance does _not_ inherit from intf_B.
if(auto i = cast(intf_B)instanceOfA)
i.hello();
