On 8/13/15 2:25 PM, Iain Buclaw via Digitalmars-d wrote:


class A { invariant { } }
class B : A { }
class C : B { invariant { } }

B b = new C();  // We can only discover that 'b' is a C object at runtime.

    I thought invariant was like ctor/dtor, the most derived
    automatically calls the base version.


Nope, it only calls it's own invariants.  Calling all derived invariants
is what _d_invariant is for.

I envisioned C.invariant would inject a call to A.invariant, and that invariant would occupy a vtable slot.

-Steve

Reply via email to