On Monday, May 21, 2018 14:33:44 Manu via Digitalmars-d wrote:
> How do virtual destructors work in normal D classes?

It is my understanding that destructors in D are never virtual but rather
that the runtime handles calling them correctly. IIRC, that relates to some
of the issues that make it so that you can't do stuff like call destroy in
@nogc code. And a quick test with __traits seems to indicate that
destructors are indeed not virtual:

    class C
    {
        void foo() {}
        ~this() {}
    }

    pragma(msg, __traits(isVirtualFunction, C.foo));
    pragma(msg, __traits(isVirtualFunction, C.__dtor));

    void main()
    {
    }

prints

true
false

- Jonathan M Davis

Reply via email to