Can anyone explain what this code extract is doing? My first guess was that d() calls the destructor of itself but then I wondered why you couldn’t just call the destructor of T yourself.
class T
{
void d()
{
this -> ~T();
}
}
Thank you in advance.
That explicitly calls the destructor for
Tonthis. The name of the destructor forTis~T.Usually this isn’t necessary, as C++ takes care of calling the destructor for an object when it goes out of scope or when you
deleteit. Without more context it’s hard to say what is going on in your code and why the author thought that was necessary.