Class member function calls inside ctor and dtor
Thomas Mader
thomas.mader at gmail.com
Sat Jan 27 16:18:26 UTC 2018
On Saturday, 27 January 2018 at 14:48:08 UTC, Johan Engelen wrote:
> I'm working on devirtualization and for that it's crucial to
> know some spec details (or define them in the spec if they
> aren't yet).
>
> Currently, calling non-final member functions in the destructor
> is allowed and these indirect calls are to the possibly
> overridden functions of derived classes. That is, inside a base
> class constructor, the object's type is its final type (so
> possibly of a derived class). This is the same in the
> destructor. Thus, the object's dynamic type does not change
> during its lifetime.
Can't answer your question but have a little question.
How is the behavior different to the situation in C++? They argue
that it's not good to call virtual methods in Con-/Destructors in
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-ctor-virtual
So I guess it should better be not used in D as well?
More information about the Digitalmars-d
mailing list