Q:

What does this -> ~T() do?

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.

A:

That explicitly calls the destructor for T on this. The name of the destructor for T is ~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 delete it. Without more context it's hard to say what is going on in your code and why the author thought that was necessary.

